blob: 7307bec2bc17766570ae0cec9242879720e0123a (
plain) (
blame)
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
|
#include "lib/matcha.h"
#include <cassert>
#include <cstdio>
Thread* gThread1 = nullptr;
void thread1_1() {
puts("thread1_1");
}
void thread1() {
puts("start thread1");
thread1_1();
puts("finish thread1");
assert(gThread1 != nullptr);
yield_from(*gThread1);
}
int main() {
puts("start main thread");
Thread t(thread1);
gThread1 = &t;
yield_to(t);
gThread1 = nullptr;
puts("finish main thread");
return 0;
}
|