‪TYPO3CMS  ‪main
TYPO3\CMS\Core\Locking\SimpleLockStrategy Class Reference
Inheritance diagram for TYPO3\CMS\Core\Locking\SimpleLockStrategy:
TYPO3\CMS\Core\Locking\LockingStrategyInterface

Public Member Functions

 __construct ($subject)
 
 init ($loops=0, $step=0)
 
 __destruct ()
 
bool release ()
 
bool isAcquired ()
 
bool acquire ($mode=self::LOCK_CAPABILITY_EXCLUSIVE)
 
 destroy ()
 

Static Public Member Functions

static int getCapabilities ()
 
static int getPriority ()
 

Public Attributes

const FILE_LOCK_FOLDER = 'lock/'
 
const DEFAULT_PRIORITY = 50
 
- ‪Public Attributes inherited from ‪TYPO3\CMS\Core\Locking\LockingStrategyInterface
const LOCK_CAPABILITY_EXCLUSIVE = 1
 
const LOCK_CAPABILITY_SHARED = 2
 
const LOCK_CAPABILITY_NOBLOCK = 4
 

Protected Attributes

string $filePath
 
bool $isAcquired = false
 
int $loops = 150
 
int $step = 200
 

Detailed Description

Simple file locking

Definition at line 27 of file SimpleLockStrategy.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Locking\SimpleLockStrategy::__construct (   $subject)
Parameters
string$subject‪ID to identify this lock in the system
Exceptions
LockCreateException‪if the lock could not be created

Implements TYPO3\CMS\Core\Locking\LockingStrategyInterface.

Definition at line 54 of file SimpleLockStrategy.php.

References $GLOBALS, TYPO3\CMS\Core\Locking\SimpleLockStrategy\FILE_LOCK_FOLDER, TYPO3\CMS\Core\Core\Environment\getProjectPath(), TYPO3\CMS\Core\Core\Environment\getVarPath(), and TYPO3\CMS\Core\Utility\GeneralUtility\mkdir().

◆ __destruct()

TYPO3\CMS\Core\Locking\SimpleLockStrategy::__destruct ( )

Destructor: Releases lock automatically when instance is destroyed and release resources

Definition at line 94 of file SimpleLockStrategy.php.

References TYPO3\CMS\Core\Locking\SimpleLockStrategy\release().

Member Function Documentation

◆ acquire()

bool TYPO3\CMS\Core\Locking\SimpleLockStrategy::acquire (   $mode = self::LOCK_CAPABILITY_EXCLUSIVE)

Try to acquire a lock

Parameters
int$mode‪LOCK_CAPABILITY_EXCLUSIVE or self::LOCK_CAPABILITY_NOBLOCK
Returns
‪bool Returns TRUE if the lock was acquired successfully
Exceptions
LockAcquireWouldBlockException

Implements TYPO3\CMS\Core\Locking\LockingStrategyInterface.

Definition at line 149 of file SimpleLockStrategy.php.

References TYPO3\CMS\Core\Locking\SimpleLockStrategy\$isAcquired, TYPO3\CMS\Core\Locking\SimpleLockStrategy\$loops, TYPO3\CMS\Core\Utility\GeneralUtility\fixPermissions(), and TYPO3\CMS\Core\Locking\SimpleLockStrategy\isAcquired().

◆ destroy()

TYPO3\CMS\Core\Locking\SimpleLockStrategy::destroy ( )

Destroys the resource associated with the lock

Implements TYPO3\CMS\Core\Locking\LockingStrategyInterface.

Definition at line 200 of file SimpleLockStrategy.php.

◆ getCapabilities()

static int TYPO3\CMS\Core\Locking\SimpleLockStrategy::getCapabilities ( )
static
Returns
‪int LOCK_CAPABILITY_* elements combined with bit-wise OR

Implements TYPO3\CMS\Core\Locking\LockingStrategyInterface.

Definition at line 137 of file SimpleLockStrategy.php.

References TYPO3\CMS\Core\Locking\LockingStrategyInterface\LOCK_CAPABILITY_NOBLOCK.

◆ getPriority()

static int TYPO3\CMS\Core\Locking\SimpleLockStrategy::getPriority ( )
static

◆ init()

TYPO3\CMS\Core\Locking\SimpleLockStrategy::init (   $loops = 0,
  $step = 0 
)
Parameters
int$loops‪Number of times a locked resource is tried to be acquired.
int$step‪Milliseconds after lock acquire is retried. $loops * $step results in the maximum delay of a lock.

Definition at line 84 of file SimpleLockStrategy.php.

References TYPO3\CMS\Core\Locking\SimpleLockStrategy\$loops, and TYPO3\CMS\Core\Locking\SimpleLockStrategy\$step.

◆ isAcquired()

bool TYPO3\CMS\Core\Locking\SimpleLockStrategy::isAcquired ( )

Get status of this lock

Returns
‪bool Returns TRUE if lock is acquired by this locker, FALSE otherwise

Implements TYPO3\CMS\Core\Locking\LockingStrategyInterface.

Definition at line 129 of file SimpleLockStrategy.php.

References TYPO3\CMS\Core\Locking\SimpleLockStrategy\$isAcquired.

Referenced by TYPO3\CMS\Core\Locking\SimpleLockStrategy\acquire(), and TYPO3\CMS\Core\Locking\SimpleLockStrategy\release().

◆ release()

bool TYPO3\CMS\Core\Locking\SimpleLockStrategy::release ( )

Release the lock

Returns
‪bool Returns TRUE on success or FALSE on failure

Implements TYPO3\CMS\Core\Locking\LockingStrategyInterface.

Definition at line 104 of file SimpleLockStrategy.php.

References TYPO3\CMS\Core\Core\Environment\getVarPath(), and TYPO3\CMS\Core\Locking\SimpleLockStrategy\isAcquired().

Referenced by TYPO3\CMS\Core\Locking\SimpleLockStrategy\__destruct().

Member Data Documentation

◆ $filePath

string TYPO3\CMS\Core\Locking\SimpleLockStrategy::$filePath
protected

File path used for this lock

Definition at line 36 of file SimpleLockStrategy.php.

◆ $isAcquired

bool TYPO3\CMS\Core\Locking\SimpleLockStrategy::$isAcquired = false
protected

◆ $loops

int TYPO3\CMS\Core\Locking\SimpleLockStrategy::$loops = 150
protected

Number of times a locked resource is tried to be acquired. Only used in manual locks method "simple".

Definition at line 44 of file SimpleLockStrategy.php.

Referenced by TYPO3\CMS\Core\Locking\SimpleLockStrategy\acquire(), and TYPO3\CMS\Core\Locking\SimpleLockStrategy\init().

◆ $step

int TYPO3\CMS\Core\Locking\SimpleLockStrategy::$step = 200
protected

Milliseconds after lock acquire is retried. $loops * $step results in the maximum delay of a lock. Only used in manual lock method "simple".

Definition at line 48 of file SimpleLockStrategy.php.

Referenced by TYPO3\CMS\Core\Locking\SimpleLockStrategy\init().

◆ DEFAULT_PRIORITY

◆ FILE_LOCK_FOLDER