interface FileLockInterface implements LoggerAwareInterface

Interface that a file lock.

Constants

LOCK_SHARED

Option for shared lock.

LOCK_EXCLUSIVE

Option for exclusive lock.

LOCK_NON_BLOCKING

Option for non-blocking lock acquisition.

LOCK_BLOCKING

Option for blocking lock acquisition.

Methods

__construct( string $file, null|int $options = null, LoggerInterface $logger = null)

Construct file lock with file name and optional options bitmask and logger instance.

setOptions( int $options)

Assign the options bitmask to configure locking behavior.

bool
isAcquired()

Returns true if lock has been acquired.

bool
isShared()

Returns true if lock is shared.

bool
isExclusive()

Returns true if lock is exclusive.

bool
isBlocking()

Returns if lock is blocking.

bool
isNonBlocking()

Returns true if lock is non blocking.

bool
hasResource()

Returns true if file handle is held.

resource
getResource()

Returns the file handle.

bool
acquire()

Try to acquire a file lock.

bool
release()

Try to release a file lock.

Details

at line line 49
__construct( string $file, null|int $options = null, LoggerInterface $logger = null)

Construct file lock with file name and optional options bitmask and logger instance.

Parameters

string $file The path to the file to lock
null|int $options An options bitmark to configure locking behavior
LoggerInterface $logger A logger instance enables acquire/release logging

at line line 56
setOptions( int $options)

Assign the options bitmask to configure locking behavior.

Parameters

int $options An options bitmark to configure locking behavior

at line line 63
bool isAcquired()

Returns true if lock has been acquired.

Return Value

bool

at line line 70
bool isShared()

Returns true if lock is shared.

Return Value

bool

at line line 77
bool isExclusive()

Returns true if lock is exclusive.

Return Value

bool

at line line 84
bool isBlocking()

Returns if lock is blocking.

Return Value

bool

at line line 91
bool isNonBlocking()

Returns true if lock is non blocking.

Return Value

bool

at line line 98
bool hasResource()

Returns true if file handle is held.

Return Value

bool

at line line 105
resource getResource()

Returns the file handle.

Return Value

resource

at line line 112
bool acquire()

Try to acquire a file lock.

Return Value

bool

at line line 119
bool release()

Try to release a file lock.

Return Value

bool