Skip to content
This repository has been archived by the owner on Jun 5, 2019. It is now read-only.

Commit

Permalink
Slight refactoring of the pool, currently still a race condition but …
Browse files Browse the repository at this point in the history
…need to write tests to test that before creating anti race condition code
  • Loading branch information
WyriHaximus committed Mar 2, 2016
1 parent 00b2854 commit 548a135
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/Pool.php
Expand Up @@ -33,15 +33,17 @@ class Pool implements PoolUtilizerInterface
protected function __construct(LoopInterface $loop)
{
$this->loop = $loop;
$this->pool = Flexible::create(
Flexible::create(
new Process(
Configure::read('WyriHaximus.React.Cake.Orm.Process')
),
$this->loop,
[
'processOptions' => Configure::read('WyriHaximus.React.Cake.Orm.Line'),
]
);
)->then(function (PoolInterface $pool) {
$this->pool = $pool;
});
}

/**
Expand Down Expand Up @@ -70,13 +72,11 @@ public static function getInstance(LoopInterface $loop = null)
*/
public function call($tableName, $function, array $arguments)
{
return $this->pool->then(function (PoolInterface $pool) use ($tableName, $function, $arguments) {
return $pool->rpc(Factory::rpc('table.call', [
'function' => $function,
'table' => $tableName,
'arguments' => serialize($arguments),
]));
})->then(function ($result) {
return $this->pool->rpc(Factory::rpc('table.call', [
'function' => $function,
'table' => $tableName,
'arguments' => serialize($arguments),
]))->then(function ($result) {
return \React\Promise\resolve($result['result']);
});
}
Expand Down

0 comments on commit 548a135

Please sign in to comment.