Moodle PHP Documentation 5.1
Moodle 5.1dev (Build: 20250706) (a6b17d8f6bd)
core\lock\timing_wrapper_lock_factory Class Reference
Inheritance diagram for core\lock\timing_wrapper_lock_factory:
core\lock\lock_factory

Public Member Functions

 __construct ($type, ?lock_factory $factory=null)
 Constructor required by interface.
 
 get_lock ($resource, $timeout, $maxlifetime=86400)
 Implementation of lock_factory::get_lock that defers to function inner_get_lock and keeps track of how long it took.
 
 get_real_factory ()
 Gets the real lock factory that this is wrapping.
 
 is_available ()
 Calls parent factory to check if it is available.
 
 release_lock (lock $lock)
 Release a lock that was previously obtained with {.
 
 supports_auto_release ()
 Calls parent factory to check if it auto-releases locks.
 
 supports_timeout ()
 Calls parent factory to check if it supports timeout.
 

Static Public Member Functions

static record_lock_data (float $after, float $before, string $type, string $resource, bool $result, $lock)
 Records statistics about a lock to the performance data.
 
static record_lock_released_data ($lock)
 Find the lock in the performance info and update it with the time held.
 

Protected Attributes

lock_factory $factory
 Real lock factory.
 
string $type
 Type (Frankenstyle) used for these locks.
 

Detailed Description

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

core\lock\timing_wrapper_lock_factory::__construct ( $type,
?lock_factory $factory = null )

Constructor required by interface.

Parameters
string$typeType (should be same as passed to real lock factory)
lock_factory$factoryReal lock factory

Member Function Documentation

◆ get_lock()

core\lock\timing_wrapper_lock_factory::get_lock ( $resource,
$timeout,
$maxlifetime = 86400 )

Implementation of lock_factory::get_lock that defers to function inner_get_lock and keeps track of how long it took.

Parameters
string$resourceIdentifier for the lock
int$timeoutNumber of seconds to wait for a lock before giving up
int$maxlifetimeNumber of seconds to wait before reclaiming a stale lock
Return values
core::lock::lock|boolean- An instance of core\lock\lock if the lock was obtained, or false.

Implements core\lock\lock_factory.

◆ get_real_factory()

core\lock\timing_wrapper_lock_factory::get_real_factory ( )

Gets the real lock factory that this is wrapping.

Return values
lock_factoryReaL lock factory

◆ is_available()

core\lock\timing_wrapper_lock_factory::is_available ( )

Calls parent factory to check if it is available.

Return values
booleanTrue if this lock type is available in this environment.

Implements core\lock\lock_factory.

◆ record_lock_data()

static core\lock\timing_wrapper_lock_factory::record_lock_data ( float $after,
float $before,
string $type,
string $resource,
bool $result,
$lock )
static

Records statistics about a lock to the performance data.

Parameters
float$afterThe time after the lock was achieved.
float$beforeThe time before the lock was requested.
string$typeThe type of lock.
string$resourceThe resource being locked.
bool$resultWhether the lock was successful.
lock | string$lockA value uniquely identifying the lock.
Return values
void

◆ record_lock_released_data()

static core\lock\timing_wrapper_lock_factory::record_lock_released_data ( $lock)
static

Find the lock in the performance info and update it with the time held.

Parameters
lock | string$lockA value uniquely identifying the lock.
Return values
void

◆ release_lock()

core\lock\timing_wrapper_lock_factory::release_lock ( lock $lock)

Release a lock that was previously obtained with {.

See also
get_lock}.
Parameters
lock$lock- The lock to release.
Return values
boolean- True if the lock is no longer held (including if it was never held).

Implements core\lock\lock_factory.

◆ supports_auto_release()

core\lock\timing_wrapper_lock_factory::supports_auto_release ( )

Calls parent factory to check if it auto-releases locks.

Return values
booleanTrue if this lock type will be automatically released when the current process ends.

Implements core\lock\lock_factory.

◆ supports_timeout()

core\lock\timing_wrapper_lock_factory::supports_timeout ( )

Calls parent factory to check if it supports timeout.

Return values
booleanFalse if attempting to get a lock will block indefinitely.

Implements core\lock\lock_factory.


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