MediaWiki  REL1_20
LockManager Class Reference

Class for handling resource locking. More...

Inheritance diagram for LockManager:

List of all members.

Public Member Functions

 __construct (array $config)
 Construct a new instance from configuration.
 lock (array $paths, $type=self::LOCK_EX)
 Lock the resources at the given abstract paths.
 unlock (array $paths, $type=self::LOCK_EX)
 Unlock the resources at the given abstract paths.

Public Attributes

const LOCK_EX = 3
const LOCK_SH = 1
const LOCK_UW = 2

Protected Member Functions

 doLock (array $paths, $type)
 Lock resources with the given keys and lock type.
 doUnlock (array $paths, $type)
 Unlock resources with the given keys and lock type.

Static Protected Member Functions

static sha1Base36 ($path)
 Get the base 36 SHA-1 of a string, padded to 31 digits.

Protected Attributes

Array $locksHeld = array()
 Map of (resource path => lock type => count) *.
Array $lockTypeMap
 Mapping of lock types to the type actually used *.

Detailed Description

Class for handling resource locking.

Locks on resource keys can either be shared or exclusive.

Implementations must keep track of what is locked by this proccess in-memory and support nested locking calls (using reference counting). At least LOCK_UW and LOCK_EX must be implemented. LOCK_SH can be a no-op. Locks should either be non-blocking or have low wait timeouts.

Subclasses should avoid throwing exceptions at all costs.

Since:
1.19

Definition at line 45 of file LockManager.php.


Constructor & Destructor Documentation

LockManager::__construct ( array $  config)

Construct a new instance from configuration.

Parameters:
$configArray

Reimplemented in DBLockManager, LSLockManager, MemcLockManager, and FSLockManager.

Definition at line 64 of file LockManager.php.


Member Function Documentation

LockManager::doLock ( array $  paths,
type 
) [abstract, protected]

Lock resources with the given keys and lock type.

Parameters:
$pathsArray List of storage paths
$typeinteger LockManager::LOCK_* constant
Returns:
string

Reimplemented in NullLockManager, QuorumLockManager, and FSLockManager.

LockManager::doUnlock ( array $  paths,
type 
) [abstract, protected]

Unlock resources with the given keys and lock type.

Parameters:
$pathsArray List of storage paths
$typeinteger LockManager::LOCK_* constant
Returns:
string

Reimplemented in NullLockManager, QuorumLockManager, and FSLockManager.

LockManager::lock ( array $  paths,
type = self::LOCK_EX 
) [final]

Lock the resources at the given abstract paths.

Parameters:
$pathsArray List of resource names
$typeinteger LockManager::LOCK_* constant
Returns:
Status

Definition at line 73 of file LockManager.php.

static LockManager::sha1Base36 ( path) [static, final, protected]

Get the base 36 SHA-1 of a string, padded to 31 digits.

Parameters:
$pathstring
Returns:
string

Definition at line 100 of file LockManager.php.

LockManager::unlock ( array $  paths,
type = self::LOCK_EX 
) [final]

Unlock the resources at the given abstract paths.

Parameters:
$pathsArray List of storage paths
$typeinteger LockManager::LOCK_* constant
Returns:
Status

Definition at line 87 of file LockManager.php.


Member Data Documentation

Array LockManager::$locksHeld = array() [protected]

Map of (resource path => lock type => count) *.

Definition at line 52 of file LockManager.php.

Array LockManager::$lockTypeMap [protected]
Initial value:
 array(
                self::LOCK_SH => self::LOCK_SH,
                self::LOCK_UW => self::LOCK_EX, 
                self::LOCK_EX => self::LOCK_EX
        )

Mapping of lock types to the type actually used *.

Reimplemented in MySqlLockManager, LSLockManager, MemcLockManager, and FSLockManager.

Definition at line 46 of file LockManager.php.

Definition at line 55 of file LockManager.php.

Referenced by FileBackendTest\doTestLockCalls().

Definition at line 56 of file LockManager.php.

Referenced by SyncFileBackend\syncFileBatch().


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