blob: 7a7cd1c305d3f60b25c6e0fc35d2454b62848266 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#ifndef INCLUDE_COROUTINE_H
#define INCLUDE_COROUTINE_H
class Coroutine
{
public:
enum Status
{
NotStarted,
Running,
Stopped,
Terminated
};
public:
explicit Coroutine(int stackSize = 32768);
virtual ~Coroutine();
bool cont();
static void yield();
Status status()
{ return _status; }
static Coroutine *currentCoroutine();
protected:
virtual void run() {}
private:
// for the original coroutine
Coroutine(bool);
static void yieldHelper(Status stopStatus);
static void entryPoint();
void *_stackData;
void *_stackPointer;
Coroutine *_previousCoroutine;
Status _status;
};
#endif // INCLUDE_COROUTINE_H
|