public function __construct($config, $limit)
{
$config->ready = function ($conn) {
$this->ready($conn);
};
/* @TODO ... pending queries ... */
$config->restore = function ($conn, $init) {
$this->unmapConnection($conn);
if ($init && empty($this->connections)) {
$this->virtualConnection->fail(new \Exception("Connection failed"));
}
return $this->getReadyConnection();
};
$config->busy = function ($conn) {
if (isset($this->readyMap[$hash = spl_object_hash($conn)])) {
unset($this->ready[$this->readyMap[$hash]]);
}
};
$this->config = $config;
$this->limit = $limit;
$this->virtualConnection = new VirtualConnection();
$this->addConnection();
}