/** * Write specified $dataToWrite to the $socket destination stream * * @param \Alert\Reactor $reactor * @param resource $socket * @param string $dataToWrite * @return \After\Promise */ public function write(Reactor $reactor, $socket, $dataToWrite) { $this->reactor = $reactor; $this->future = new Future(); $this->socket = $socket; $this->buffer = $dataToWrite; $reactor->immediately(function () { $this->doWrite(); }); return $this->future->promise(); }
/** * Schedule a callback to be invoked on the next tick of the event loop. * * Callbacks are guaranteed to be executed in the order they are enqueued, * before any timer or stream events. * * @param callable $listener The callback to invoke. */ public function nextTick(callable $listener) { $this->reactor->immediately(function () use($listener) { call_user_func($listener, $this); }); }