11:21 I know this is a simplification in the presentation, but this needs to be `return { coroutine_handle::from_promise(*this); }`. That effectively does the same thing, but it returns the coro handle (which the Task needs to hang on to as a member variable to preserve the coro).
That's the other way to implement it. Coroutine handle and reference to promise are basically synonyms: having one you can trivially get the other (unless the coroutine handle is type erased like this: *std::coroutine_handle* ). In this case it was easier to use a pointer to promise instead of coroutine handle since *Promise* exposes functionality that the *Task* implementation can access directly without converting a coroutine handle to a reference to promise every time.
Promise "lives" inside the coroutine frame, so calling *.destroy()* on the coroutine _handle_ effectively destroys the coroutine frame _and_ the promise, freeing all the resources used by the coroutine.
11:21 I know this is a simplification in the presentation, but this needs to be `return { coroutine_handle::from_promise(*this); }`. That effectively does the same thing, but it returns the coro handle (which the Task needs to hang on to as a member variable to preserve the coro).
That's the other way to implement it. Coroutine handle and reference to promise are basically synonyms: having one you can trivially get the other (unless the coroutine handle is type erased like this: *std::coroutine_handle* ).
In this case it was easier to use a pointer to promise instead of coroutine handle since *Promise* exposes functionality that the *Task* implementation can access directly without converting a coroutine handle to a reference to promise every time.
@@PaulSkeptic Ah yes this makes sense. I'm still rewatching this presentation every week or so to learn a little more each time :D
I very much enjoyed your Robert C. Weide joke at the beginning! :-D
10:12 shouldn't this custom deleter also call `delete on the Promise pointer too?
Promise "lives" inside the coroutine frame, so calling *.destroy()* on the coroutine _handle_ effectively destroys the coroutine frame _and_ the promise, freeing all the resources used by the coroutine.
12:50 - can we just write `U&&` instead of that complex `decltype(...)` expression?
Yes, you absolutely can.
Expression inside decltype is just a copypaste of the expression in initialization.