@@ -20,19 +20,13 @@ public function __construct()
20
20
21
21
public function resume (mixed $ value ): void
22
22
{
23
- if ($ this ->fiber === null ) {
24
- $ suspend = static fn () => $ value ;
25
- if (\Fiber::getCurrent () !== self ::$ scheduler ) {
26
- self ::$ suspend = $ suspend ;
27
- } else {
28
- \Fiber::suspend ($ suspend );
29
- }
30
- return ;
23
+ if ($ this ->fiber !== null ) {
24
+ $ this ->fiber ->resume ($ value );
25
+ } else {
26
+ self ::$ suspend = static fn () => $ value ;
31
27
}
32
28
33
- $ this ->fiber ->resume ($ value );
34
-
35
- if (self ::$ suspend ) {
29
+ if (self ::$ suspend !== null && \Fiber::getCurrent () === self ::$ scheduler ) {
36
30
$ suspend = self ::$ suspend ;
37
31
self ::$ suspend = null ;
38
32
@@ -42,19 +36,13 @@ public function resume(mixed $value): void
42
36
43
37
public function throw (\Throwable $ throwable ): void
44
38
{
45
- if ($ this ->fiber === null ) {
46
- $ suspend = static fn () => throw $ throwable ;
47
- if (\Fiber::getCurrent () !== self ::$ scheduler ) {
48
- self ::$ suspend = $ suspend ;
49
- } else {
50
- \Fiber::suspend ($ suspend );
51
- }
52
- return ;
39
+ if ($ this ->fiber !== null ) {
40
+ $ this ->fiber ->throw ($ throwable );
41
+ } else {
42
+ self ::$ suspend = static fn () => throw $ throwable ;
53
43
}
54
44
55
- $ this ->fiber ->throw ($ throwable );
56
-
57
- if (self ::$ suspend ) {
45
+ if (self ::$ suspend !== null && \Fiber::getCurrent () === self ::$ scheduler ) {
58
46
$ suspend = self ::$ suspend ;
59
47
self ::$ suspend = null ;
60
48
0 commit comments