We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c2c7fd7 commit 838e13cCopy full SHA for 838e13c
src/Loop.php
@@ -39,9 +39,27 @@ public function sleep(int|float $seconds)
39
}
40
41
42
- public function defer(callable $callable): void
+ public function await(callable|Fiber $fiber): mixed
43
{
44
- $this->callStack[] = new Fiber($callable);
+ if(!($fiber instanceof Fiber)){
45
+ $fiber = new Fiber($fiber);
46
+ }
47
+ $fiber->start();
48
+ while ($fiber->isTerminated() === FALSE) {
49
+ $fiber->resume();
50
+
51
+ if(!$fiber->isTerminated()){
52
+ Fiber::suspend();
53
+ }else{
54
+ break;
55
56
57
+ return $fiber->getReturn();
58
59
60
+ public function defer(callable|Fiber $fiber): void
61
+ {
62
+ $this->callStack[] = ($fiber instanceof Fiber) ? $fiber : new Fiber($fiber);
63
64
65
public function run()
0 commit comments