zengine-old/engine/3rdparty/co_context/src/main.cpp

20 lines
481 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;
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;
context.co_spawn(the_answer(a));
context.co_spawn(the_answer(5));
context.start();
return 0;
}