blob: 5beb27413861d6b40570f3aeea78155338c612f3 (
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
44
45
46
47
48
49
50
51
52
53
54
55
56
|
#ifndef INCLUDE_COROUTINE_H
#define INCLUDE_COROUTINE_H
class Coroutine
{
public:
enum Status
{
NotStarted,
Running,
Stopped,
Terminated
};
public:
Coroutine();
virtual ~Coroutine();
void createStack(int size = 32768);
void setStack(void *memory, int size);
bool cont();
static void yield();
Status status() const
{ return _status; }
static Coroutine *currentCoroutine();
#ifdef qdoc
static Coroutine* build(Function function, ...);
#endif
// add declarations for static build(...) function
#include "coroutinebuilddeclaration_p.h"
protected:
virtual void run() {}
private: // not copyable
Coroutine(const Coroutine &);
Coroutine &operator=(const Coroutine &);
private:
static void yieldHelper(Status stopStatus);
static void entryPoint();
void *_stackData;
void *_stackPointer;
Coroutine *_previousCoroutine;
Status _status;
};
// add definitions for static build(...) function
#include "coroutinebuilddefinition_p.h"
#endif // INCLUDE_COROUTINE_H
|