BlueSpice MediaWiki REL1_27
 All Classes Namespaces Files Functions Variables Groups Pages
LockManager Class Reference

Class for handling resource locking. More...

Inheritance diagram for LockManager:

Public Member Functions

 __construct (array $config)
 
 lock (array $paths, $type=self::LOCK_EX, $timeout=0)
 
 lockByType (array $pathsByType, $timeout=0)
 
 unlock (array $paths, $type=self::LOCK_EX)
 
 unlockByType (array $pathsByType)
 

Public Attributes

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

Protected Member Functions

 sha1Base36Absolute ($path)
 
 sha1Base16Absolute ($path)
 
 normalizePathsByType (array $pathsByType)
 
 doLockByType (array $pathsByType)
 
 doLock (array $paths, $type)
 
 doUnlockByType (array $pathsByType)
 
 doUnlock (array $paths, $type)
 

Protected Attributes

 $lockTypeMap
 
 $locksHeld = []
 
 $domain
 
 $lockTTL
 

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

Constructor & Destructor Documentation

LockManager::__construct ( array  $config)

Construct a new instance from configuration

Parameters
array$configParameters include:
  • domain : Domain (usually wiki ID) that all resources are relative to [optional]
  • lockTTL : Age (in seconds) at which resource locks should expire. This only applies if locks are not tied to a connection/process.

Member Function Documentation

LockManager::doLock ( array  $paths,
  $type 
)
abstractprotected

Lock resources with the given keys and lock type

Parameters
array$pathsList of paths
int$typeLockManager::LOCK_* constant
Returns
Status
LockManager::doLockByType ( array  $pathsByType)
protected
See Also
LockManager::lockByType()
Parameters
array$pathsByTypeMap of LockManager::LOCK_* constants to lists of paths
Returns
Status
Since
1.22
LockManager::doUnlock ( array  $paths,
  $type 
)
abstractprotected

Unlock resources with the given keys and lock type

Parameters
array$pathsList of paths
int$typeLockManager::LOCK_* constant
Returns
Status
LockManager::doUnlockByType ( array  $pathsByType)
protected
See Also
LockManager::unlockByType()
Parameters
array$pathsByTypeMap of LockManager::LOCK_* constants to lists of paths
Returns
Status
Since
1.22
LockManager::lock ( array  $paths,
  $type = self::LOCK_EX,
  $timeout = 0 
)
final

Lock the resources at the given abstract paths

Parameters
array$pathsList of resource names
int$typeLockManager::LOCK_* constant
int$timeoutTimeout in seconds (0 means non-blocking) (since 1.21)
Returns
Status
LockManager::lockByType ( array  $pathsByType,
  $timeout = 0 
)
final

Lock the resources at the given abstract paths

Parameters
array$pathsByTypeMap of LockManager::LOCK_* constants to lists of paths
int$timeoutTimeout in seconds (0 means non-blocking) (since 1.21)
Returns
Status
Since
1.22
LockManager::normalizePathsByType ( array  $pathsByType)
finalprotected

Normalize the $paths array by converting LOCK_UW locks into the appropriate type and removing any duplicated paths for each lock type.

Parameters
array$pathsByTypeMap of LockManager::LOCK_* constants to lists of paths
Returns
array
Since
1.22
LockManager::sha1Base16Absolute (   $path)
finalprotected

Get the base 16 SHA-1 of a string, padded to 31 digits. Before hashing, the path will be prefixed with the domain ID. This should be used interally for lock key or file names.

Parameters
string$path
Returns
string
LockManager::sha1Base36Absolute (   $path)
finalprotected

Get the base 36 SHA-1 of a string, padded to 31 digits. Before hashing, the path will be prefixed with the domain ID. This should be used interally for lock key or file names.

Parameters
string$path
Returns
string
LockManager::unlock ( array  $paths,
  $type = self::LOCK_EX 
)
final

Unlock the resources at the given abstract paths

Parameters
array$pathsList of paths
int$typeLockManager::LOCK_* constant
Returns
Status
LockManager::unlockByType ( array  $pathsByType)
final

Unlock the resources at the given abstract paths

Parameters
array$pathsByTypeMap of LockManager::LOCK_* constants to lists of paths
Returns
Status
Since
1.22

Member Data Documentation

LockManager::$lockTypeMap
protected
Initial value:
= [
self::LOCK_SH => self::LOCK_SH
const LockManager::LOCK_SH = 1

Lock types; stronger locks have higher values


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