jamboree / co2 Goto Github PK
View Code? Open in Web Editor NEWA C++ await/yield emulation library for stackless coroutine
A C++ await/yield emulation library for stackless coroutine
Just a quick message to say I experimented with your library and really liked it. Worked perfectly with Visual Studio 2015, clang osx and XCode.
Congrats !
Would you say that it can safely be used in production code (I do not have very high reliability needs, since my target app is gui-driven and does not require 100% availability ) ?
Hi,
I am getting errors while compiling asio echo example:
/usr/bin/g++ -c "/net/main.cpp" -O3 -std=c++14 -Wall -std=gnu++14 -DNDEBUG -o ./Release/main.cpp.o -I. -I.
In file included from /net/main.cpp:3:0:
./co2/coroutine.hpp: In function 'decltype (p->.try_suspend()) co2::detail::try_suspend(Promise*)':
./co2/coroutine.hpp:439:56: error: ambiguating new declaration of 'decltype (p->.try_cancel()) co2::detail::is_also_required()'
decltype(p->try_cancel()) is_also_required(void);
^
./co2/coroutine.hpp:438:35: note: old declaration 'decltype (p->.try_resume()) co2::detail::is_also_required()'
decltype(p->try_resume()) is_also_required(void);
^
./co2/coroutine.hpp: In function 'decltype (p->.try_resume()) co2::detail::try_resume(Promise*)':
./co2/coroutine.hpp:452:56: error: ambiguating new declaration of 'decltype (p->.try_cancel()) co2::detail::is_also_required()'
decltype(p->try_cancel()) is_also_required(void);
^
./co2/coroutine.hpp:451:36: note: old declaration 'decltype (p->.try_suspend()) co2::detail::is_also_required()'
decltype(p->try_suspend()) is_also_required(void);
^
./co2/coroutine.hpp: In function 'decltype (p->.try_cancel()) co2::detail::try_cancel(Promise*)':
./co2/coroutine.hpp:465:56: error: ambiguating new declaration of 'decltype (p->.try_resume()) co2::detail::is_also_required()'
decltype(p->try_resume()) is_also_required(void);
^
I'm trying to use co2 with non-static class member functions but cannot capture the "this" pointer. Is it supported? For now I'm using static member functions with explicit "this" as parameter.
Well, needless to say, but, unless I am really confused... it does not make even sense to compare stackful to stackless coroutines and conclude that co2 implementation is faster. It does not even mention that they implement different things and that stackful is more costly by its own nature and capabilities.
A task (or more general, a coroutine) is cancelled when its ref-count becomes zero or cancellation_requested()
returns true. A task is responsible for notifying the waiting coroutine(s), that is, when the result arrives (either value or error), its dependant(s) should get notified. But what if the result never arrives (i.e. when the task is cancelled)? There're some design options:
When a task is cancelled...
finalize
after stack-unwinding, in this case, finalize
may need a better namefinalize
, check whether there's a result, if not, do nothingA declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.