Exemplo n.º 1
0
 /**
  * @param string $function
  * @param array $args
  * @param int $errorResultCode
  * @return \React\Promise\PromiseInterface
  */
 public function invokeCall($function, $args, $errorResultCode = -1)
 {
     $this->callQueueActive = true;
     $deferred = new Deferred();
     $this->callQueue->enqueue(new QueuedCall($deferred, $function, $args, $errorResultCode));
     if (!$this->callQueue->isEmpty() && $this->runningOperations < $this->maxSimultaneousOperations) {
         $this->processQueue();
     }
     return $deferred->promise()->then(function ($data) {
         return $this->adapter->callFilesystem($data['function'], $data['args'], $data['errorResultCode'])->then($this->filesystemResultHandler('React\\Promise\\resolve'), $this->filesystemResultHandler('React\\Promise\\reject'));
     });
 }
Exemplo n.º 2
0
 /**
  * @param $sourceStream
  * @return Stream
  */
 protected function processLsRecursiveContents($sourceStream)
 {
     $stream = new ObjectStream();
     $closeCount = 0;
     $sourceStream->on('data', function (NodeInterface $node) use(&$closeCount, $stream) {
         if ($node instanceof Directory || $node instanceof File) {
             $stream->emit('data', [$node]);
         }
         if ($node instanceof Directory) {
             $this->streamLsIntoStream($node, $stream, $closeCount);
         }
     });
     $sourceStream->on('end', function () use(&$closeCount, $stream) {
         $this->adapter->getLoop()->addPeriodicTimer(0.01, function (TimerInterface $timer) use(&$closeCount, $stream) {
             if ($closeCount === 0) {
                 $timer->cancel();
                 $stream->close();
             }
         });
     });
     return $stream;
 }
Exemplo n.º 3
0
 /**
  * @param string $function
  * @param array $args
  * @param int $errorResultCode
  * @return \React\Promise\PromiseInterface
  */
 public function invokeCall($function, $args, $errorResultCode = -1)
 {
     return $this->adapter->callFilesystem($function, $args, $errorResultCode);
 }
Exemplo n.º 4
0
 /**
  * {@inheritDoc}
  */
 public function remove()
 {
     return $this->adapter->unlink($this->path);
 }
Exemplo n.º 5
0
 /**
  * @param CallInvokerInterface $invoker
  */
 public function setInvoker(CallInvokerInterface $invoker)
 {
     $this->adapter->setInvoker($invoker);
 }