Esempio n. 1
0
 /**
  * Executes/Resumes the task.
  */
 public function run()
 {
     if (!$this->generator) {
         $this->start();
     }
     if ($this->generator) {
         while (!$this->shouldWait() && $this->generator->valid()) {
             $this->resume($this->generator);
             $this->generatorValue = $this->getCurrentValue($this->generator);
         }
     }
     if ($this->shouldWait() && $this->generatorValue->awaitsResource()) {
         $this->loop->addReadStream($this->generatorValue->getResource());
     }
 }
Esempio n. 2
0
 /**
  * Schedules the $callback for asynchronous execution.
  *
  * @param callable $callback
  * @param mixed ...$args Arguments to be supplied to the $callback
  *                       at the time of execution.
  */
 public static function async(callable $callback, ...$args)
 {
     return self::$loop->scheduleTask($callback, ...$args);
 }