Abstract Class Yiisoft\Mutex\MutexFactory
| Inheritance | Yiisoft\ |
|---|---|
| Implements | Yiisoft\ |
Creates a mutex instance.
See also Yiisoft\
Public Methods
| Method | Description | Defined By |
|---|---|---|
| create() | Creates a mutex. | Yiisoft\ |
| createAndAcquire() | Yiisoft\ |
Method Details
Defined in:
Yiisoft\
Creates a mutex.
| public abstract Yiisoft\ | ||
| $name | string |
Name of the mutex to create. |
public function create(string $name): MutexInterface;
| public Yiisoft\ | ||
| $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;
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.