summaryrefslogtreecommitdiffstats
path: root/src/fiber.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/fiber.h')
-rw-r--r--src/fiber.h27
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