GuzzleHttpPromiseTaskQueue

A task queue that executes tasks in a FIFO order.

Defined (1)

The class is defined in the following location(s).

/lib/Azure/GuzzleHttp/Promise/TaskQueue.php  
  1. class TaskQueue implements TaskQueueInterface 
  2. private $enableShutdown = true; 
  3. private $queue = []; 
  4.  
  5. public function __construct($withShutdown = true) 
  6. if ($withShutdown) { 
  7. register_shutdown_function(function () { 
  8. if ($this->enableShutdown) { 
  9. // Only run the tasks if an E_ERROR didn't occur. 
  10. $err = error_get_last(); 
  11. if (!$err || ($err['type'] ^ E_ERROR)) { 
  12. $this->run(); 
  13. }); 
  14.  
  15. public function isEmpty() 
  16. return !$this->queue; 
  17.  
  18. public function add(callable $task) 
  19. $this->queue[] = $task; 
  20.  
  21. public function run() 
  22. /** @var callable $task */ 
  23. while ($task = array_shift($this->queue)) { 
  24. $task(); 
  25.  
  26. /** 
  27. * The task queue will be run and exhausted by default when the process 
  28. * exits IFF the exit is not the result of a PHP E_ERROR error. 
  29. * You can disable running the automatic shutdown of the queue by calling 
  30. * this function. If you disable the task queue shutdown process, then you 
  31. * MUST either run the task queue (as a result of running your event loop 
  32. * or manually using the run() method) or wait on each outstanding promise. 
  33. * Note: This shutdown will occur before any destructors are triggered. 
  34. */ 
  35. public function disableShutdown() 
  36. $this->enableShutdown = false;