Download the PHP package wikimedia/wait-condition-loop without Composer
On this page you can find all versions of the php package wikimedia/wait-condition-loop. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wikimedia/wait-condition-loop
More information about wikimedia/wait-condition-loop
Files in wikimedia/wait-condition-loop
Package wait-condition-loop
Short Description Wait loop that reaches a condition or times out
License GPL-2.0-or-later
Homepage https://www.mediawiki.org/wiki/WaitConditionLoop
Informations about the package wait-condition-loop
Wait Condition Loop for PHP
This class is used for waiting on a condition to be reached, with the ability to specify a timeout. The condition is considered reached when the condition callback returns CONDITION_REACHED or true. CONDITION_ABORTED can also be used to stop the loop.
Additionally, "work" callbacks can be injected to prepare useful work instead of simply having the current thread sleep or block on I/O. The loop will run one of these callbacks on each iteration of checking the condition callback, as long as there are any left to run.
The loop class will automatically either retry the condition or usleep() before retrying it, depending on CPU usage. Low CPU usage and significant real-time passage is used to detect whether the condition callback appears to use blocking I/O. Use of usleep() will not occur until all of the "work" callbacks have run. This means that the condition callback can either be an "instant" CPU-bound check or a blocking I/O call with a small timeout. Both cases should automatically work without CPU intensive spin loops.
Additional documentation about the library can be found on mediawiki.org.
Usage
Running tests
composer install
composer test