21 declare(strict_types=1);
38 private static $nextSlaveNumber = 0;
40 private $running =
true;
49 $this->slaveNumber = self::$nextSlaveNumber++;
57 $cl = Server::getInstance()->getPluginManager()->getPlugin(
"DEVirion")->getVirionClassLoader();
58 $this->setClassLoader($cl);
63 public function run() : void{
64 $this->registerClassLoader();
67 $this->connError = $error;
73 while($this->running){
74 while($this->bufferSend->fetchQuery($queryId, $mode, $query, $params)){
75 $this->working =
true;
77 $result = $this->
executeQuery($resource, $mode, $query, $params);
78 $this->bufferRecv->publishResult($queryId, $result);
80 $this->bufferRecv->publishError($queryId, $error);
83 $this->working =
false;
86 $this->
close($resource);
99 $this->running =
false;
106 public function addQuery(
int $queryId,
int $mode,
string $query, array $params) : void{
107 $this->bufferSend->scheduleQuery($queryId, $mode, $query, $params);
111 while($this->bufferRecv->fetchResult($queryId, $result)){
112 if(!isset($callbacks[$queryId])){
116 $callbacks[$queryId]($result);
117 unset($callbacks[$queryId]);
126 return $this->connError !== null;
133 protected abstract function createConn(&$resource) : ?string;
144 protected abstract function executeQuery($resource,
int $mode,
string $query, array $params) :
SqlResult;
146 protected abstract function close(&$resource) : void;
addQuery(int $queryId, int $mode, string $query, array $params)
executeQuery($resource, int $mode, string $query, array $params)
readResults(array &$callbacks)