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.
Methods
Initializes the choice of semaphore Vs file lock
__construct(boolean $use_lock) : void
Parameters
$use_lock
boolean
True to force use of file locking
Acquires the semaphore or opens and locks the file
acquire() : boolean
Returns
boolean
True if the acquisition succeeded
Returns the semaphore identifier, if it exists, else NULL
getId() : resource
Returns
resource
Semaphore identifier or NULL
Creates the semaphore or sets the (lock) file name
init(integer $id, string $filename) : boolean
Parameters
$id
integer
Key to identify the semaphore
$filename
string
Absolute path and name of the file for locking
Returns
boolean
True if the initialization succeeded
Releases the semaphore or unlocks and closes (but does not unlink) the file
release() : boolean
Returns
boolean
True if the release succeeded
Properties
Name of the (locked) file used as a semaphore
$filename : string
File system pointer resource of the (locked) file used as a semaphore
$filepointer : resource
True if the semaphore has been acquired
$is_acquired : boolean
Semaphore identifier returned by sem_get()
$sem_id : resource
True if using a file lock instead of a semaphore
$use_file_lock : boolean