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.

package Media Library Assistant
since 2.10

 Methods

Initializes the choice of semaphore Vs file lock

__construct(boolean $use_lock) : void

since 2.10

Parameters

$use_lock

boolean

True to force use of file locking

Acquires the semaphore or opens and locks the file

acquire() : boolean

since 2.10

Returns

booleanTrue if the acquisition succeeded

Returns the semaphore identifier, if it exists, else NULL

getId() : resource

since 2.10

Returns

resourceSemaphore identifier or NULL

Creates the semaphore or sets the (lock) file name

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

since 2.10

Parameters

$id

integer

Key to identify the semaphore

$filename

string

Absolute 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

since 2.10

Returns

booleanTrue if the release succeeded

 Properties

 

Name of the (locked) file used as a semaphore

$filename : string

since 2.10
 

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

$filepointer : resource

since 2.10
 

True if the semaphore has been acquired

$is_acquired : boolean

since 2.10
 

Semaphore identifier returned by sem_get()

$sem_id : resource

since 2.10
 

True if using a file lock instead of a semaphore

$use_file_lock : boolean

since 2.10