Skip to content

Commit 6c531f5

Browse files
Merge pull request #55 from async-interop/info
Add Loop::info
2 parents 8feb808 + 9d990a2 commit 6c531f5

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

src/Loop.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,32 @@ 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+
* "watchers" => ["referenced" => int, "unreferenced" => int],
291+
* ];
292+
*
293+
* Implementations MAY optionally add more information in the array but
294+
* at minimum the above key => value format MUST always be provided.
295+
*
296+
* @return array
297+
*/
298+
public static function info()
299+
{
300+
return self::get()->info();
301+
}
302+
277303
/**
278304
* Disable construction as this is a static class.
279305
*/

src/LoopDriver.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,29 @@ 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+
* "watchers" => ["referenced" => int, "unreferenced" => int],
161+
* ];
162+
*
163+
* Implementations MAY optionally add more information in the array but
164+
* at minimum the above key => value format MUST always be provided.
165+
*
166+
* @return array
167+
*/
168+
public function info();
169+
147170
/**
148171
* Get the underlying loop handle.
149172
*

0 commit comments

Comments
 (0)