src/MutexLock.php
function acquire()
    {
        if ( $this->isLocked() )
            // resource is locked
            return false;


        $lockRes = static::_getLocksDir("{$this->realm}.lockfile");
        if (false === $this->file = $file = fopen($lockRes, 'w+') )
            throw new \RuntimeException(sprintf(
                'Failed To Open Resource (%s).'
                , $lockRes
            ));

        if (! flock($file, LOCK_EX | LOCK_NB, $wouldBlock) ) {
            if ($wouldBlock)
                // another process holds the lock
                return false;

            throw new \RuntimeException(sprintf(
                'FAILED to acquire lock[%s] on resource (%s).'
                , $this->realm
                , $lockRes
            ));
        }



        ftruncate($file, 0);
        fwrite($file, sprintf("(%s): Locked Accrued. \n", date('Y-m-d H:i:s')));
        fflush($file);

        return true;
    }
function acquire()
    {
        if ( $this->isLocked() )
            // resource is locked
            return false;


        $lockRes = static::_getLocksDir("{$this->realm}.lockfile");
        if (false === $this->file = $file = fopen($lockRes, 'w+') )
            throw new \RuntimeException(sprintf(
                'Failed To Open Resource (%s).'
                , $lockRes
            ));

        if (! flock($file, LOCK_EX | LOCK_NB, $wouldBlock) ) {
            if ($wouldBlock)
                // another process holds the lock
                return false;

            throw new \RuntimeException(sprintf(
                'FAILED to acquire lock[%s] on resource (%s).'
                , $this->realm
                , $lockRes
            ));
        }



        ftruncate($file, 0);
        fwrite($file, sprintf("(%s): Locked Accrued. \n", date('Y-m-d H:i:s')));
        fflush($file);

        return true;
    }
function acquire ( ) { if ( $ this -> isLocked ( ) ) // resource is locked return false ; $ lockRes = static :: _getLocksDir ( "{$this->realm}.lockfile" ) ; if ( false === $ this -> file = $ file = fopen ( $ lockRes , 'w+' ) ) throw new \ RuntimeException ( sprintf ( 'Failed To Open Resource (%s).' , $ lockRes ) ) ; if ( ! flock ( $ file , LOCK_EX | LOCK_NB , $ wouldBlock ) ) { if ( $ wouldBlock ) // another process holds the lock return false ; throw new \ RuntimeException ( sprintf ( 'FAILED to acquire lock[%s] on resource (%s).' , $ this -> realm , $ lockRes ) ) ; } ftruncate ( $ file , 0 ) ; fwrite ( $ file , sprintf ( "(%s): Locked Accrued. \n" , date ( 'Y-m-d H:i:s' ) ) ) ; fflush ( $ file ) ; return true ; }
Put Lock On Resource

@return bool
Put Lock On Resource