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

Commit ab51ba2

Browse files
committed
% update Error mitigation strategies
1 parent 397701e commit ab51ba2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

basic.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1761,12 +1761,19 @@ But such code can't be considered an accidental mistake.
17611761

17621762
To avoid accidentally hanging coroutines whose lifetimes were not correctly limited, follow these rules:
17631763

1764-
* Use separate Scopes for different coroutines. This is the best practice,
1764+
* Use **separate Scopes** for different coroutines. This is the best practice,
17651765
as it allows explicitly defining lifetime dependencies between Scopes.
17661766
* Use `Scope::dispose()`. The `dispose()` method cancels coroutine execution and logs an error.
17671767
* Don’t mix semantically different coroutines within the same `Scope`.
17681768
* Avoid building hierarchies between `Scopes` with complex interdependencies.
17691769
* Do not use cyclic dependencies between `Scopes`.
1770+
* The principle of single point of responsibility and `Scope` ownership.
1771+
Do not pass the `Scope` object to different coroutine functions (unless the action happens in a closure).
1772+
Do not store `Scope` objects in different places.
1773+
Violating this rule can lead to manipulations with `Scope`,
1774+
which may cause a deadlock or disrupt the application's logic.
1775+
* Child coroutines should not wait for their parents.
1776+
Child Scopes should not wait for their parents.
17701777

17711778
```php
17721779
namespace ProcessPool;

0 commit comments

Comments
 (0)