Kraken\Promise\Helper\CancellationQueue::enqueue PHP Method

enqueue() public method

public enqueue ( mixed $cancellable )
$cancellable mixed
    public function enqueue($cancellable)
    {
        if ($cancellable instanceof PromiseInterface === false) {
            return;
        }
        $length = array_push($this->queue, $cancellable);
        if ($this->started && 1 === $length) {
            $this->drain();
        }
    }

Usage Example

 /**
  *
  */
 public function testApiInvoke_ThrowsExceptionsFromCancel()
 {
     $this->setExpectedException(Exception::class, 'test');
     $mock = $this->getMock(PromiseInterface::class);
     $mock->expects($this->once())->method('cancel')->will($this->throwException(new Exception('test')));
     $cancellationQueue = new CancellationQueue();
     $cancellationQueue->enqueue($mock);
     $cancellationQueue();
 }
All Usage Examples Of Kraken\Promise\Helper\CancellationQueue::enqueue