From 9d614195cff948d69df417add0b08b2fe44d4ec5 Mon Sep 17 00:00:00 2001 From: Nicolas Noble Date: Thu, 1 Aug 2013 16:02:21 -0700 Subject: I'm surprised this worked so far. The yield / EAgain mechanism was pretty much broken when using stackless operations. --- includes/Task.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'includes') diff --git a/includes/Task.h b/includes/Task.h index 3e1b9cf..27cb0bc 100644 --- a/includes/Task.h +++ b/includes/Task.h @@ -167,10 +167,11 @@ class Task { struct ev_loop * getLoop(); bool isStackless() { return m_stackless; } protected: - void yield(bool stillRunning = false) throw (GeneralException); - void yield(Events::BaseEvent * evt) { - waitFor(evt); - yield(); + void yield(Events::BaseEvent * evt = NULL) throw (GeneralException) { + if (evt) + waitFor(evt); + if (yield(false)) + throw EAgain(NULL); } virtual void Do() = 0; void waitFor(Events::BaseEvent * event); @@ -190,6 +191,7 @@ class Task { m_okayToEAgain = true; } private: + bool yield(bool stillRunning); static size_t stackSize() { return 64 * 1024; } void setup(TaskMan * taskMan, void * stack); static bool needsStacks(); -- cgit v1.2.3