Articles & Books

C++ coroutines: Waiting synchronously for our coroutine to complete--Raymond Chen

The series continue.

C++ coroutines: Waiting synchronously for our coroutine to complete

by Raymond Chen

From the article:

Last time, we added an extension point that permitted us to respond differently to the completion of the coroutine. We’re going to put that extension point to good use by adding the ability to wait synchronously for the coroutine to complete.

C++ coroutines: Adding COM context support to our awaiter--Raymond Chen

The series continue.

C++ coroutines: Adding COM context support to our awaiter

by Raymond Chen

From the article:

You may want to have awaiters that apply custom resume behavior. For example, in Windows, you are likely to want your awaiter to preserve the COM thread context. For X11 programming, you may want to the awaiter to return to the render thread if the co_await was initiated from the render thread. Today we’ll add the ability to customize the awaiter to our coroutine promise type...

C++ coroutines: Snooping in on the coroutine body--Raymond Chen

The series continue.

C++ coroutines: Snooping in on the coroutine body

by Raymond Chen

From the article:

A coroutine promise can snoop on the coroutine body by implementing a method named await_transform. Any time the coroutine body performs a co_await, the thing being awaited is passed through the await_transform method, and whatever await_transform returns is the thing that is actually awaited. This is the mysterious “We’re not ready to talk about step 1 yet” that kept reappearing in our introduction to awaitable objects...

The most popular C++ standard features

The next article on the results from the Meeting C++ survey

The most popular C++ standard features

by Jens Weller

From the article:

Continuing the series about the Meeting C++ survey results with a look at the standard features. Last week I compared the ISOCPP survey to the one of Meeting C++.

When I was looking into the questions I could ask in the survey tool, it came to my mind that it would be interesting to know more about the details of standards, not just asking for which standard folks use in various ways. So in this blog post, I'm going to show you the questions about standard feature usage.

C++ coroutines: How do I create a coroutine that terminates on an unhandled exception?--Raymond Chen

The series continue.

C++ coroutines: How do I create a coroutine that terminates on an unhandled exception?

by Raymond Chen

From the article:

Last time, we saw that declaring a coroutine as noexcept doesn’t do what you think. The noexcept specific says that production of the coroutine does not throw an exception, but it says nothing about what happens during execution of the coroutine. If an exception occurs inside the coroutine, the promise’s unhandled_exception method decides what happens...

C++ coroutines: What does it mean when I declare my coroutine as noexcept?--Raymond Chen

The series continue.

C++ coroutines: What does it mean when I declare my coroutine as noexcept?

by Raymond Chen

From the article:

Suppose you want a coroutine that terminates on unhandled exceptions, or equivalently (looking at it from the consumer side) a coroutine that never throws an exception when awaited. For regular functions, the way to say this is to put the noexcept exception specification on your function declaration...

C++ coroutines: Improving cold-start coroutines which complete synchronously--Raymond Chen

The series continue.

C++ coroutines: Improving cold-start coroutines which complete synchronously

by Raymond Chen

From the article:

Last time, we learned that the naïve implementation of cold-start coroutines is susceptible to stack build-up. What we want is for await_suspend to return false if the coroutine completed synchronously. This is tricky because that reintroduces a race condition where the coroutine runs asynchronously and completes at the same time we try to transition from synchronous to asynchronous behavior in the awaiter...

C++ coroutines: Cold-start coroutines--Raymond Chen

The series continue.

C++ coroutines: Cold-start coroutines

by Raymond Chen

From the article:

So far, our coroutine promise has implemented a so-called hot-start coroutine, which is one that begins running as soon as it is created. Another model for coroutines is the so-called cold-start coroutine, which is one that doesn’t start running until it is awaited...