Skip to content
This repository was archived by the owner on Jun 16, 2025. It is now read-only.

Commit 0cd3a45

Browse files
committed
Add "Cancellable by design" principle to documentation; clarify coroutine lifetime management
1 parent 85290d2 commit 0cd3a45

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

basic.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -264,32 +264,32 @@ if the **Scheduler** implements a runtime control mechanism similar to `max_exec
264264

265265
Please see [Maximum activity interval](#maximum-activity-interval) for more information.
266266

267-
### Namespace
268-
269-
All functions, classes, and constants defined in this **RFC** are located in the `Async` namespace.
270-
Extensions for **Scheduler/Reactor** are allowed to extend this namespace with functions and classes,
271-
provided that they are directly related to concurrency functionality.
272-
273267
### Cancellable by design
274268

275-
This RFC is based on the principle of **"Cancellable by design"**, which can be described as follows:
269+
This **RFC** is based on the principle of **"Cancellable by design"**, which can be described as follows:
276270

277-
> By default, coroutines **should be** designed in such a way that their
271+
> By default, coroutines **should be** designed in such a way that their
278272
> cancellation at any moment does not compromise data integrity.
279273
280274
> Coroutines launched without a defined `Scope` or lifetime **must** adhere to the "Cancellable by design" principle.
281275
282276
> If a coroutine’s lifetime needs to be controlled — it **MUST** be done **EXPLICITLY**!
283277
284-
In practice, this means that if a coroutine is created using the expression `spawn <callable>`,
285-
the developer treats it as non-critical in terms of data integrity.
286-
If the developer needs to manage the coroutine’s lifetime, they will use the expression `spawn with`.
278+
In practice, this means that if a coroutine is created using the expression `spawn <callable>`,
279+
the developer treats it as non-critical in terms of data integrity.
280+
If the developer needs to manage the coroutine’s lifetime, they will use the expression `spawn with`.
287281
In other words, the developer must take extra steps to explicitly extend the coroutine's lifetime.
288282

289-
The **Cancellable by design** principle works especially well for server-side applications,
290-
but it can conflict with the principles of **structured concurrency**.
283+
The **Cancellable by design** principle works especially well for server-side applications,
284+
but it can conflict with the principles of **structured concurrency**.
291285
This **RFC** proposes a balance between both approaches.
292286

287+
### Namespace
288+
289+
All functions, classes, and constants defined in this **RFC** are located in the `Async` namespace.
290+
Extensions for **Scheduler/Reactor** are allowed to extend this namespace with functions and classes,
291+
provided that they are directly related to concurrency functionality.
292+
293293
### Coroutine
294294

295295
> A `Coroutine` is an `execution container`, transparent to the code,

0 commit comments

Comments
 (0)