diff --git a/README.md b/README.md index ffec742..67e9fe0 100644 --- a/README.md +++ b/README.md @@ -421,11 +421,11 @@ try { ## Coroutine -If `define.hpp` is included, you can initialize coroutines using `coroutine`; if not, just use `boost::asio::awaitable`. +If `define.hpp` is included, you can initialize coroutines using `asyncable`; if not, just use `boost::asio::awaitable`. ```c++ -coroutine c2(int a) { +asyncable c2(int a) { co_return a * 2; } @@ -440,7 +440,7 @@ Or using a lambda expression: ```c++ -async_([]() -> coroutine { +async_([]() -> asyncable { std::cout << "Hello" << std::endl; co_await c2(4); co_return; diff --git a/lib/define.hpp b/lib/define.hpp index 721f484..b14acf4 100644 --- a/lib/define.hpp +++ b/lib/define.hpp @@ -12,7 +12,7 @@ namespace asynco { #define await_ marcelb::asynco::await_ #if __cplusplus >= 202002L -#define coroutine boost::asio::awaitable +#define asyncable boost::asio::awaitable #endif } diff --git a/test/main.cpp b/test/main.cpp index 5902bc2..d6a7c4b 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -17,13 +17,13 @@ using namespace marcelb::asynco; using namespace std; using namespace this_thread; -coroutine c2 (int a) { +asyncable c2 (int a) { co_return a*2; } -coroutine c () { +asyncable c () { cout << "Ispisi" << endl; co_await c2(0); co_return; @@ -458,7 +458,7 @@ int main () { // // ---------------------------------------------------------------------------------------------------- - // auto i = async_ ( []() -> coroutine { + // auto i = async_ ( []() -> asyncable { // cout << "aaaa" << endl; // co_return 5; // }); @@ -470,7 +470,7 @@ int main () { // cout << i_ << endl; - // Periodic a( []() -> coroutine { + // Periodic a( []() -> asyncable { // cout << "corutina" << endl; // // co_await retint(); // }, 2000); @@ -485,15 +485,15 @@ int main () { // Trigger evintString; Trigger<> evoid; - // ev2int.on("sum", [](int a, int b) -> coroutine { + // ev2int.on("sum", [](int a, int b) -> asyncable { // cout << "Sum " << a+b << endl; // }); - // ev2int.on("sum", [](int a, int b) -> coroutine { + // ev2int.on("sum", [](int a, int b) -> asyncable { // cout << "Sum done" << endl; // }); - // evintString.on("substract", [](int a, string b) -> coroutine { + // evintString.on("substract", [](int a, string b) -> asyncable { // cout << "Substract " << a-stoi(b) << endl; // }); @@ -503,33 +503,35 @@ int main () { }); - // auto c1 = []() -> coroutine { + // auto c1 = []() -> asyncable { // cout << "Roge " << endl; // co_return; // }; - // async_ ( c2(3)); + async_ ( c2(3)); - async_ ([]() -> coroutine { + + async_ ([]() -> asyncable { cout << "Hello" << endl; co_await c2(4); co_return; }()); - Periodic p( []() { - auto a = await_ (async_ (c2(34))); - cout << "A " << a << endl; - }, 2000); + // Periodic p( []() { + // async_ ( + // c2(34) + // ); + // }, 2000); - // await_( async_co2 ( [c1 = move(c1)]() -> coroutine { + // await_( async_co2 ( [c1 = move(c1)]() -> asyncable { // cout << "Baba roga" << endl; // co_await c1(); // })); // string emited2 = "2"; - // evoid.on("void", [&]() -> coroutine { + // evoid.on("void", [&]() -> asyncable { // cout << "Void emited " << emited2 << endl; // });