projects
/
m6w6
/
pq-gateway
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
flush
[m6w6/pq-gateway]
/
lib
/
pq
/
Query
/
AsyncExecutor.php
diff --git
a/lib/pq/Query/AsyncExecutor.php
b/lib/pq/Query/AsyncExecutor.php
index e7c1c35998f1847a4b544ac0ece47337fc1418bc..a309ce62799cf535810870868b1dc38d10459834 100644
(file)
--- a/
lib/pq/Query/AsyncExecutor.php
+++ b/
lib/pq/Query/AsyncExecutor.php
@@
-1,6
+1,6
@@
<?php
<?php
-namespace pq\Query
\Executor
;
+namespace pq\Query;
use \pq\Query\Executor;
use \pq\Query\WriterInterface;
use \pq\Query\Executor;
use \pq\Query\WriterInterface;
@@
-54,8
+54,8
@@
class AsyncExecutor extends Executor
*
* Example with amphp:
* <code>
*
* Example with amphp:
* <code>
- * use
a
mp\Future;
- * use function
a
mp\reactor;
+ * use
A
mp\Future;
+ * use function
A
mp\reactor;
*
* $exec = new pq\Query\AsyncExecutor(new pq\Connection);
* $exec->setCallbacks(
*
* $exec = new pq\Query\AsyncExecutor(new pq\Connection);
* $exec->setCallbacks(
@@
-69,7
+69,7
@@
class AsyncExecutor extends Executor
* },
* # then
* function(Future $context, callable $cb) {
* },
* # then
* function(Future $context, callable $cb) {
- * return $context->when(function ($error, $result) {
+ * return $context->when(function ($error, $result)
use ($cb)
{
* $cb($result);
* });
* });
* $cb($result);
* });
* });
@@
-99,29
+99,19
@@
class AsyncExecutor extends Executor
* @param callable $callback
* @return array($context, $resolver)
*/
* @param callable $callback
* @return array($context, $resolver)
*/
- protected function prepareCallback(callable $callback/*, ... */) {
+ protected function prepareCallback
s
(callable $callback/*, ... */) {
list($init, $done, $then) = $this->getCallbacks();
$context = $init();
foreach (func_get_args() as $cb) {
$then($context, $cb);
}
list($init, $done, $then) = $this->getCallbacks();
$context = $init();
foreach (func_get_args() as $cb) {
$then($context, $cb);
}
- $then($context, $callback);
return array($context, function($result) use ($context, $done) {
$done($context, $result);
});
}
return array($context, function($result) use ($context, $done) {
$done($context, $result);
});
}
- /**
- * Result callback
- * @param \pq\Result $result
- */
- protected function receiveResult(\pq\Result $result) {
- $this->result = $result;
- $this->notify();
- }
-
/**
* Execute the query asynchronously through \pq\Connection::execParamsAsync()
* @param \pq\Query\WriterInterface $query
/**
* Execute the query asynchronously through \pq\Connection::execParamsAsync()
* @param \pq\Query\WriterInterface $query
@@
-133,8
+123,11
@@
class AsyncExecutor extends Executor
$this->query = $query;
$this->notify();
$this->query = $query;
$this->notify();
- list($context, $resolver) = $this->prepareCallback(
- array($this, "receiveResult"), $callback);
+ list($context, $resolver) = $this->prepareCallbacks(
+ function(\pq\Result $result) {
+ $this->result = $result;
+ $this->notify();
+ }, $callback);
$this->getConnection()->execParamsAsync($query, $query->getParams(),
$query->getTypes(), $resolver);
return $context;
$this->getConnection()->execParamsAsync($query, $query->getParams(),
$query->getTypes(), $resolver);
return $context;