From e1bae5b6dbd3f13df3cffc9c1fd188c9092fc5c1 Mon Sep 17 00:00:00 2001 From: Klemens Morgenstern Date: Fri, 22 Sep 2023 09:35:00 +0800 Subject: [PATCH] final review 2 update --- design.html | 6 +++++- reference.html | 25 ++++++++++++------------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/design.html b/design.html index 3407cefd..1fdd83a5 100644 --- a/design.html +++ b/design.html @@ -1074,7 +1074,7 @@

Associators

async uses concepts to check if those are present in its await_suspend functions.

-

That way custom coroutines can support cancellation, executors etc..

+

That way custom coroutines can support cancellation, executors and allocators.

In a custom awaitable you can obtain them like this:

@@ -1099,6 +1099,10 @@

Associators

};
+
+

Cancellation gets connected by co_await statements (if supported by the coroutine & awaitable), +including synchronization mechanism like select.

+

Threading

diff --git a/reference.html b/reference.html index 62598483..16e3bbcd 100644 --- a/reference.html +++ b/reference.html @@ -1015,14 +1015,12 @@

async/promise.hpp

-

Promises can also be used to spawn tasks easily.

-
-

Promises are by default attached. This means, that a cancellation is sent when the promise handles goes out of scope.

-

A promise can be detached by calling detach or by using the prefix + operator.

+

A promise can be detached by calling detach or by using the prefix + operator. +This is a runtime alternative to using detached.

@@ -1499,7 +1497,7 @@

use_task

The use_task completion token can be used to create a task from an async_ function. This is less efficient than use_op as it needs to allocate a coroutine frame, -but has an obvious return type and support Interrupt Wait.

+but has a simpler return type and supports Interrupt Wait.

@@ -1526,7 +1524,7 @@

async/detached.hpp

-

Promises are mainly used to spawn tasks easily.

+

Detached is used to run coroutines in the background easily.

@@ -2691,18 +2689,19 @@

async/wait_group.hpp

async/spawn.hpp

-

The spawn functions allow to use task directly with asio:

+

The spawn functions allow to run task on an asio executor/execution_context +and consume the result with a completion token.

-
auto spawn(                            task<T>    && t, CompletionToken&& token);
-auto spawn(asio::io_context & context, task<T>    && t, CompletionToken&& token);
-auto spawn(Executor executor,          task<T>    && t, CompletionToken&& token);
+
auto spawn(Context & context, task<T> && t, CompletionToken&& token);
+auto spawn(Executor executor, task<T> && t, CompletionToken&& token);
-

Spawn will post both ways, so it is safe to use task to run the task -on another executor and consume the result on the current one with use_op.

+

Spawn will dispatch it’s initiartion and post the completion. S +That makes it safe to use task to run the task on another executor +and consume the result on the current one with use_op.

Example

@@ -2728,7 +2727,7 @@

Example

The caller needs to make sure that the executor is not running on multiple threads -concurrently, e,g, by using a single-threaded context. +concurrently, e,g, by using a single-threaded asio::io_context or a strand.