-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathcpps_async_task.h
More file actions
61 lines (57 loc) · 1.57 KB
/
cpps_async_task.h
File metadata and controls
61 lines (57 loc) · 1.57 KB
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
57
58
59
60
61
#ifndef CPPS_ASYNC_TASK_CPPS_HEAD_
#define CPPS_ASYNC_TASK_CPPS_HEAD_
//===================================
//@Author : Johnson
//@QQ : 88481106
//@Email : 88481106@qq.com
//@Date : 2020/12/5 (yy/mm/dd)
//@Module : CPPS_ASYNC_TASK
//@Description : 协程任务(协程运行体)
//@website : http://cppscript.org
//==================================
namespace cpps
{
enum
{
cpps_async_task_pending,
cpps_async_task_running,
cpps_async_task_done,
cpps_async_task_cancelled,
cpps_async_task_timeouted,
cpps_async_task_thorw,
cpps_async_task_terminate,
};
struct cpps_async_task
{
cpps_async_task();
virtual ~cpps_async_task();
static void run(cpps_async_task* p,C*c);
cpps_value getresult();
cpps_async_object* getobject();
int8 state();
bool cancelled();
bool done();
cpps_integer get_id();
bool timeout();
bool pending();
bool running();
void cancel();
void start(C* cstate);
void add_done_callback(cpps_value func, cpps_value context);
void remove_done_callback();
void call_done_callback(C* c);
void set_name(std::string n);
std::string get_name();
cpps_async_object* async_object;
coroutine::routine_t rt;
int8 runstate;
std::vector<cpps_stack*> takestacklist;
cpps_value ret; /*return 返回值*/
cpps_value callback_func; /*call back func*/
cpps_value callback_context; /*call back func context*/
std::string name;
cpps_trycatch_error throwerr;//可能携带异常回来
C* c;
};
}
#endif //CPPS_ASYNC_TASK_CPPS_HEAD_