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
booleanTrue to force use of file locking
Acquires the semaphore or opens and locks the file
acquire() : boolean
Returns
booleanTrue if the acquisition succeeded
Returns the semaphore identifier, if it exists, else NULL
getId() : resource
Returns
resourceSemaphore identifier or NULL
Creates the semaphore or sets the (lock) file name
init(integer $id, string $filename) : boolean
Parameters
$id
integerKey to identify the semaphore
$filename
stringAbsolute path and name of the file for locking
Returns
booleanTrue if the initialization succeeded
Releases the semaphore or unlocks and closes (but does not unlink) the file
release() : boolean
Returns
booleanTrue 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