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.

package

Media Library Assistant

since 2.10

Methods

Initializes the choice of semaphore Vs file lock

__construct(boolean $use_lock = false) : void
since 2.10

Arguments

$use_lock

boolean

True to force use of file locking

Acquires the semaphore or opens and locks the file

acquire() : boolean
since 2.10

Response

boolean

True if the acquisition succeeded

Returns the semaphore identifier, if it exists, else NULL

getId() : resource
since 2.10

Response

resource

Semaphore identifier or NULL

Creates the semaphore or sets the (lock) file name

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

Arguments

$id

integer

Key to identify the semaphore

$filename

string

Absolute path and name of the file for locking

Response

boolean

True if the initialization succeeded

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

release() : boolean
since 2.10

Response

boolean

True if the release succeeded

Properties

Semaphore identifier returned by sem_get()

sem_id : resource
since
var

Type(s)

resource

True if the semaphore has been acquired

is_acquired : boolean
since
var

Type(s)

boolean

True if using a file lock instead of a semaphore

use_file_lock : boolean
since
var

Type(s)

boolean

Name of the (locked) file used as a semaphore

filename : string
since
var

Type(s)

string

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

filepointer : resource
since
var

Type(s)

resource