projects
/
m6w6
/
seekat
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
|
github
raw
|
patch
|
inline
| side by side (parent:
98264bf
)
simplify generator invoker
author
Michael Wallner
<mike@php.net>
Tue, 17 May 2016 07:45:54 +0000
(09:45 +0200)
committer
Michael Wallner
<mike@php.net>
Tue, 17 May 2016 07:45:54 +0000
(09:45 +0200)
lib/API/Invoker.php
patch
|
blob
|
history
diff --git
a/lib/API/Invoker.php
b/lib/API/Invoker.php
index ff3a91e04a7fc7c7d977cc3e78a886e161f020ff..e52eedc7a3ec48421779b1427e28f734172bada5 100644
(file)
--- a/
lib/API/Invoker.php
+++ b/
lib/API/Invoker.php
@@
-66,7
+66,7
@@
class Invoker extends Deferred
if ($this->cancelled) {
break;
}
if ($this->cancelled) {
break;
}
- $this->
queu
e($promise, $gen);
+ $this->
giv
e($promise, $gen);
}
if (!$this->cancelled) {
}
if (!$this->cancelled) {
@@
-87,24
+87,20
@@
class Invoker extends Deferred
/**
* Promise handler
*
/**
* Promise handler
*
- * @param \React\Promise\PromiseInterface $promise
- * @param \Generator $
to
+ * @param
array|
\React\Promise\PromiseInterface $promise
+ * @param \Generator $
gen
*/
*/
- private function give(PromiseInterface $promise, Generator $to) {
- $promise->then(function($result) use($to) {
- if (($promise = $to->send($result))) {
- $this->queue($promise, $to);
- }
- });
- }
-
- private function queue($promise, Generator $gen) {
+ private function give($promise, Generator $gen) {
if ($promise instanceof PromiseInterface) {
if ($promise instanceof PromiseInterface) {
- $this->give($promise, $gen);
+ $promise->then(function($result) use($gen) {
+ if (($promise = $gen->send($result))) {
+ $this->give($promise, $gen);
+ }
+ });
} else {
all($promise)->then(function($results) use($gen) {
if (($promise = $gen->send($results))) {
} else {
all($promise)->then(function($results) use($gen) {
if (($promise = $gen->send($results))) {
- $this->
queu
e($promise, $gen);
+ $this->
giv
e($promise, $gen);
}
});
}
}
});
}