eZ Publish  [4.2]
eZMutex Class Reference

The class eZMutex provides a file based mutex. The mutex works across processes. More...

List of all members.

Public Member Functions

 clearMeta ()
 eZMutex ($name)
 lock ()
 lockTS ()
 meta ($key)
 setMeta ($key, $value)
 steal ($force=false)
 test ()
 unlock ()

Public Attributes

 $FileName
 $Name
const STEAL_STRING = '_eZMutex_Steal'

Private Member Functions

 fp ()

Detailed Description

The class eZMutex provides a file based mutex. The mutex works across processes.

Definition at line 40 of file ezmutex.php.


Member Function Documentation

eZMutex::clearMeta ( )

Clear the meta data

Definition at line 158 of file ezmutex.php.

Referenced by lock().

eZMutex::eZMutex ( name)

Constructor. Creates a mutex object for mutext <name>. The mutex is file based, and a mutex is valid across PHP processes.

Parameters:
mutexname

Definition at line 51 of file ezmutex.php.

Referenced by steal().

eZMutex::fp ( ) [private]

Get file pointer

Definition at line 67 of file ezmutex.php.

Referenced by lock(), test(), and unlock().

eZMutex::lock ( )

Lock. Blocks untill the mutex becomes available

Returns:
true if lock is successfull. false if it fails to require a lock.

Definition at line 105 of file ezmutex.php.

Referenced by steal().

eZMutex::lockTS ( )

Get the timestamp of when the mutex was locked

Returns:
GMT timestamp of when the mutex was created. false if no lock exists.

Definition at line 189 of file ezmutex.php.

eZMutex::meta ( key)

Read meta data

Parameters:
key
Returns:
value, null if no value is associated with the key.

Definition at line 145 of file ezmutex.php.

Referenced by lockTS().

eZMutex::setMeta ( key,
value 
)

Set metadata

Parameters:
key
value

Definition at line 125 of file ezmutex.php.

Referenced by lock().

eZMutex::steal ( force = false)

Steal. The function will aquire a lock on the mutex when it's stolen. $myMutex = new eZMutex( 'myMutex' ); if ( $myMutex->steal() ) { protected code goes here $myMutex->unlock(); }

Parameters:
force.If this is set to true, the process will steal the mutex, even if other processes are in the process of stealing it as well.
Returns:
false If the process is not able to steal the mutex. true if the mutex is successfully stolen.

Definition at line 211 of file ezmutex.php.

eZMutex::test ( )

Test if mutex is locked.

Returns:
true if mutex is locked

Definition at line 86 of file ezmutex.php.

Referenced by lockTS().

eZMutex::unlock ( )

Unlock. Unlocks the mutex.

Returns:
true if the unlock is successfull.

Definition at line 171 of file ezmutex.php.

Referenced by steal().


Member Data Documentation

eZMutex::$FileName

Definition at line 253 of file ezmutex.php.

eZMutex::$Name

Definition at line 252 of file ezmutex.php.

const eZMutex::STEAL_STRING = '_eZMutex_Steal'

Definition at line 42 of file ezmutex.php.

Referenced by steal().


The documentation for this class was generated from the following file: