This repository was archived by the owner on Jun 16, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -1761,12 +1761,19 @@ But such code can't be considered an accidental mistake.
17611761
17621762To 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,
17651765as 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
17721779namespace ProcessPool;
You can’t perform that action at this time.
0 commit comments