/** * Create a new loop backed by an event base. * * @param LoopConfig $config * @param \EventBase $loop Event base instance to be used, will create a new instance by default. */ public function __construct(LoopConfig $config = null, \EventBase $loop = null) { parent::__construct($config); $this->loop = $loop ?? new \EventBase(); $this->delayCallback = function ($stream, $what, Watcher $watcher) { $this->info[Watcher::TYPE_DELAY]--; unset($this->watchers[$watcher->id], $this->enable[$watcher->id]); if ($watcher->referenced) { $this->watchersReferenced--; } try { $watcher->event->del(); $watcher->event->free(); } finally { $watcher->event = null; } ($watcher->callback)($watcher->id, $watcher->data); }; $this->repeatCallback = function ($stream, $what, Watcher $watcher) { ($watcher->callback)($watcher->id, $watcher->data); }; $this->streamCallback = function ($stream, $what, Watcher $watcher) { ($watcher->callback)($watcher->id, $stream, $watcher->data); }; $this->signalCallback = function ($signo, $what, Watcher $watcher) { ($watcher->callback)($watcher->id, $signo, $watcher->data); }; }
/** * Create a new native loop. * * @param LoopConfig $config */ public function __construct(LoopConfig $config = null) { static $signalsAvailable; parent::__construct($config); $this->scheduler = new \SplPriorityQueue(); static::$signalsEnabled = $signalsAvailable === null ? $signalsAvailable = \function_exists('pcntl_signal') : $signalsAvailable; }
/** * Create a new event loop using ev. * * @param LoopConfig $config * @param \EvLoop $loop Ev loop instance to be used, will create a new loop instance by default. */ public function __construct(LoopConfig $config = null, \EvLoop $loop = null) { parent::__construct($config); $this->loop = $loop ?? new \EvLoop(); $this->delayCallback = function (\EVTimer $event) { $this->info[Watcher::TYPE_DELAY]--; unset($this->watchers[$event->data->id], $this->enable[$event->data->id]); if ($event->data->referenced) { $this->watchersReferenced--; } $event->data->event = null; $event->stop(); ($event->data->callback)($event->data->id, $event->data->data); }; $this->repeatCallback = function (\EvTimer $event) { ($event->data->callback)($event->data->id, $event->data->data); }; $this->streamCallback = function (\EvIO $event) { ($event->data->callback)($event->data->id, $event->data->stream, $event->data->data); }; $this->signalCallback = function (\EvSignal $event) { ($event->data->callback)($event->data->id, $event->data->signo, $event->data->data); }; }
/** * Set up the default arguments for WP_Query. * * Pass in an array to override or extend the default arguments. * For example, pass an array to $override: * ``` * [ * 'post_status' => array( 'publish' ), * 'posts_per_page' => '-1', * 'order' => 'ASC', * 'orderby' => 'menu_order', * ] * ``` * * @since 1.0.0 * @param array $override Array of WP_Query arguments */ public function __construct($override = [], $term = null) { parent::__construct(); $this->args = array_merge($this->args, array_merge(['post_type' => array('service')], $override)); }