RequestTimeout
Request timeout library for Excimer with plain PHP fallback
|
A class providing a named critical section concept. More...
Public Member Functions | |
__construct (RequestTimeout $requestTimeout, $emergencyLimit, $emergencyCallback, $implicitExitCallback) | |
enter ( $name, $emergencyLimit=null, $emergencyCallback=null) | |
Enter a critical section, giving it a name. | |
exit ( $name) | |
Exit a named critical section. | |
scopedEnter ( $name, $emergencyLimit=null, $emergencyCallback=null, $implicitExitCallback=null) | |
Enter a critical section, and return a scope variable. | |
getEmergencyLimit () | |
Get the configured emergency time limit. | |
A class providing a named critical section concept.
When the code is inside a critical section, if a request timeout occurs, it is queued and then delivered when the critical section exits.
The class stores configuration for "emergency timeouts". This is a second timeout which limits the amount of time a critical section may be open.
Wikimedia\RequestTimeout\CriticalSectionProvider::enter | ( | $name, | |
$emergencyLimit = null, | |||
$emergencyCallback = null ) |
Enter a critical section, giving it a name.
The name should uniquely identify the calling code.
Multiple critical sections may be active at a given time. Critical sections created by this method must be exited in the reverse order to which they were created, i.e. there is a stack of named critical sections.
string | $name | |
float | null | $emergencyLimit | If non-null, this will override the configured emergency timeout |
callable | null | $emergencyCallback | If non-null, this will override the configured emergency timeout callback. |
Wikimedia\RequestTimeout\CriticalSectionProvider::exit | ( | $name | ) |
Exit a named critical section.
If the name does not match the most recent call to enter(), an exception will be thrown.
CriticalSectionMismatchException | |
TimeoutException |
string | $name |
Wikimedia\RequestTimeout\CriticalSectionProvider::getEmergencyLimit | ( | ) |
Get the configured emergency time limit.
Wikimedia\RequestTimeout\CriticalSectionProvider::scopedEnter | ( | $name, | |
$emergencyLimit = null, | |||
$emergencyCallback = null, | |||
$implicitExitCallback = null ) |
Enter a critical section, and return a scope variable.
The critical section will automatically exit when the scope variable is destroyed.
Multiple critical sections may be active at a given time. There is no restriction on the order in which critical sections created by this method are exited.
NOTE: Callers should typically call CriticalSectionScope::exit() instead of waiting for __destruct() to be called, since exiting a critical section may throw a timeout exception, but it is a fatal error to throw an exception from a destructor during request shutdown.
string | $name | A name for the critical section, used in error messages |
float | null | $emergencyLimit | If non-null, this will override the configured emergency timeout |
callable | null | $emergencyCallback | If non-null, this will override the configured emergency timeout callback. |
callable | null | $implicitExitCallback | If non-null, this will override the configured implicit exit callback. The callback will be called if the section is exited in __destruct() instead of by calling exit(). |