2016-01-20 12:01:40 +01:00
|
|
|
<?php
|
|
|
|
|
2017-03-10 19:19:32 +01:00
|
|
|
namespace Amp\Loop;
|
|
|
|
|
2020-11-01 16:43:21 +01:00
|
|
|
interface Driver extends \FiberScheduler
|
2018-06-18 20:00:01 +02:00
|
|
|
{
|
2017-03-10 21:58:46 +01:00
|
|
|
/**
|
2020-10-03 05:26:10 +02:00
|
|
|
* Run the event loop.
|
2020-03-28 12:23:46 +01:00
|
|
|
*
|
2020-10-03 05:26:10 +02:00
|
|
|
* One iteration of the loop is called one "tick". A tick covers the following steps:
|
|
|
|
*
|
|
|
|
* 1. Activate watchers created / enabled in the last tick / before `run()`.
|
|
|
|
* 2. Execute all enabled defer watchers.
|
|
|
|
* 3. Execute all due timer, pending signal and actionable stream callbacks, each only once per tick.
|
|
|
|
*
|
|
|
|
* The loop MUST continue to run until it is either stopped explicitly, no referenced watchers exist anymore, or an
|
|
|
|
* exception is thrown that cannot be handled. Exceptions that cannot be handled are exceptions thrown from an
|
|
|
|
* error handler or exceptions that would be passed to an error handler but none exists to handle them.
|
|
|
|
*
|
|
|
|
* @return void
|
2017-03-10 21:58:46 +01:00
|
|
|
*/
|
2020-11-01 16:43:21 +01:00
|
|
|
public function run(): void;
|
2017-03-14 06:20:05 +01:00
|
|
|
|
2020-10-03 05:26:10 +02:00
|
|
|
/**
|
|
|
|
* Stop the event loop.
|
|
|
|
*
|
|
|
|
* When an event loop is stopped, it continues with its current tick and exits the loop afterwards. Multiple calls
|
|
|
|
* to stop MUST be ignored and MUST NOT raise an exception.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2020-11-01 16:43:21 +01:00
|
|
|
public function stop(): void;
|
2017-03-10 21:58:46 +01:00
|
|
|
|
2016-02-17 16:25:39 +01:00
|
|
|
/**
|
2020-09-26 19:34:39 +02:00
|
|
|
* @return bool True if the event loop is running, false if it is stopped.
|
2016-02-17 16:25:39 +01:00
|
|
|
*/
|
2020-11-01 16:43:21 +01:00
|
|
|
public function isRunning(): bool;
|
2016-02-17 16:25:39 +01:00
|
|
|
|
|
|
|
/**
|
2016-03-14 11:56:31 +01:00
|
|
|
* Defer the execution of a callback.
|
2016-05-12 17:57:02 +02:00
|
|
|
*
|
2017-02-09 15:47:44 +01:00
|
|
|
* The deferred callable MUST be executed before any other type of watcher in a tick. Order of enabling MUST be
|
|
|
|
* preserved when executing the callbacks.
|
|
|
|
*
|
|
|
|
* The created watcher MUST immediately be marked as enabled, but only be activated (i.e. callback can be called)
|
|
|
|
* right before the next tick. Callbacks of watchers MUST NOT be called in the tick they were enabled.
|
2016-05-20 12:49:31 +02:00
|
|
|
*
|
2020-03-28 12:23:46 +01:00
|
|
|
* @param callable (string $watcherId, mixed $data) $callback The callback to defer. The `$watcherId` will be
|
2020-11-01 16:43:21 +01:00
|
|
|
* invalidated before the callback call.
|
2016-09-25 13:22:01 +02:00
|
|
|
* @param mixed $data Arbitrary data given to the callback function as the `$data` parameter.
|
2016-05-12 17:57:02 +02:00
|
|
|
*
|
2016-05-28 15:57:07 +02:00
|
|
|
* @return string An unique identifier that can be used to cancel, enable or disable the watcher.
|
2016-02-17 16:25:39 +01:00
|
|
|
*/
|
2020-11-01 16:43:21 +01:00
|
|
|
public function defer(callable $callback, $data = null): string;
|
2016-02-17 16:25:39 +01:00
|
|
|
|
|
|
|
/**
|
2016-05-20 12:49:31 +02:00
|
|
|
* Delay the execution of a callback.
|
|
|
|
*
|
2016-06-26 16:15:01 +02:00
|
|
|
* The delay is a minimum and approximate, accuracy is not guaranteed. Order of calls MUST be determined by which
|
2016-09-25 13:22:01 +02:00
|
|
|
* timers expire first, but timers with the same expiration time MAY be executed in any order.
|
2016-05-12 17:57:02 +02:00
|
|
|
*
|
2017-02-09 15:47:44 +01:00
|
|
|
* The created watcher MUST immediately be marked as enabled, but only be activated (i.e. callback can be called)
|
|
|
|
* right before the next tick. Callbacks of watchers MUST NOT be called in the tick they were enabled.
|
|
|
|
*
|
2017-03-10 21:58:46 +01:00
|
|
|
* @param int $delay The amount of time, in milliseconds, to delay the execution for.
|
2020-03-28 12:23:46 +01:00
|
|
|
* @param callable (string $watcherId, mixed $data) $callback The callback to delay. The `$watcherId` will be
|
2020-11-01 16:43:21 +01:00
|
|
|
* invalidated before the callback call.
|
|
|
|
* @param mixed $data Arbitrary data given to the callback function as the `$data` parameter.
|
2016-05-12 17:57:02 +02:00
|
|
|
*
|
2016-05-28 15:57:07 +02:00
|
|
|
* @return string An unique identifier that can be used to cancel, enable or disable the watcher.
|
2016-02-17 16:25:39 +01:00
|
|
|
*/
|
2020-11-01 16:43:21 +01:00
|
|
|
public function delay(int $delay, callable $callback, $data = null): string;
|
2016-02-17 16:25:39 +01:00
|
|
|
|
|
|
|
/**
|
2016-05-20 12:49:31 +02:00
|
|
|
* Repeatedly execute a callback.
|
|
|
|
*
|
2016-06-26 16:15:01 +02:00
|
|
|
* The interval between executions is a minimum and approximate, accuracy is not guaranteed. Order of calls MUST be
|
2016-10-25 17:29:09 +02:00
|
|
|
* determined by which timers expire first, but timers with the same expiration time MAY be executed in any order.
|
2016-05-23 20:29:10 +02:00
|
|
|
* The first execution is scheduled after the first interval period.
|
2016-05-12 17:57:02 +02:00
|
|
|
*
|
2017-02-09 15:47:44 +01:00
|
|
|
* The created watcher MUST immediately be marked as enabled, but only be activated (i.e. callback can be called)
|
|
|
|
* right before the next tick. Callbacks of watchers MUST NOT be called in the tick they were enabled.
|
|
|
|
*
|
2017-03-10 21:58:46 +01:00
|
|
|
* @param int $interval The time interval, in milliseconds, to wait between executions.
|
2020-03-28 12:23:46 +01:00
|
|
|
* @param callable (string $watcherId, mixed $data) $callback The callback to repeat.
|
2020-11-01 16:43:21 +01:00
|
|
|
* @param mixed $data Arbitrary data given to the callback function as the `$data` parameter.
|
2016-05-12 17:57:02 +02:00
|
|
|
*
|
2016-05-28 15:57:07 +02:00
|
|
|
* @return string An unique identifier that can be used to cancel, enable or disable the watcher.
|
2016-02-17 16:25:39 +01:00
|
|
|
*/
|
2020-11-01 16:43:21 +01:00
|
|
|
public function repeat(int $interval, callable $callback, $data = null): string;
|
2016-02-17 16:25:39 +01:00
|
|
|
|
|
|
|
/**
|
2016-09-23 16:02:23 +02:00
|
|
|
* Execute a callback when a stream resource becomes readable or is closed for reading.
|
2016-05-12 17:57:02 +02:00
|
|
|
*
|
2016-10-24 17:08:53 +02:00
|
|
|
* Warning: Closing resources locally, e.g. with `fclose`, might not invoke the callback. Be sure to `cancel` the
|
2016-10-25 17:29:09 +02:00
|
|
|
* watcher when closing the resource locally. Drivers MAY choose to notify the user if there are watchers on invalid
|
2016-10-24 17:21:12 +02:00
|
|
|
* resources, but are not required to, due to the high performance impact. Watchers on closed resources are
|
|
|
|
* therefore undefined behavior.
|
2016-10-24 17:08:53 +02:00
|
|
|
*
|
2016-10-25 17:29:09 +02:00
|
|
|
* Multiple watchers on the same stream MAY be executed in any order.
|
2016-06-04 18:27:30 +02:00
|
|
|
*
|
2017-02-09 15:47:44 +01:00
|
|
|
* The created watcher MUST immediately be marked as enabled, but only be activated (i.e. callback can be called)
|
|
|
|
* right before the next tick. Callbacks of watchers MUST NOT be called in the tick they were enabled.
|
|
|
|
*
|
2016-03-14 11:56:31 +01:00
|
|
|
* @param resource $stream The stream to monitor.
|
2020-03-28 12:23:46 +01:00
|
|
|
* @param callable (string $watcherId, resource $stream, mixed $data) $callback The callback to execute.
|
2020-11-01 16:43:21 +01:00
|
|
|
* @param mixed $data Arbitrary data given to the callback function as the `$data` parameter.
|
2016-05-12 17:57:02 +02:00
|
|
|
*
|
2016-05-28 15:57:07 +02:00
|
|
|
* @return string An unique identifier that can be used to cancel, enable or disable the watcher.
|
2016-02-17 16:25:39 +01:00
|
|
|
*/
|
2020-11-01 16:43:21 +01:00
|
|
|
public function onReadable($stream, callable $callback, $data = null): string;
|
2016-02-17 16:25:39 +01:00
|
|
|
|
|
|
|
/**
|
2016-09-23 16:02:23 +02:00
|
|
|
* Execute a callback when a stream resource becomes writable or is closed for writing.
|
2016-05-12 17:57:02 +02:00
|
|
|
*
|
2016-10-24 17:08:53 +02:00
|
|
|
* Warning: Closing resources locally, e.g. with `fclose`, might not invoke the callback. Be sure to `cancel` the
|
2016-10-25 17:29:09 +02:00
|
|
|
* watcher when closing the resource locally. Drivers MAY choose to notify the user if there are watchers on invalid
|
2016-10-24 17:21:12 +02:00
|
|
|
* resources, but are not required to, due to the high performance impact. Watchers on closed resources are
|
|
|
|
* therefore undefined behavior.
|
2016-10-24 17:08:53 +02:00
|
|
|
*
|
2016-10-25 17:29:09 +02:00
|
|
|
* Multiple watchers on the same stream MAY be executed in any order.
|
2016-06-04 18:27:30 +02:00
|
|
|
*
|
2017-02-09 15:47:44 +01:00
|
|
|
* The created watcher MUST immediately be marked as enabled, but only be activated (i.e. callback can be called)
|
|
|
|
* right before the next tick. Callbacks of watchers MUST NOT be called in the tick they were enabled.
|
|
|
|
*
|
2016-03-14 11:56:31 +01:00
|
|
|
* @param resource $stream The stream to monitor.
|
2020-03-28 12:23:46 +01:00
|
|
|
* @param callable (string $watcherId, resource $stream, mixed $data) $callback The callback to execute.
|
2020-11-01 16:43:21 +01:00
|
|
|
* @param mixed $data Arbitrary data given to the callback function as the `$data` parameter.
|
2016-05-12 17:57:02 +02:00
|
|
|
*
|
2016-05-28 15:57:07 +02:00
|
|
|
* @return string An unique identifier that can be used to cancel, enable or disable the watcher.
|
2016-02-17 16:25:39 +01:00
|
|
|
*/
|
2020-11-01 16:43:21 +01:00
|
|
|
public function onWritable($stream, callable $callback, $data = null): string;
|
2016-02-17 16:25:39 +01:00
|
|
|
|
|
|
|
/**
|
2016-03-14 11:56:31 +01:00
|
|
|
* Execute a callback when a signal is received.
|
2016-05-12 17:57:02 +02:00
|
|
|
*
|
2016-10-24 17:08:53 +02:00
|
|
|
* Warning: Installing the same signal on different instances of this interface is deemed undefined behavior.
|
2016-10-25 17:29:09 +02:00
|
|
|
* Implementations MAY try to detect this, if possible, but are not required to. This is due to technical
|
2016-09-04 22:45:37 +02:00
|
|
|
* limitations of the signals being registered globally per process.
|
2016-07-19 18:10:51 +02:00
|
|
|
*
|
2016-10-25 17:29:09 +02:00
|
|
|
* Multiple watchers on the same signal MAY be executed in any order.
|
2016-10-24 17:08:53 +02:00
|
|
|
*
|
2017-02-09 15:47:44 +01:00
|
|
|
* The created watcher MUST immediately be marked as enabled, but only be activated (i.e. callback can be called)
|
|
|
|
* right before the next tick. Callbacks of watchers MUST NOT be called in the tick they were enabled.
|
|
|
|
*
|
2017-03-10 21:58:46 +01:00
|
|
|
* @param int $signo The signal number to monitor.
|
2020-03-28 12:23:46 +01:00
|
|
|
* @param callable (string $watcherId, int $signo, mixed $data) $callback The callback to execute.
|
2020-11-01 16:43:21 +01:00
|
|
|
* @param mixed $data Arbitrary data given to the callback function as the $data parameter.
|
2016-05-12 17:57:02 +02:00
|
|
|
*
|
2016-05-28 15:57:07 +02:00
|
|
|
* @return string An unique identifier that can be used to cancel, enable or disable the watcher.
|
2016-05-26 17:43:03 +02:00
|
|
|
*
|
2016-07-15 22:17:24 +02:00
|
|
|
* @throws UnsupportedFeatureException If signal handling is not supported.
|
2016-02-17 16:25:39 +01:00
|
|
|
*/
|
2020-11-01 16:43:21 +01:00
|
|
|
public function onSignal(int $signo, callable $callback, $data = null): string;
|
2016-02-17 16:25:39 +01:00
|
|
|
|
|
|
|
/**
|
2017-02-09 15:47:44 +01:00
|
|
|
* Enable a watcher to be active starting in the next tick.
|
2016-07-15 22:17:24 +02:00
|
|
|
*
|
2017-02-09 09:50:23 +01:00
|
|
|
* Watchers MUST immediately be marked as enabled, but only be activated (i.e. callbacks can be called) right before
|
|
|
|
* the next tick. Callbacks of watchers MUST NOT be called in the tick they were enabled.
|
2016-05-12 17:57:02 +02:00
|
|
|
*
|
2016-05-19 17:21:26 +02:00
|
|
|
* @param string $watcherId The watcher identifier.
|
2016-05-12 17:57:02 +02:00
|
|
|
*
|
2016-03-01 01:52:59 +01:00
|
|
|
* @return void
|
2016-05-28 15:57:07 +02:00
|
|
|
*
|
2017-03-14 17:48:27 +01:00
|
|
|
* @throws InvalidWatcherError If the watcher identifier is invalid.
|
2016-02-17 16:25:39 +01:00
|
|
|
*/
|
2020-11-01 16:43:21 +01:00
|
|
|
public function enable(string $watcherId): void;
|
2016-03-01 01:52:59 +01:00
|
|
|
|
2017-03-10 21:58:46 +01:00
|
|
|
/**
|
|
|
|
* Cancel a watcher.
|
|
|
|
*
|
2020-03-28 12:23:46 +01:00
|
|
|
* This will detach the event loop from all resources that are associated to the watcher. After this operation the
|
2017-03-10 21:58:46 +01:00
|
|
|
* watcher is permanently invalid. Calling this function MUST NOT fail, even if passed an invalid watcher.
|
|
|
|
*
|
|
|
|
* @param string $watcherId The watcher identifier.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2020-11-01 16:43:21 +01:00
|
|
|
public function cancel(string $watcherId): void;
|
2017-03-10 21:58:46 +01:00
|
|
|
|
2016-03-01 01:52:59 +01:00
|
|
|
/**
|
2017-02-09 15:47:44 +01:00
|
|
|
* Disable a watcher immediately.
|
|
|
|
*
|
|
|
|
* A watcher MUST be disabled immediately, e.g. if a defer watcher disables a later defer watcher, the second defer
|
|
|
|
* watcher isn't executed in this tick.
|
2016-09-25 13:22:01 +02:00
|
|
|
*
|
|
|
|
* Disabling a watcher MUST NOT invalidate the watcher. Calling this function MUST NOT fail, even if passed an
|
|
|
|
* invalid watcher.
|
2016-05-12 17:57:02 +02:00
|
|
|
*
|
2016-05-19 17:21:26 +02:00
|
|
|
* @param string $watcherId The watcher identifier.
|
2016-05-12 17:57:02 +02:00
|
|
|
*
|
2016-03-01 01:52:59 +01:00
|
|
|
* @return void
|
|
|
|
*/
|
2020-11-01 16:43:21 +01:00
|
|
|
public function disable(string $watcherId): void;
|
2016-03-01 01:52:59 +01:00
|
|
|
|
2016-03-23 10:47:18 +01:00
|
|
|
/**
|
2016-05-15 00:19:05 +02:00
|
|
|
* Reference a watcher.
|
2016-05-12 17:57:02 +02:00
|
|
|
*
|
2016-05-20 12:49:31 +02:00
|
|
|
* This will keep the event loop alive whilst the watcher is still being monitored. Watchers have this state by
|
|
|
|
* default.
|
2016-05-12 17:57:02 +02:00
|
|
|
*
|
2016-05-19 17:21:26 +02:00
|
|
|
* @param string $watcherId The watcher identifier.
|
2016-05-12 17:57:02 +02:00
|
|
|
*
|
2016-03-23 10:47:18 +01:00
|
|
|
* @return void
|
2016-05-28 15:57:07 +02:00
|
|
|
*
|
2017-03-14 17:48:27 +01:00
|
|
|
* @throws InvalidWatcherError If the watcher identifier is invalid.
|
2016-03-23 10:47:18 +01:00
|
|
|
*/
|
2020-11-01 16:43:21 +01:00
|
|
|
public function reference(string $watcherId): void;
|
2016-03-23 10:47:18 +01:00
|
|
|
|
|
|
|
/**
|
2016-05-15 00:19:05 +02:00
|
|
|
* Unreference a watcher.
|
2016-05-12 17:57:02 +02:00
|
|
|
*
|
2016-05-20 12:49:31 +02:00
|
|
|
* The event loop should exit the run method when only unreferenced watchers are still being monitored. Watchers
|
|
|
|
* are all referenced by default.
|
2016-05-12 17:57:02 +02:00
|
|
|
*
|
2016-05-19 17:21:26 +02:00
|
|
|
* @param string $watcherId The watcher identifier.
|
2016-05-12 17:57:02 +02:00
|
|
|
*
|
2016-03-23 10:47:18 +01:00
|
|
|
* @return void
|
|
|
|
*/
|
2020-11-01 16:43:21 +01:00
|
|
|
public function unreference(string $watcherId): void;
|
2016-07-15 22:17:24 +02:00
|
|
|
|
2016-05-27 17:45:45 +02:00
|
|
|
/**
|
2016-09-25 13:22:01 +02:00
|
|
|
* Stores information in the loop bound registry.
|
2016-05-27 17:45:45 +02:00
|
|
|
*
|
2017-03-18 21:52:23 +01:00
|
|
|
* Stored information is package private. Packages MUST NOT retrieve the stored state of other packages. Packages
|
|
|
|
* MUST use their namespace as prefix for keys. They may do so by using `SomeClass::class` as key.
|
|
|
|
*
|
|
|
|
* If packages want to expose loop bound state to consumers other than the package, they SHOULD provide a dedicated
|
|
|
|
* interface for that purpose instead of sharing the storage key.
|
2016-05-27 17:45:45 +02:00
|
|
|
*
|
2020-11-01 16:43:21 +01:00
|
|
|
* @param string $key The namespaced storage key.
|
2017-03-10 21:58:46 +01:00
|
|
|
* @param mixed $value The value to be stored.
|
2016-05-27 17:45:45 +02:00
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2020-11-01 16:43:21 +01:00
|
|
|
public function setState(string $key, mixed $value): void;
|
2016-05-27 17:45:45 +02:00
|
|
|
|
|
|
|
/**
|
2016-09-25 13:22:01 +02:00
|
|
|
* Gets information stored bound to the loop.
|
2016-05-27 17:45:45 +02:00
|
|
|
*
|
2016-09-25 13:22:01 +02:00
|
|
|
* Stored information is package private. Packages MUST NOT retrieve the stored state of other packages. Packages
|
2017-03-18 21:52:23 +01:00
|
|
|
* MUST use their namespace as prefix for keys. They may do so by using `SomeClass::class` as key.
|
|
|
|
*
|
|
|
|
* If packages want to expose loop bound state to consumers other than the package, they SHOULD provide a dedicated
|
|
|
|
* interface for that purpose instead of sharing the storage key.
|
2016-05-27 17:45:45 +02:00
|
|
|
*
|
2016-09-04 22:45:37 +02:00
|
|
|
* @param string $key The namespaced storage key.
|
2016-05-27 17:45:45 +02:00
|
|
|
*
|
2016-09-25 13:22:01 +02:00
|
|
|
* @return mixed The previously stored value or `null` if it doesn't exist.
|
2016-05-27 17:45:45 +02:00
|
|
|
*/
|
2020-11-01 16:43:21 +01:00
|
|
|
public function getState(string $key): mixed;
|
2016-05-13 23:41:54 +02:00
|
|
|
|
2016-05-18 13:12:42 +02:00
|
|
|
/**
|
|
|
|
* Set a callback to be executed when an error occurs.
|
|
|
|
*
|
2016-10-24 20:43:21 +02:00
|
|
|
* The callback receives the error as the first and only parameter. The return value of the callback gets ignored.
|
|
|
|
* If it can't handle the error, it MUST throw the error. Errors thrown by the callback or during its invocation
|
|
|
|
* MUST be thrown into the `run` loop and stop the driver.
|
|
|
|
*
|
2016-05-18 13:12:42 +02:00
|
|
|
* Subsequent calls to this method will overwrite the previous handler.
|
|
|
|
*
|
2020-03-28 12:23:46 +01:00
|
|
|
* @param callable(\Throwable $error):void|null $callback The callback to execute. `null` will clear the
|
2016-09-25 13:22:01 +02:00
|
|
|
* current handler.
|
2016-05-18 13:12:42 +02:00
|
|
|
*
|
2020-03-28 12:23:46 +01:00
|
|
|
* @return callable(\Throwable $error):void|null The previous handler, `null` if there was none.
|
2016-05-18 13:12:42 +02:00
|
|
|
*/
|
2020-11-01 16:43:21 +01:00
|
|
|
public function setErrorHandler(callable $callback = null): ?callable;
|
2016-05-18 13:12:42 +02:00
|
|
|
|
2018-01-06 03:32:57 +01:00
|
|
|
/**
|
|
|
|
* Returns the current loop time in millisecond increments. Note this value does not necessarily correlate to
|
|
|
|
* wall-clock time, rather the value returned is meant to be used in relative comparisons to prior values returned
|
|
|
|
* by this method (intervals, expiration calculations, etc.) and is only updated once per loop tick.
|
|
|
|
*
|
|
|
|
* Extending classes should override this function to return a value cached once per loop tick.
|
|
|
|
*
|
|
|
|
* @return int
|
|
|
|
*/
|
2020-11-01 16:43:21 +01:00
|
|
|
public function now(): int;
|
2018-01-06 03:32:57 +01:00
|
|
|
|
2017-03-10 21:58:46 +01:00
|
|
|
/**
|
|
|
|
* Get the underlying loop handle.
|
|
|
|
*
|
|
|
|
* Example: the `uv_loop` resource for `libuv` or the `EvLoop` object for `libev` or `null` for a native driver.
|
|
|
|
*
|
|
|
|
* Note: This function is *not* exposed in the `Loop` class. Users shall access it directly on the respective loop
|
|
|
|
* instance.
|
|
|
|
*
|
|
|
|
* @return null|object|resource The loop handle the event loop operates on. `null` if there is none.
|
|
|
|
*/
|
2020-11-01 16:43:21 +01:00
|
|
|
public function getHandle();
|
2017-03-10 21:58:46 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the same array of data as getInfo().
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
2020-11-01 16:43:21 +01:00
|
|
|
public function __debugInfo(): array;
|
2017-03-10 21:58:46 +01:00
|
|
|
|
2016-05-21 11:00:01 +02:00
|
|
|
/**
|
|
|
|
* Retrieve an associative array of information about the event loop driver.
|
|
|
|
*
|
2016-07-15 22:17:24 +02:00
|
|
|
* The returned array MUST contain the following data describing the driver's currently registered watchers:
|
2016-05-21 11:00:01 +02:00
|
|
|
*
|
2016-09-25 13:22:01 +02:00
|
|
|
* [
|
2017-01-08 11:40:11 +01:00
|
|
|
* "defer" => ["enabled" => int, "disabled" => int],
|
|
|
|
* "delay" => ["enabled" => int, "disabled" => int],
|
|
|
|
* "repeat" => ["enabled" => int, "disabled" => int],
|
|
|
|
* "on_readable" => ["enabled" => int, "disabled" => int],
|
|
|
|
* "on_writable" => ["enabled" => int, "disabled" => int],
|
|
|
|
* "on_signal" => ["enabled" => int, "disabled" => int],
|
|
|
|
* "enabled_watchers" => ["referenced" => int, "unreferenced" => int],
|
2016-09-25 13:22:01 +02:00
|
|
|
* ];
|
|
|
|
*
|
|
|
|
* Implementations MAY optionally add more information in the array but at minimum the above `key => value` format
|
2016-07-15 22:17:24 +02:00
|
|
|
* MUST always be provided.
|
2016-05-21 11:00:01 +02:00
|
|
|
*
|
2016-12-23 11:05:37 +01:00
|
|
|
* @return array Statistics about the loop in the described format.
|
2016-05-21 11:00:01 +02:00
|
|
|
*/
|
2020-11-01 16:43:21 +01:00
|
|
|
public function getInfo(): array;
|
2020-04-15 22:46:31 +02:00
|
|
|
|
2020-10-03 15:38:31 +02:00
|
|
|
/**
|
2020-10-08 05:52:23 +02:00
|
|
|
* Removes all watchers, registry data, and error handler from the event loop. This method is intended for
|
|
|
|
* clearing the loop between tests and not intended for use in an application.
|
2020-10-03 15:38:31 +02:00
|
|
|
*/
|
2020-11-01 16:43:21 +01:00
|
|
|
public function clear(): void;
|
2017-04-24 15:39:08 +02:00
|
|
|
}
|