Esempio n. 1
0
 /**
  * For each async tasks scheduled, execute its tick function synchronously.
  * Executing the tick function on an Async will unschedule it if the Async completes.
  * Do not use with declare(ticks=...) and register_tick_function
  * as that feature is deprecated as of PHP 5.3.0.
  * Instead, consider making a call for each event loop at the top level in your script.
  * @return true|false True if there are currently scheduled Asyncs
  */
 public static function tickAll()
 {
     //tickables() are allowed to register new tickables
     //Make sure that these are not lost.
     $snapshotOfAsyncs = self::$asyncs;
     self::$asyncs = Iterators::toList([]);
     self::$asyncs = (new \Yasca\Core\IteratorBuilder())->from($snapshotOfAsyncs)->where(static function ($async) {
         return $async->tick() === false;
     })->toFunctionPipe()->pipe([Iterators::_class, 'toList'])->toIteratorBuilder()->concat(self::$asyncs)->toList();
     return self::$asyncs->isEmpty() === false;
 }
	public function toList(){
		return Iterators::toList($this->iterator);
	}