zengine-old/test/co_context/src/main.cpp

24 lines
574 B
C++
Raw Normal View History

2024-01-29 12:16:21 +08:00
#include<iostream>
#include "co_context/io_context.h"
#include "co_context/lazy_io.h"
using namespace std;
using namespace co_context;
2024-02-07 16:24:11 +08:00
2024-01-29 12:16:21 +08:00
task<> the_answer(int t) {
const char* name = "hello";
cout << "lazyout" << endl;
co_await lazy::write(1, { name, 5 }, 10);
cout << name << t << endl;
co_return;
}
int main() {
io_context context;
int a = 3;
2024-02-07 16:24:11 +08:00
auto b = the_answer(a);
b.get_handle().resume();
b.get_handle().resume();
//context.co_spawn(the_answer(a));
//context.co_spawn(the_answer(5));
//context.start();
2024-01-29 12:16:21 +08:00
return 0;
}