N4402: Resumable Functions (revision 4) -- Gor Nishanov, Jim Radigan

New WG21 papers are available. If you are not a committee member, please use the comments section below or the std-proposals forum for public discussion.

Document number: N4402

Date: 2015-03-31

Resumable Functions (revision 4)

by Gor Nishanov, Jim Radigan

Excerpt:

Revisions and History

This document supersedes N4286. Changes relative to N4286 include:

  • renaming customization points back to resumable_traits and resumable_handle as they were in N4134;
  • changing requirements on the return type of initial_suspend() and final_suspend() to be lexically convertible to bool;
  • changing requirements on the return type of yield_value() to be either of a void type or a type lexically convertible to bool;
  • making a set_result member function optional in a promise type; the absence of a set_result indicates that resumable function does not support an eventual return value and using await operator or for-await statement is not allowed in resumable functions with such promise;
  • altered cancellation mechanism in resumable functions; instead of using cancellation_requested() member function in a promise to indicate that on the next resume resumable function need to be cancelled, an explicit member function destroy() is added to the resumable_handle. A destroy() member function can be invoked to force resumption of coroutine to go on the cancel path;
  • added resume(), destroy(), and done() member functions to resumable_handle;
  • moved proposed wording into a separate document N4302;
  • removed trivial awaitables suspend_always, suspend_never and suspend_if; switching yield_value, initial_suspend, and final_suspend to return bool eliminated the need for those;

Terms and Definitions

Coroutine

A generalized routine that in addition to traditional subroutine operations such as invoke and return supports suspend and resume operations.

...

Add a Comment

Comments are closed.

Comments (0)

There are currently no comments on this entry.