eZ Publish  [trunk]
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 17 of file ezmutex.php.


Member Function Documentation

Clear the meta data

Definition at line 133 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 28 of file ezmutex.php.

Referenced by steal().

eZMutex::fp ( ) [private]

Get file pointer

Definition at line 44 of file ezmutex.php.

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

Lock. Blocks untill the mutex becomes available

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

Definition at line 82 of file ezmutex.php.

Referenced by steal().

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 162 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 120 of file ezmutex.php.

Referenced by lockTS().

eZMutex::setMeta ( key,
value 
)

Set metadata

Parameters:
key
value

Definition at line 102 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 184 of file ezmutex.php.

Test if mutex is locked.

Returns:
true if mutex is locked

Definition at line 63 of file ezmutex.php.

Referenced by lockTS().

Unlock. Unlocks the mutex.

Returns:
true if the unlock is successfull.

Definition at line 144 of file ezmutex.php.

Referenced by steal().


Member Data Documentation

eZMutex::$FileName

Definition at line 226 of file ezmutex.php.

eZMutex::$Name

Definition at line 225 of file ezmutex.php.

const eZMutex::STEAL_STRING = '_eZMutex_Steal'

Definition at line 19 of file ezmutex.php.

Referenced by steal().


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