Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

Differences Between: [Versions 401 and 403] [Versions 402 and 403]

(no description)

File Size: 191 lines (7 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

timing_wrapper_lock_factory:: (11 methods):
  __construct()
  get_real_factory()
  get_lock()
  record_lock_data()
  release_lock()
  record_lock_released_data()
  supports_timeout()
  supports_auto_release()
  supports_recursion()
  is_available()
  extend_lock()


Class: timing_wrapper_lock_factory  - X-Ref

Timing wrapper around a lock factory.

This passes all calls through to the underlying lock factory, but adds timing information on how
long it takes to get a lock and how long the lock is held for.

__construct($type, lock_factory $factory = null)   X-Ref
Constructor required by interface.

param: string $type Type (should be same as passed to real lock factory)
param: lock_factory $factory Real lock factory

get_real_factory()   X-Ref
Gets the real lock factory that this is wrapping.

return: lock_factory ReaL lock factory

get_lock($resource, $timeout, $maxlifetime = 86400)   X-Ref
Implementation of lock_factory::get_lock that defers to function inner_get_lock and keeps
track of how long it took.

param: string $resource Identifier for the lock
param: int $timeout Number of seconds to wait for a lock before giving up
param: int $maxlifetime Number of seconds to wait before reclaiming a stale lock
return: \core\lock\lock|boolean - An instance of \core\lock\lock if the lock was obtained, or false.

record_lock_data(float $after, float $before, string $type, string $resource, bool $result, $lock)   X-Ref
Records statistics about a lock to the performance data.

param: float $after The time after the lock was achieved.
param: float $before The time before the lock was requested.
param: string $type The type of lock.
param: string $resource The resource being locked.
param: bool $result Whether the lock was successful.
param: lock|string $lock A value uniquely identifying the lock.
return: void

release_lock(lock $lock)   X-Ref
Release a lock that was previously obtained with {@see get_lock}.

param: lock $lock - The lock to release.
return: boolean - True if the lock is no longer held (including if it was never held).

record_lock_released_data($lock)   X-Ref
Find the lock in the performance info and update it with the time held.

param: lock|string $lock A value uniquely identifying the lock.
return: void

supports_timeout()   X-Ref
Calls parent factory to check if it supports timeout.

return: boolean False if attempting to get a lock will block indefinitely.

supports_auto_release()   X-Ref
Calls parent factory to check if it auto-releases locks.

return: boolean True if this lock type will be automatically released when the current process ends.

supports_recursion()   X-Ref


is_available()   X-Ref
Calls parent factory to check if it is available.

return: boolean True if this lock type is available in this environment.

extend_lock()   X-Ref