44
55### 📚 Diagrams Overview
66
7- This ** RFC** is quite complex due to the number of logical connections.
7+ This ** RFC** is quite complex due to the number of logical connections.
88Please use the diagrams from the table to simplify understanding.
99
1010| Diagram Name | Description |
@@ -226,12 +226,12 @@ function mergeFiles(string ...$files): string
226226
227227### Scheduler and Reactor
228228
229- ** Scheduler** and ** Reactor** must be implemented as ` PHP ` extensions that implement low-level interfaces.
229+ ** Scheduler** and ** Reactor** must be implemented as ` PHP ` extensions that implement low-level interfaces.
230230
231231The ** Scheduler** and ** Reactor** interfaces are part of the implementation of this ** RFC** .
232232
233233The behavior of ** Scheduler** and ** Reactor** must not contradict the logic of the ** RFC** .
234- Components cannot override the logic of expressions such as spawn, async, suspend, and so on.
234+ Components cannot override the logic of expressions such as spawn, async, suspend, and so on.
235235However, this ** RFC** does not impose any restrictions on extending functionality.
236236
237237It is allowed to use the ** Async** namespace for new functions or objects in ** Scheduler** and ** Reactor** .
@@ -298,7 +298,7 @@ However, it cannot be stopped externally.
298298> It is permissible to stop a coroutine’s execution externally for two reasons:
299299> * To implement multitasking.
300300> * To enforce an active execution time limit.
301- > Please see [ Maximum activity interval] ( #maximum-activity-interval ) for more information.
301+ > Please see [ Maximum activity interval] ( #maximum-activity-interval ) for more information.
302302
303303A suspended coroutine can be resumed at any time.
304304The ` Scheduler ` component is responsible for the coroutine resumption algorithm.
@@ -944,7 +944,7 @@ Caught exception: Error
944944#### Task Race
945945
946946Sometimes it's necessary to get the result of the fastest task from a set.
947- The ** ` Scope::firstDirectTask ` ** method returns a trigger
947+ The ** ` Scope::firstDirectTask ` ** method returns a trigger
948948that fires as soon as at least one of the direct tasks in the ** Scope** is completed.
949949
950950** Example:**
@@ -1148,7 +1148,7 @@ Resource control at the top level is a useful tool for organizing applications,
11481148
11491149##### Explicit and Implicit Tasks
11501150
1151- The division of coroutines into explicit and implicit tasks is unique to this **RFC**
1151+ The division of coroutines into explicit and implicit tasks is unique to this **RFC**
11521152and does not exist in any other language.
11531153
11541154The **Java Loom** project, for example, requires that the `Scope` is always explicitly specified.
@@ -1157,7 +1157,7 @@ It is possible to discard the `spawn` expression without specifying
11571157a `Scope` or always create a coroutine in the global scope,
11581158as **Java Loom** and **Kotlin** do.
11591159
1160- However, explicit task creation in the global scope is prohibited by the rules of this RFC,
1160+ However, explicit task creation in the global scope is prohibited by the rules of this RFC,
11611161as it is considered an **antipattern** that is well-studied.
11621162
11631163The ability to control the default `Scope` for `spawn` allows frameworks to manage user code by enforcing common rules.
@@ -1377,7 +1377,7 @@ The following expressions do not affect the reference count of the `$scope` obje
13771377* ` Scope::inherit($scope) ` does ** not** increase the reference count of either the parent or the child ` $scope ` .
13781378
13791379The following statements are true:
1380- 1 . The lifetime of a child ` Scope ` cannot exceed that of its parent.
1380+ 1 . The lifetime of a child ` Scope ` cannot exceed that of its parent.
13811381 If the parent is destroyed, the child ` Scope ` will be closed.
138213822 . If the child ` Scope ` is released, the parent will automatically lose its connection to it.
13831383
@@ -1477,10 +1477,7 @@ A new child `Scope` can be created using a special constructor:
14771477It returns a new ` Scope ` object that acts as a child.
14781478A coroutine created within the child ` Scope ` can also be considered a child relative to the coroutines in the parent ` Scope ` .
14791479
1480- The advantage of a child ` Scope ` is that it’s not “detached” — it’s attached to its parent.
1481- The code that owns the parent ` Scope ` can control the entire hierarchy of coroutines at once.
1482-
1483- Let’s look at an example.
1480+ ** An example:**
14841481
14851482``` php
14861483use Async\Scope;
@@ -1571,7 +1568,7 @@ function socketServer(): void
15711568```
15721569Let's examine how this example works.
15731570
1574- 1 . ` socketServer ` creates a new Scope for coroutines that will handle all connections.
1571+ 1 . ` socketServer ` creates a new ` Scope ` for coroutines that will handle all connections.
157515722 . Each new connection is processed using ` connectionHandler() ` in a separate ` Scope ` ,
15761573 which is inherited from the main one.
157715743 . ` connectionHandler ` creates a new ` Scope ` for the ` connectionLimiter ` and ` connectionChecker ` coroutines.
@@ -2075,7 +2072,7 @@ The following scenarios are considered potentially erroneous:
207520721 . A coroutine belongs to a global scope and is not awaited by anyone (a ** zombie coroutine** ).
207620732 . The root scope has been destroyed (its destructor was called), but no one awaited
20772074 it or ensured that its resources were explicitly cleaned up (e.g., by calling ` $scope->cancel() ` or ` $scope->dispose() ` ).
2078- 3 . Tasks were not cancelled using the ` cancel() ` method, but through a call to ` dispose() ` .
2075+ 3 . ** Implicit Tasks** were not cancelled using the ` cancel() ` method, but through a call to ` dispose() ` .
20792076 This indicates that the programmer did not intend to cancel the execution of the coroutine,
20802077 yet it happened because the scope was destroyed.
208120784 . Deadlocks caused by circular dependencies between coroutines.
@@ -3046,7 +3043,7 @@ The `Async\getCoroutines()` method returns an array of all coroutines in the app
30463043
30473044#### Parallels with Java Loom
30483045
3049- This ** RFC** unintentionally contains many parallels with the Java Loom StructuredTaskScope API,
3046+ This ** RFC** unintentionally contains many parallels with the Java Loom StructuredTaskScope API,
30503047which is very similar to this ** RFC** .
30513048
30523049| ** Feature** | ** PHP True Async (Scope)** | ** Java Loom (StructuredTaskScope)** |
0 commit comments