\MLAMutex

Class MLA (Media Library Assistant) Mutex provides a simple "mutual exclusion" semaphore for the [mla_gallery] mla_viewer=single option

Adapted from the example by mr.smaon@gmail.com in the PHP Manual "Semaphore Functions" page.

Summary

Methods
Properties
Constants
__construct()
init()
acquire()
release()
getId()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$sem_id
$is_acquired
$use_file_lock
$filename
$filepointer
N/A

Properties

$sem_id

$sem_id : resource

Semaphore identifier returned by sem_get()

Type

resource

$is_acquired

$is_acquired : boolean

True if the semaphore has been acquired

Type

boolean

$use_file_lock

$use_file_lock : boolean

True if using a file lock instead of a semaphore

Type

boolean

$filename

$filename : string

Name of the (locked) file used as a semaphore

Type

string

$filepointer

$filepointer : resource

File system pointer resource of the (locked) file used as a semaphore

Type

resource

Methods

__construct()

__construct(boolean  $use_lock = false) : void

Initializes the choice of semaphore Vs file lock

Parameters

boolean $use_lock

True to force use of file locking

init()

init(integer  $id, string  $filename = '') : boolean

Creates the semaphore or sets the (lock) file name

Parameters

integer $id

Key to identify the semaphore

string $filename

Absolute path and name of the file for locking

Returns

boolean —

True if the initialization succeeded

acquire()

acquire() : boolean

Acquires the semaphore or opens and locks the file

Returns

boolean —

True if the acquisition succeeded

release()

release() : boolean

Releases the semaphore or unlocks and closes (but does not unlink) the file

Returns

boolean —

True if the release succeeded

getId()

getId() : resource

Returns the semaphore identifier, if it exists, else NULL

Returns

resource —

Semaphore identifier or NULL