Coder Social home page Coder Social logo

jamboree / co2 Goto Github PK

View Code? Open in Web Editor NEW
333.0 33.0 32.0 343 KB

A C++ await/yield emulation library for stackless coroutine

C++ 98.37% CMake 1.63%
coroutines c-plus-plus header-only await async-programming yield c-plus-plus-14 concurrency generator multitasking

co2's People

Contributors

adevress avatar jamboree avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

co2's Issues

Just saying thanks !

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 ) ?

errors while compiling example

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);
^

Support for member functions

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.

Comparing boost.coroutine2 (stackful) to stackless coro implementation...

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.

What do you expect when a task is cancelled?

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...

  1. Don't call finalize after stack-unwinding, in this case, finalize may need a better name
  2. In finalize, check whether there's a result, if not, do nothing
  3. Let a task's result default to an error state so there's always a result

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.