0 follower

Abstract Class Yiisoft\Mutex\MutexFactory

InheritanceYiisoft\Mutex\MutexFactory
ImplementsYiisoft\Mutex\MutexFactoryInterface

Creates a mutex instance.

See also Yiisoft\Mutex\MutexFactoryInterface.

Method Details

Hide inherited methods

create() public abstract method

Defined in: Yiisoft\Mutex\MutexFactoryInterface::create()

Creates a mutex.

public abstract Yiisoft\Mutex\MutexInterface create ( string $name )
$name string

Name of the mutex to create.

                public function create(string $name): MutexInterface;

            
createAndAcquire() public method

public Yiisoft\Mutex\MutexInterface createAndAcquire ( string $name, integer $timeout 0 )
$name string
$timeout integer

                final public function createAndAcquire(string $name, int $timeout = 0): MutexInterface
{
    $mutex = $this->create($name);
    if (!$mutex->acquire($timeout)) {
        throw new MutexLockedException("Unable to acquire the \"$name\" mutex.");
    }
    return $mutex;
}