eZPublishCommunityProject(LegacyStack)  2013.9
eZMutex Class Reference

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

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.

Member Function Documentation

eZMutex::clearMeta ( )

Clear the meta data

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

Referenced by steal().

eZMutex::fp ( )
private

Get file pointer

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.

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.
eZMutex::meta (   $key)

Read meta data

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

Referenced by lockTS().

eZMutex::setMeta (   $key,
  $value 
)

Set metadata

Parameters
key
value

Referenced by lock().

eZMutex::steal (   $force = false)
 Steal. The function will aquire a lock on the mutex when it's stolen.
 <code>
 $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.
eZMutex::test ( )

Test if mutex is locked.

Returns
true if mutex is locked

Referenced by lockTS().

eZMutex::unlock ( )

Unlock. Unlocks the mutex.

Returns
true if the unlock is successfull.

Referenced by steal().

Member Data Documentation

eZMutex::$FileName

Referenced by fp(), and unlock().

eZMutex::$Name
const eZMutex::STEAL_STRING = '_eZMutex_Steal'

Referenced by steal().


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