Skip to content

Commit ae36a20

Browse files
committed
Add Loop::info, resolves #44
1 parent 8feb808 commit ae36a20

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

src/Loop.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,34 @@ public static function setErrorHandler(callable $callback = null)
274274
self::get()->setErrorHandler($callback);
275275
}
276276

277+
/**
278+
* Retrieve an associative array of information about the event loop driver.
279+
*
280+
* The returned array MUST contain the following data describing the driver's
281+
* currently registered watchers:
282+
*
283+
* [
284+
* "defer" => ["enabled" => int, "disabled" => int],
285+
* "delay" => ["enabled" => int, "disabled" => int],
286+
* "repeat" => ["enabled" => int, "disabled" => int],
287+
* "on_readable" => ["enabled" => int, "disabled" => int],
288+
* "on_writable" => ["enabled" => int, "disabled" => int],
289+
* "on_signal" => ["enabled" => int, "disabled" => int],
290+
* "keep_alive" => int,
291+
* ];
292+
*
293+
* keep_alive refers to the number of referenced watchers.
294+
*
295+
* Implementations MAY optionally add more information in the array but
296+
* at minimum the above key => value format MUST always be provided.
297+
*
298+
* @return array
299+
*/
300+
public function info()
301+
{
302+
self::get()->info();
303+
}
304+
277305
/**
278306
* Disable construction as this is a static class.
279307
*/

src/LoopDriver.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,31 @@ public function unreference($watcherId);
144144
*/
145145
public function setErrorHandler(callable $callback = null);
146146

147+
/**
148+
* Retrieve an associative array of information about the event loop driver.
149+
*
150+
* The returned array MUST contain the following data describing the driver's
151+
* currently registered watchers:
152+
*
153+
* [
154+
* "defer" => ["enabled" => int, "disabled" => int],
155+
* "delay" => ["enabled" => int, "disabled" => int],
156+
* "repeat" => ["enabled" => int, "disabled" => int],
157+
* "on_readable" => ["enabled" => int, "disabled" => int],
158+
* "on_writable" => ["enabled" => int, "disabled" => int],
159+
* "on_signal" => ["enabled" => int, "disabled" => int],
160+
* "keep_alive" => int,
161+
* ];
162+
*
163+
* keep_alive refers to the number of referenced watchers.
164+
*
165+
* Implementations MAY optionally add more information in the array but
166+
* at minimum the above key => value format MUST always be provided.
167+
*
168+
* @return array
169+
*/
170+
public function info();
171+
147172
/**
148173
* Get the underlying loop handle.
149174
*

0 commit comments

Comments
 (0)