@@ -909,10 +909,10 @@ The coroutine with text `"Child of Task 1"` also belongs to `$scope`,
909909meaning it is at the same level as the ` "Task 1" ` and ` "Task 2" ` coroutines.
910910
911911If the ` $scope ` object is destroyed (i.e., its destructor is called),
912- the coroutines that did not have time to complete will be marked as "leaked coroutine" or "orphan coroutine"
912+ the coroutines that did not have time to complete will be marked as "zombie coroutine" or "orphan coroutine"
913913
914- Leaked coroutines are considered a result of a programming error and are handled specially
915- (See section: [ Leaked coroutine policy] ( #leaked -coroutine-policy ) ).
914+ Zombie coroutines are considered a result of a programming error and are handled specially
915+ (See section: [ Zombie coroutine policy] ( #zombie -coroutine-policy ) ).
916916
917917``` php
918918use Async\Scope;
@@ -937,7 +937,7 @@ unset($scope);
937937** Expected output:**
938938
939939```
940- Warning: Coroutine is leaked at ...
940+ Warning: Coroutine is zombie at ...
941941Task 1
942942Task 2
943943Child of Task 1
@@ -1030,7 +1030,7 @@ Let's say we have a function that creates an array of tasks performing some back
10301030``` php
10311031function fetchProfile(string $user): array
10321032{
1033- spawn { // <- a leaked coroutine
1033+ spawn { // <- a zombie coroutine
10341034 sleep(100);
10351035 };
10361036}
@@ -1106,7 +1106,7 @@ When the `await $scope->directTasks()` has completed,
11061106the coroutine created by ` processUser ` will not stop its execution.
11071107
11081108The ` finally ` block calls ` $scope->dispose() ` , which cancels all coroutines that were created within the ` Scope ` .
1109- Calling ` dispose() ` explicitly cancels all leaked coroutines with a warning message.
1109+ Calling ` dispose() ` explicitly cancels all zombie coroutines with a warning message.
11101110
11111111You can also use the ` disposeAfterTimeout ` and ` disposeSafely ` methods
11121112as alternative scenarios for cleaning up a ` Scope ` , see [ Scope disposal] ( #scope-disposal ) .
@@ -1386,20 +1386,20 @@ since the exact order of coroutines in the execution queue cannot be determined
13861386The ` Async\Scope ` class implements several methods for resource cleanup:
13871387
13881388- ` dispose ` – cleans up resources and cancels coroutines, possibly with errors.
1389- - ` disposeSafely ` – cleans up resources while preserving leaked coroutines.
1389+ - ` disposeSafely ` – cleans up resources while preserving zombie coroutines.
13901390- ` disposeAfterTimeout ` – cleans up resources and cancels coroutines after a timeout.
13911391
13921392The ` Scope::dispose* ` methods terminates the execution of a ` Scope ` differently than ` cancel() ` .
13931393
13941394It goes through all child coroutines that were explicitly defined using a ` spawn with ` expression and cancels them.
1395- All implicit coroutines that have not completed execution are marked as ** Leaked ** .
1395+ All implicit coroutines that have not completed execution are marked as ** Zombie ** .
13961396
1397- When a ** Leaked ** coroutine is detected, PHP generates a warning indicating the location where the coroutine was started.
1397+ When a ** Zombie ** coroutine is detected, PHP generates a warning indicating the location where the coroutine was started.
13981398The later behavior depends on the selected strategy:
13991399
14001400- ` dispose ` – immediately cancels the coroutine.
14011401- ` disposeAfterTimeout ` – delays the cancellation for a specified duration.
1402- - ` disposeSafely ` – runs the coroutine under the ** Leaked ** policy.
1402+ - ` disposeSafely ` – runs the coroutine under the ** Zombie ** policy.
14031403
14041404``` php
14051405use function Async\Scope\delay;
@@ -1426,9 +1426,9 @@ $scope->disposeSafely();
14261426** Expected output:**
14271427
14281428```
1429- Warning: Coroutine is leaked at ...
1430- Warning: Coroutine is leaked at ...
1431- Warning: Coroutine is leaked at ...
1429+ Warning: Coroutine is zombie at ...
1430+ Warning: Coroutine is zombie at ...
1431+ Warning: Coroutine is zombie at ...
14321432Root task
14331433Task 1
14341434Task 2
@@ -1462,9 +1462,9 @@ $scope->dispose();
14621462** Expected output:**
14631463
14641464```
1465- Warning: Coroutine is leaked at ...
1466- Warning: Coroutine is leaked at ...
1467- Warning: Coroutine is leaked at ...
1465+ Warning: Coroutine is zombie at ...
1466+ Warning: Coroutine is zombie at ...
1467+ Warning: Coroutine is zombie at ...
14681468```
14691469
14701470#### Spawn with disposed scope
@@ -1654,7 +1654,7 @@ async &$object
16541654
16551655- ` bounded ` - a keyword that cancels all child coroutines
16561656 if they have not been completed by the time the ` Scope ` block exits.
1657- Without this attribute, such coroutines are marked as ** Leaked ** .
1657+ Without this attribute, such coroutines are marked as ** Zombie ** .
16581658
16591659- ` codeBlock ` - a block of code that will be executed in the ` Scope ` context.
16601660
@@ -1732,7 +1732,7 @@ Detecting erroneous situations when using coroutines is an important part of ana
17321732
17331733The following scenarios are considered potentially erroneous:
17341734
1735- 1 . A coroutine belongs to a global scope and is not awaited by anyone (a ** detached coroutine** ).
1735+ 1 . A coroutine belongs to a global scope and is not awaited by anyone (a ** zombie coroutine** ).
173617362 . The root scope has been destroyed (its destructor was called), but no one awaited
17371737it or ensured that its resources were explicitly cleaned up (e.g., by calling ` $scope->cancel() ` or ` $scope->dispose() ` ).
173817383 . Tasks were not cancelled using the ` cancel() ` method, but through a call to ` dispose() ` .
@@ -1745,7 +1745,7 @@ Developers are expected to write code in a way that avoids triggering these warn
17451745
17461746#### Error mitigation strategies
17471747
1748- The only way to create ** detached coroutines** is by using the ` spawn ` expression in the ` globalScope ` .
1748+ The only way to create ** zombie coroutines** is by using the ` spawn ` expression in the ` globalScope ` .
17491749However, if the initial code explicitly creates a scope and treats it as the application's entry point,
17501750the initializing code gains full control — because ` spawn <callable> ` will no longer
17511751be able to create a coroutine in ` globalScope ` , thus preventing the application from hanging beyond the entry point.
@@ -1850,7 +1850,7 @@ The lifetime of `watcherScope` matches that of `poolScope`, but not longer than
18501850The overall lifetime of all coroutines in the ` ProcessPool ` is determined by the lifetime of the ` ProcessPool `
18511851object or by the moment the ` stop() ` method is explicitly called.
18521852
1853- #### Leaked coroutine policy
1853+ #### Zombie coroutine policy
18541854
18551855Coroutines whose lifetime extends beyond the boundaries of their parent ` Scope `
18561856are handled according to a separate ** policy** .
@@ -1860,13 +1860,13 @@ terminate coroutines, which could lead to data integrity violations.
18601860
18611861If there are no active coroutines left in the execution queue and no events to wait for, the application is considered complete.
18621862
1863- Leaked coroutines differ from regular ones in that they are not counted as active.
1863+ Zombie coroutines differ from regular ones in that they are not counted as active.
18641864Once the application is considered finished,
1865- leaked coroutines are given a time limit within which they must complete execution.
1866- If this limit is exceeded, all leaked coroutines are canceled.
1865+ zombie coroutines are given a time limit within which they must complete execution.
1866+ If this limit is exceeded, all zombie coroutines are canceled.
18671867
1868- The delay time for handling leaked coroutines can be configured using
1869- a constant in the ` ini ` file: ` async.leaked_coroutine_timeout ` , which is set to two seconds by default.
1868+ The delay time for handling zombie coroutines can be configured using
1869+ a constant in the ` ini ` file: ` async.zombie_coroutine_timeout ` , which is set to two seconds by default.
18701870
18711871If a coroutine is created within a user-defined ` Scope ` , the programmer
18721872can set a custom timeout for that specific ` Scope ` using the ` Scope::disposeAfterTimeout(int $ms) ` method.
0 commit comments