Class Symfony\Component\Filesystem\LockHandler

InheritanceSymfony\Component\Filesystem\LockHandler

LockHandler class provides a simple abstraction to lock anything by means of a file lock.

A locked file is created based on the lock name when calling lock(). Other lock handlers will not be able to lock the same name until it is released (explicitly by calling release() or implicitly when the instance holding the lock is destroyed).

Method Details

__construct() public method

public void __construct ( $name, $lockPath null )
$name string

The lock name

$lockPath string|null

The directory to store the lock. Default values will use temporary directory

throws Symfony\Component\Filesystem\Exception\IOException

If the lock directory could not be created or is not writable

lock() public method

Lock the resource.

public bool lock ( $blocking false )
$blocking bool

Wait until the lock is released

return bool

Returns true if the lock was acquired, false otherwise

throws Symfony\Component\Filesystem\Exception\IOException

If the lock file could not be created or opened

release() public method

Release the resource.

public void release ( )