Semaphore
    
            
            in package
            
        
    
    
    
Semaphore Class
$t=new Semaphore();
$t->create(Semaphore::SEM_FTOK_KEY);
// acquire &&  release
$t->acquire();
echo "We are in the sem\n";
$t->release();
// acquire && release (aliases)
$t->synchronizedBegin();
echo "We are in the sem\n";
$t->synchronizedEnd();
$t->destroy();
Table of Contents
Constants
- SEM_FTOK_KEY = 'ftok'
- generate a key based on ftok
- SEM_MAX_INT = 2147483647
- maximum semaphore int
- SEM_MIN_INT = -2147483647
- minimum semaphore int
- SEM_RAND_KEY = 'rand'
- generate a random key
Properties
- $semaphore : resource|SysvSemaphore
- $semKey : int
Methods
- acquire() : Semaphore
- Acquire the semaphore
- create() : Semaphore
- Create a semaphore
- destroy() : Semaphore
- Destroys the semaphore
- getSemaphoreKey() : null|int
- Returns the key, that can be used to access the semaphore
- isCreated() : bool
- Has the semaphore been created?
- release() : Semaphore
- Releases the semaphore
- synchronize() : Semaphore
- Run something synchronized
- synchronizedBegin() : Semaphore
- Acquire the semaphore
- synchronizedEnd() : Semaphore
- Releases the semaphore
Constants
SEM_FTOK_KEY
generate a key based on ftok
    public
        mixed
    SEM_FTOK_KEY
    = 'ftok'
    
    
    
SEM_MAX_INT
maximum semaphore int
    public
        mixed
    SEM_MAX_INT
    = 2147483647
    
    
    
SEM_MIN_INT
minimum semaphore int
    public
        mixed
    SEM_MIN_INT
    = -2147483647
    
    
    
SEM_RAND_KEY
generate a random key
    public
        mixed
    SEM_RAND_KEY
    = 'rand'
    
    
    
Properties
$semaphore
    protected
        resource|SysvSemaphore
    $semaphore
     = NULL
    
        the semaphore resource
$semKey
    protected
        int
    $semKey
     = NULL
    
        the key that is used to access the semaphore
Methods
acquire()
Acquire the semaphore
    public
                    acquire() : Semaphore
    Tags
Return values
Semaphore —the current object
create()
Create a semaphore
    public
                    create([string|int $semKey = Semaphore::SEM_FTOK_KEY ][, int $maxAcquire = 1 ][, int $perms = 0666 ]) : Semaphore
    Parameters
- $semKey : string|int = Semaphore::SEM_FTOK_KEY
- 
                    the key of the semaphore - use a specific number or Semaphore::SEM_RAND_KEY or Semaphore::SEM_FTOK_KEY 
- $maxAcquire : int = 1
- 
                    the maximum number of processes, that can acquire the semaphore 
- $perms : int = 0666
- 
                    the unix permissions for (user,group,others) - valid range from 0 to 0777 
Tags
Return values
Semaphore —the current object
destroy()
Destroys the semaphore
    public
                    destroy() : Semaphore
    Tags
Return values
Semaphore —the current object
getSemaphoreKey()
Returns the key, that can be used to access the semaphore
    public
                    getSemaphoreKey() : null|int
    Return values
null|int —the key of the semaphore
isCreated()
Has the semaphore been created?
    public
                    isCreated() : bool
    Return values
bool —true in case the semaphore has been created
release()
Releases the semaphore
    public
                    release() : Semaphore
    Tags
Return values
Semaphore —the current object
synchronize()
Run something synchronized
    public
                    synchronize(Closure $closure) : Semaphore
    Parameters
- $closure : Closure
- 
                    the closure, that should be run synchronized 
Tags
Return values
Semaphore —the current object
synchronizedBegin()
Acquire the semaphore
    public
                    synchronizedBegin() : Semaphore
    Tags
Return values
Semaphore —the current object
synchronizedEnd()
Releases the semaphore
    public
                    synchronizedEnd() : Semaphore
    Tags
Return values
Semaphore —the current object