Abstract Class Yiisoft\Mutex\MutexFactory
| Inheritance | Yiisoft\Mutex\MutexFactory |
|---|---|
| Implements | Yiisoft\Mutex\MutexFactoryInterface |
Creates a mutex instance.
See also Yiisoft\Mutex\MutexFactoryInterface.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| create() | Creates a mutex. | Yiisoft\Mutex\MutexFactoryInterface |
| createAndAcquire() | Yiisoft\Mutex\MutexFactory |
Method Details
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;
| 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;
}
Signup or Login in order to comment.