equal
deleted
inserted
replaced
|
1 /* $Id$ */ |
|
2 |
|
3 /** @file fiber.hpp */ |
|
4 |
|
5 #ifndef FIBER_HPP |
|
6 #define FIBER_HPP |
|
7 |
|
8 typedef void (CDECL *FiberFunc)(void *); |
|
9 |
|
10 class Fiber { |
|
11 public: |
|
12 /** |
|
13 * Switch to this fiber. |
|
14 */ |
|
15 virtual void SwitchToFiber() = 0; |
|
16 |
|
17 /** |
|
18 * Exit a fiber. |
|
19 */ |
|
20 virtual void Exit() = 0; |
|
21 |
|
22 /** |
|
23 * Check if a fiber is running. |
|
24 */ |
|
25 virtual bool IsRunning() = 0; |
|
26 |
|
27 /** |
|
28 * Get the 'param' data of the Fiber. |
|
29 */ |
|
30 virtual void *GetFiberData() = 0; |
|
31 |
|
32 /** |
|
33 * Virtual Destructor to mute warnings. |
|
34 */ |
|
35 virtual ~Fiber() {}; |
|
36 |
|
37 /** |
|
38 * Create a new fiber, calling proc(param) when running. |
|
39 */ |
|
40 static Fiber *New(FiberFunc proc, void *param); |
|
41 |
|
42 /** |
|
43 * Attach a current thread to a new fiber. |
|
44 */ |
|
45 static Fiber *AttachCurrent(void *param); |
|
46 |
|
47 /** |
|
48 * Get the 'param' data of the current active Fiber. |
|
49 */ |
|
50 static void *GetCurrentFiberData(); |
|
51 }; |
|
52 |
|
53 #endif /* FIBER_HPP */ |