RequestTimeout
Request timeout library for Excimer with plain PHP fallback
Loading...
Searching...
No Matches
Wikimedia\RequestTimeout\RequestTimeout Class Reference
+ Inheritance diagram for Wikimedia\RequestTimeout\RequestTimeout:

Public Member Functions

 createCriticalSectionProvider ( $emergencyLimit, $emergencyCallback=null, $implicitExitCallback=null)
 Create a CriticalSectionProvider with the specified configuration.
 
 enterCriticalSection ( $name, $emergencyLimit, $emergencyCallback)
 
 exitCriticalSection ( $id)
 
 setWallTimeLimit ( $limit)
 Set the wall time limit.
 
 getWallTimeRemaining ()
 Get the amount of time remaining of the limit.
 
 getWallTimeLimit ()
 Get the current wall time limit, or INF if there is no limit.
 

Static Public Member Functions

static singleton ()
 Get a singleton instance of RequestTimeout.
 
static setInstance (?RequestTimeout $instance)
 Set the instance to be returned by singleton(), or null to clear the instance so that it will be recreated.
 
static factory ()
 Create a new instance of RequestTimeout.
 

Member Function Documentation

◆ createCriticalSectionProvider()

Wikimedia\RequestTimeout\RequestTimeout::createCriticalSectionProvider ( $emergencyLimit,
$emergencyCallback = null,
$implicitExitCallback = null )

Create a CriticalSectionProvider with the specified configuration.

Parameters
float$emergencyLimitThe emergency timeout in seconds
callable | null$emergencyCallbackA callback to call when the emergency timeout expires. If null, an exception will be thrown.
callable | null$implicitExitCallbackA callback to call if a critical section scope is exited implicitly, rather than by calling exit().
Returns
CriticalSectionProvider

◆ factory()

static Wikimedia\RequestTimeout\RequestTimeout::factory ( )
static

Create a new instance of RequestTimeout.

If the Excimer extension is loaded, this will return a fully functional implementation. If it is not loaded, a fallback implementation will be returned.

Returns
RequestTimeout

◆ getWallTimeLimit()

Wikimedia\RequestTimeout\RequestTimeout::getWallTimeLimit ( )
abstract

Get the current wall time limit, or INF if there is no limit.

Returns
float

Reimplemented in Wikimedia\RequestTimeout\Detail\BasicRequestTimeout, and Wikimedia\RequestTimeout\Detail\ExcimerRequestTimeout.

◆ getWallTimeRemaining()

Wikimedia\RequestTimeout\RequestTimeout::getWallTimeRemaining ( )
abstract

Get the amount of time remaining of the limit.

If there is no limit, INF will be returned.

Returns
float

Reimplemented in Wikimedia\RequestTimeout\Detail\BasicRequestTimeout, and Wikimedia\RequestTimeout\Detail\ExcimerRequestTimeout.

◆ setInstance()

static Wikimedia\RequestTimeout\RequestTimeout::setInstance ( ?RequestTimeout $instance)
static

Set the instance to be returned by singleton(), or null to clear the instance so that it will be recreated.

Parameters
RequestTimeout | null$instance

◆ setWallTimeLimit()

Wikimedia\RequestTimeout\RequestTimeout::setWallTimeLimit ( $limit)
abstract

Set the wall time limit.

If excimer is available, an exception will be thrown after the specified number of seconds.

If excimer is not available, this falls back to set_time_limit(), which causes a fatal error after the CPU time (not wall clock time) exceeds the given number of seconds, which is rounded to an integer.

A time limit of INF or 0 is interpreted as no limit.

Parameters
float$limitThe limit in seconds

Reimplemented in Wikimedia\RequestTimeout\Detail\BasicRequestTimeout, and Wikimedia\RequestTimeout\Detail\ExcimerRequestTimeout.

◆ singleton()

static Wikimedia\RequestTimeout\RequestTimeout::singleton ( )
static

Get a singleton instance of RequestTimeout.

If the Excimer extension is loaded, this will return a fully functional implementation. If it is not loaded, a fallback implementation will be returned.

Returns
RequestTimeout

The documentation for this class was generated from the following file: