Giter Site home page Giter Site logo

coroutine-demo's Introduction

C++ Coroutines in MSVC 2015

[n4134] - Resumable Functions rev2 was implemented in VS2015 Update 2 [1]

It appears that Visual Studio 2015 Update 3 actually implements http://open-std.org/JTC1/SC22/WG21/docs/papers/2015/p0057r0.pdf

an awaitable type needs to define 3 member functions.

bool await_ready() const;
void await_suspend(std::coroutine_handle<>);
T await_resume();

await_ready() is called when co_await is used on an awaitable. It returns false to suspend, otherwise it needs to have a value ready.

await_suspend() is called when await_ready() returns false, right before the function is suspended.

await_resume() is called right before this function is resumed.

The coroutine promise is looked up under the resumable function type R::promise_type A resumable function must specify coroutine promise, which has:

get_return_object()
initial_suspend()
final_suspend()

Coroutines must be of type resumable function:

struct promise_type;
constructor(coroutine_handle<promise_type> c);
destructor(); // call c.destroy()
[n4134]http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4134.pdf
[1]https://github.com/kirkshoop/await

coroutine-demo's People

Contributors

ratiotile avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

plumpmath

coroutine-demo's Issues

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.