function EventLoop::onWritable
Execute a callback when a stream resource becomes writable or is closed for writing.
Warning: Closing resources locally, e.g. with `fclose`, might not invoke the callback. Be sure to `cancel` the callback when closing the resource locally. Drivers MAY choose to notify the user if there are callbacks on invalid resources, but are not required to, due to the high performance impact. Callbacks on closed resources are therefore undefined behavior.
Multiple callbacks on the same stream MAY be executed in any order.
The created callback MUST immediately be marked as enabled, but only be activated (i.e. callback can be called) right before the next tick. Callbacks MUST NOT be called in the tick they were enabled.
Parameters
resource $stream The stream to monitor.:
\Closure(string, resource):void $closure The callback to execute.:
Return value
string A unique identifier that can be used to cancel, enable or disable the callback.
File
-
vendor/
revolt/ event-loop/ src/ EventLoop.php, line 187
Class
- EventLoop
- Accessor to allow global access to the event loop.
Namespace
RevoltCode
public static function onWritable(mixed $stream, \Closure $closure) : string {
return self::getDriver()->onWritable($stream, $closure);
}