Wait loop that reaches a condition or times out.
More...
|
const | CONDITION_REACHED = 1 |
|
const | CONDITION_CONTINUE = 0 |
|
const | CONDITION_FAILED = -1 |
|
const | CONDITION_TIMED_OUT = -2 |
|
const | CONDITION_ABORTED = -3 |
|
Wait loop that reaches a condition or times out.
◆ __construct()
Wikimedia\WaitConditionLoop::__construct |
( |
callable | $condition, |
|
|
| $timeout = 5.0, |
|
|
& | $busyCallbacks = [] ) |
- Parameters
-
callable | $condition | Callback that returns a WaitConditionLoop::CONDITION_ constant |
float | $timeout | Timeout in seconds |
array | &$busyCallbacks | List of callbacks to do useful work (by reference) |
◆ getCpuTime()
Wikimedia\WaitConditionLoop::getCpuTime |
( |
| ) |
|
|
protected |
- Returns
- float Returns 0.0 if not supported (Windows on PHP < 7) @codeCoverageIgnore
◆ getLastWaitTime()
Wikimedia\WaitConditionLoop::getLastWaitTime |
( |
| ) |
|
◆ getWallTime()
Wikimedia\WaitConditionLoop::getWallTime |
( |
| ) |
|
|
protected |
- Returns
- float @codeCoverageIgnore
◆ invoke()
Wikimedia\WaitConditionLoop::invoke |
( |
| ) |
|
Invoke the loop and continue until either:
- a) The condition callback returns neither CONDITION_CONTINUE nor false
- b) The timeout is reached Thus a condition callback can return true (stop) or false (continue) for convenience. In such cases, the halting result of "true" will be converted to CONDITION_REACHED.
If $timeout is 0, then only the condition callback will be called (no busy callbacks), and this will immediately return CONDITION_FAILED if the condition was not met.
Exceptions in callbacks will be caught and the callback will be swapped with one that simply rethrows that exception back to the caller when invoked.
- Returns
- int WaitConditionLoop::CONDITION_* constant
- Exceptions
-
Exception Any error from the condition callback
◆ usleep()
Wikimedia\WaitConditionLoop::usleep |
( |
| $microseconds | ) |
|
|
protected |
- Parameters
-
int | $microseconds | @codeCoverageIgnore |
The documentation for this class was generated from the following file: