Back to index

d-push  2.0
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes
SimpleMutex Class Reference
Inheritance diagram for SimpleMutex:
Inheritance graph
[legend]
Collaboration diagram for SimpleMutex:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 SimpleMutex ()
 Constructor.
 Block ()
 Blocks the mutex Method blocks until mutex is available! ATTENTION: make sure that you always release a blocked mutex!
 Release ()
 Releases the mutex After the release other processes are able to block the mutex themselfs.
 InterProcessData ()
 Constructor.
 InitializeParams ()
 Initializes internal parameters.
 ReInitSharedMem ()
 Reinitializes shared memory by removing, detaching and re-allocating it.
 Clean ()
 Cleans up the shared memory block.
 IsActive ()
 Indicates if the shared memory is active.

Public Attributes

const CLEANUPTIME = 1

Protected Member Functions

 blockMutex ()
 Blocks the class mutex Method blocks until mutex is available! ATTENTION: make sure that you always release a blocked mutex!
 releaseMutex ()
 Releases the class mutex After the release other processes are able to block the mutex themselfs.
 hasData ($id=2)
 Indicates if the requested variable is available in shared memory.
 getData ($id=2)
 Returns the requested variable from shared memory.
 setData ($data, $id=2)
 Writes the transmitted variable to shared memory Subclasses may never use an id < 2!

Protected Attributes

 $type
 $allocate

Static Protected Attributes

static $devid
static $pid
static $user
static $start

Detailed Description

Definition at line 44 of file simplemutex.php.


Member Function Documentation

Blocks the mutex Method blocks until mutex is available! ATTENTION: make sure that you always release a blocked mutex!

public

Returns:
boolean

Definition at line 67 of file simplemutex.php.

                            {
        if ($this->IsActive())
            return $this->blockMutex();

        ZLog::Write(LOGLEVEL_WARN, "Could not enter mutex as InterProcessData is not available. This is not recommended on duty systems and may result in corrupt user/device linking!");
        return true;
    }

Here is the call graph for this function:

InterProcessData::blockMutex ( ) [protected, inherited]

Blocks the class mutex Method blocks until mutex is available! ATTENTION: make sure that you always release a blocked mutex!

protected

Returns:
boolean

Definition at line 200 of file interprocessdata.php.

                                    {
        if ((isset($this->mutexid) && $this->mutexid !== false) && (isset($this->memid) && $this->memid !== false))
            return @sem_acquire($this->mutexid);

        return false;
    }

Here is the caller graph for this function:

InterProcessData::Clean ( ) [inherited]

Cleans up the shared memory block.

public

Returns:
boolean

Definition at line 166 of file interprocessdata.php.

                            {
        $stat = false;

        // exclusive block
        if ($this->blockMutex()) {
            $cleanuptime = ($this->hasData(1)) ? $this->getData(1) : false;

            // TODO implement Shared Memory cleanup

            $this->releaseMutex();
        }
        // end exclusive block

        return $stat;
    }

Here is the call graph for this function:

InterProcessData::getData ( id = 2) [protected, inherited]

Returns the requested variable from shared memory.

Parameters:
int$idint indicating the variable

protected

Returns:
mixed

Definition at line 249 of file interprocessdata.php.

                                        {
        if ((isset($this->mutexid) && $this->mutexid !== false) && (isset($this->memid) && $this->memid !== false))
            return @shm_get_var($this->memid, $id);

        return ;
    }

Here is the caller graph for this function:

InterProcessData::hasData ( id = 2) [protected, inherited]

Indicates if the requested variable is available in shared memory.

Parameters:
int$idint indicating the variable

protected

Returns:
boolean

Definition at line 229 of file interprocessdata.php.

                                        {
        if ((isset($this->mutexid) && $this->mutexid !== false) && (isset($this->memid) && $this->memid !== false)) {
            if (function_exists("shm_has_var"))
                return @shm_has_var($this->memid, $id);
            else {
                $some = $this->getData($id);
                return isset($some);
            }
        }
        return false;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Initializes internal parameters.

public

Returns:
boolean

Definition at line 76 of file interprocessdata.php.

                                       {
        if (!isset(self::$devid)) {
            self::$devid = Request::GetDeviceID();
            self::$pid = @getmypid();
            self::$user = Request::GetAuthUser();
            self::$start = time();
        }
        return true;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Constructor.

public

Definition at line 62 of file interprocessdata.php.

                                       {
        if (!isset($this->type) || !isset($this->allocate))
            throw new FatalNotImplementedException(sprintf("Class InterProcessData can not be initialized. Subclass %s did not initialize type and allocable memory.", get_class($this)));

        if ($this->InitSharedMem())
            ZLog::Write(LOGLEVEL_DEBUG, sprintf("%s(): Initialized mutexid %s and memid %s.", get_class($this), $this->mutexid, $this->memid));
    }

Here is the call graph for this function:

InterProcessData::IsActive ( ) [inherited]

Indicates if the shared memory is active.

public

Returns:
boolean

Definition at line 188 of file interprocessdata.php.

                               {
        return ((isset($this->mutexid) && $this->mutexid !== false) && (isset($this->memid) && $this->memid !== false));
    }

Here is the caller graph for this function:

Reinitializes shared memory by removing, detaching and re-allocating it.

public

Returns:
boolean

Definition at line 156 of file interprocessdata.php.

                                      {
        return ($this->RemoveSharedMem() && $this->InitSharedMem());
    }

Here is the call graph for this function:

Releases the mutex After the release other processes are able to block the mutex themselfs.

public

Returns:
boolean

Definition at line 82 of file simplemutex.php.

                              {
        if ($this->IsActive())
            return $this->releaseMutex();

        return true;
    }

Here is the call graph for this function:

InterProcessData::releaseMutex ( ) [protected, inherited]

Releases the class mutex After the release other processes are able to block the mutex themselfs.

protected

Returns:
boolean

Definition at line 214 of file interprocessdata.php.

                                      {
        if ((isset($this->mutexid) && $this->mutexid !== false) && (isset($this->memid) && $this->memid !== false))
            return @sem_release($this->mutexid);

        return false;
    }

Here is the caller graph for this function:

InterProcessData::setData ( data,
id = 2 
) [protected, inherited]

Writes the transmitted variable to shared memory Subclasses may never use an id < 2!

Parameters:
mixed$datadata which should be saved into shared memory
int$idint indicating the variable (bigger than 2!)

protected

Returns:
boolean

Definition at line 266 of file interprocessdata.php.

                                               {
        if ((isset($this->mutexid) && $this->mutexid !== false) && (isset($this->memid) && $this->memid !== false))
            return @shm_put_var($this->memid, $id, $data);

        return false;
    }

Here is the caller graph for this function:

Constructor.

Definition at line 48 of file simplemutex.php.

                                  {
        // initialize super parameters
        $this->allocate = 64;
        $this->type = 5173;
        parent::__construct();

        if (!$this->IsActive()) {
            ZLog::Write(LOGLEVEL_ERROR, "SimpleMutex not available as InterProcessData is not available. This is not recommended on duty systems and may result in corrupt user/device linking.");
        }
    }

Here is the call graph for this function:


Member Data Documentation

InterProcessData::$allocate [protected, inherited]

Definition at line 53 of file interprocessdata.php.

InterProcessData::$devid [static, protected, inherited]

Definition at line 48 of file interprocessdata.php.

InterProcessData::$pid [static, protected, inherited]

Definition at line 49 of file interprocessdata.php.

InterProcessData::$start [static, protected, inherited]

Definition at line 51 of file interprocessdata.php.

InterProcessData::$type [protected, inherited]

Definition at line 52 of file interprocessdata.php.

InterProcessData::$user [static, protected, inherited]

Definition at line 50 of file interprocessdata.php.

const InterProcessData::CLEANUPTIME = 1 [inherited]

Definition at line 46 of file interprocessdata.php.


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