Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401] [Versions 401 and 403]

Class representing a lock The methods available for a specific lock type are only known by it's factory.

Copyright: Damyon Wiese 2013
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 144 lines (5 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

lock:: (6 methods):
  __construct()
  init_factory()
  get_key()
  extend()
  release()
  __destruct()


Class: lock  - X-Ref

Class representing a lock

The methods available for a specific lock type are only known by it's factory.

__construct($key, $factory)   X-Ref
Construct a lock containing the unique key required to release it.

param: mixed $key - The lock key. The type of this is up to the lock_factory being used.
param: lock_factory $factory - The factory that generated this lock.

init_factory(lock_factory $factory)   X-Ref
Sets the lock factory that owns a lock. This function should not be called under normal use.
It is intended only for cases like {@see timing_wrapper_lock_factory} where we wrap a lock
factory.

When used, it should be called immediately after constructing the lock.

param: lock_factory $factory New lock factory that owns this lock

get_key()   X-Ref
Return the unique key representing this lock.

return: string|int lock key.

extend($maxlifetime = 86400)   X-Ref
Extend the lifetime of this lock. Not supported by all factories.

param: int $maxlifetime - the new lifetime for the lock (in seconds).
return: bool

release()   X-Ref
Release this lock

return: bool

__destruct()   X-Ref
Print debugging if this lock falls out of scope before being released.