Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

Public Member Functions | Public Attributes | Private Member Functions | List of all members
eZMutex Class Reference

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

## Public Member Functions
| __construct ( $name)
| test ()
| lock ()
| setMeta ( $key, $value)
| meta ( $key)
| clearMeta ()
| unlock ()
| lockTS ()
| steal ( $force=false)

## Public Attributes
const | STEAL_STRING = '_eZMutex_Steal'
| $Name
| $FileName
| $MetaFileName

## 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.

## Constructor & Destructor Documentation

## ◆ __construct()

eZMutex::__construct | ( |  | $name | ) |

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

Parameters

  string | $name |

Definition at line 25 of file ezmutex.php.

References eZSys\cacheDirectory(), eZDir\mkdir(), and eZDir\path().

## Member Function Documentation

## ◆ clearMeta()

eZMutex::clearMeta | ( |  | ) |

Clear the meta data

Definition at line 130 of file ezmutex.php.

References eZFile\create().

Referenced by lock().

## ◆ fp()

eZMutex::fp | ( |  | ) |
| private

Get file pointer

Definition at line 41 of file ezmutex.php.

References $FileName, and eZDebug\writeError().

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

## ◆ lock()

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

References clearMeta(), fp(), and setMeta().

Referenced by steal().

## ◆ lockTS()

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

References meta(), and test().

## ◆ meta()

eZMutex::meta | ( |  | $key | ) |

Read meta data

Parameters

  key |

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

Definition at line 117 of file ezmutex.php.

Referenced by lockTS().

## ◆ setMeta()

eZMutex::setMeta | ( |  | $key,
|  |  | $value
| ) |  |

Set metadata

Parameters

  key |
  value |

Definition at line 99 of file ezmutex.php.

References eZFile\create().

Referenced by lock().

## ◆ steal()

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.

Definition at line 190 of file ezmutex.php.

References lock(), STEAL_STRING, unlock(), and eZDebug\writeNotice().

## ◆ test()

eZMutex::test | ( |  | ) |

Test if mutex is locked.

Returns
  true if mutex is locked

Definition at line 60 of file ezmutex.php.

References fp().

Referenced by lockTS().

## ◆ unlock()

eZMutex::unlock | ( |  | ) |

Unlock. Unlocks the mutex.

Returns
  true if the unlock is successfull.

Definition at line 141 of file ezmutex.php.

References $FileName, and fp().

Referenced by steal().

## Member Data Documentation

## ◆ $FileName

eZMutex::$FileName

Definition at line 232 of file ezmutex.php.

Referenced by fp(), and unlock().

## ◆ $MetaFileName

eZMutex::$MetaFileName

Definition at line 233 of file ezmutex.php.

## ◆ $Name

eZMutex::$Name

Definition at line 231 of file ezmutex.php.

## ◆ STEAL_STRING

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:

- ezmutex.php

Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.