diff options
| author | Christian Kamm <christian.d.kamm@nokia.com> | 2010-03-12 14:50:40 +0100 |
|---|---|---|
| committer | Christian Kamm <christian.d.kamm@nokia.com> | 2010-03-26 13:05:02 +0100 |
| commit | b03a4b990d9d26f62958cb1968bcf463e6d87eb5 (patch) | |
| tree | 4b83dc518cfe7ae1c6309ec198934f63e523c762 /src/fiber.h | |
| parent | d0264201dd42d7735c41338f78c6065b2f9593bc (diff) | |
Use thread local storage for active fiber. Don't require inheritance.
Diffstat (limited to 'src/fiber.h')
| -rw-r--r-- | src/fiber.h | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/src/fiber.h b/src/fiber.h index 6afc57d..b7bbcb1 100644 --- a/src/fiber.h +++ b/src/fiber.h @@ -4,6 +4,8 @@ class Fiber { public: + typedef void(*StartFunction)(); + enum Status { NotStarted, @@ -13,36 +15,29 @@ public: }; public: - explicit Fiber(int stackSize = 32768); - virtual ~Fiber(); + explicit Fiber(StartFunction startFunction, int stackSize = 32768); + ~Fiber(); bool cont(); static void yield(); - static Fiber *currentFiber(); - Status status() { return _status; } - -protected: - // could be abstract if subclassing for start fiber - virtual void run() {} - + + static Fiber *currentFiber(); + private: // for the original fiber - Fiber(bool); + Fiber(); static void yieldHelper(Status stopStatus); - + static void entryPoint(); + + StartFunction _startFunction; void *_stackData; void *_stackPointer; Fiber *_previousFiber; Status _status; - - // should be thread local - static Fiber *_currentFiber; - - static void entryPoint(); }; #endif // INCLUDE_FIBER_H |
