forked from owent/libcopp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
safe_basic_coroutine_class.txt
34 lines (30 loc) · 1.33 KB
/
safe_basic_coroutine_class.txt
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
safe basic controller api:
1. create
2. start
3. yield
4. resume <=> ÓÚstart
5. stop
basic data structure:
1. caller running stack information
2. callee coroutine running stack information
3. stack context coroutine running stack context
safe basic data structure:
1. busy status (spin lock)
2. running status
process:
|new [busy status => unlock, running status => INVALID]
|create(coroutine_context_callback) [running status => START]
|start -@-> coroutine_context_callback [busy status => lock, running status => RUNNING]
|
V
|start/resume <-@-> coroutine_run --------- [busy status => lock]
^ | |
| V |
|start/resume <-@- yield | [busy status => unlock]
| |
V |
| -@-> coroutine_context_callback <-------- [running status => FINISHED]
|
V
|start/resume <-@- yield [busy status => unlock, running status => STOP]
|delete