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.

...

CppCon 2014 Lock-free by Example--Tony Van Eerd

While we wait for CppCon 2015 in September, we’re featuring videos of some of the 100+ talks from CppCon 2014. Here is today’s feature:

Lock-free by Example

by Tony Van Eerd

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

Dive into and follow along making a lock-free queue.

In particular, a multi-producer, multi-consumer, growing, shrinking, mostly contiguous, lock-free circular queue.

With this single (complicated!) example, we will come across, and attempt to solve, many of the typical problems found in lockfree programming, and delve into the pros and cons of various solutions to those problems.

A clever comment style--Andrzej Krzemieński

You will find here a solution to link a comment to its code:

A clever comment style

by Andrzej Krzemieński

From the article:

Comments are one of the most useful language features; in practically any programming language. Yet, they can become really a pain...

CppCon 2014 STL Features And Implementation Techniques--Stephan Lavavej

While we wait for CppCon 2015 in September, we’re featuring videos of some of the 100+ talks from CppCon 2014. Here is today’s feature:

STL Features And Implementation Techniques

by Stephan Lavavej

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

This session will cover selected STL features from C++11/14, both explaining how to use them and delving into implementation techniques that could be useful outside the STL.

I will avoid covering popular features you're already using (e.g. make_shared, make_unique) and obscure features of limited use (e.g. forward_list). The focus will be on useful but underappreciated features like dual-range algorithms, minimal allocators, and heterogeneous associative lookup.

Tippet: Use reference_wrapper to create views of data -- Indi

Explicit C++ describes how to use std::reference_wrapper to create alternative views of data.

Tippet: Use reference_wrapper to create views of data

by Indi

from the article:

When working with objects indirectly, always use references. Only use pointers to indicate optional referencing. But there’s one little hitch: because you can’t rebind references, you can’t simply have a container of references. Enter std::reference_wrapper.

The C++ highlights and more of GCC 5.1

The release of GCC 5.1 is a highlight, here is an overview on the most important new things:

The C++ highlights of GCC 5.1 and more

by Jens Weller

From the article:

Just recently, GCC 5.0 has been released as GCC5.1, the not only the newest version of GCC, but also bumping up the version number from 4 to 5. This release is a major milestone for GCC, but also for C++, as it brings full C++14 support, but yet not C++11(std=c++11) as the new default...

CppCast Episode 9: Asynchronous Programming with Hartmut Kaiser

Episode 9 of CppCast the only podcast by C++ developers for C++ developers. In this episode Rob and Jason are joined by Hartmut Kaiser to talk about Asynchronous Program and the HPX framework.

CppCast Episode 9: Asynchronous Programming with Hartmut Kaiser

by Rob Irving and Jason Turner

About the interviewee:

Hartmut Kaiser is an Adjunct Professor of Computer Science at Louisiana State University. At the same time, he holds the position of a senior scientist at the Center for Computation and Technology at LSU. He received his doctorate from the Technical University of Chemnitz (Germany) in 1988. He is probably best known through his involvement in open source software projects, mainly as the author of several C++ libraries he has contributed to Boost, which are in use by thousands of developers worldwide. He is a voting member of the ISO C++ Standards Committee and his current research is focused on leading the STE||AR group at CCT working on the practical design and implementation of the ParalleX execution model and related programming methods. In addition, he architected and developed the core library modules of SAGA for C++, a Simple API for Grid Applications.