Рекурсивный акроним словосочетания «PHP: Hypertext Preprocessor»
Добро пожаловать на форум PHP программистов!
За последние 24 часа нас посетили 17264 программиста и 1691 робот. Сейчас ищут 1230 программистов ...
SyncMutex::__construct - Constructs a new SyncMutex object
Вернуться к: SyncMutex
SyncMutex::__construct
(PECL sync >= 1.0.0)
SyncMutex::__construct — Constructs a new SyncMutex object
Описание
public SyncMutex::__construct
([ string
$name
] )Constructs a named or unnamed countable mutex.
Список параметров
-
name
-
The name of the mutex if this is a named mutex object.
Замечание:
If the name already exists, it must be able to be opened by the current user that the process is running as or an exception will be thrown with a meaningless error message.
Возвращаемые значения
The new SyncMutex object. An exception is thrown if the mutex cannot be created or opened.
Примеры
Пример #1 SyncMutex::__construct() named mutex with lock timeout example
<?php
$mutex = new SyncMutex("UniqueName");
if (!$mutex->lock(3000))
{
echo "Unable to lock mutex.";
exit();
}
/* ... */
$mutex->unlock();
?>
Пример #2 SyncMutex::__construct() unnamed mutex example
<?php
$mutex = new SyncMutex();
$mutex->lock();
/* ... */
$mutex->unlock();
?>
Смотрите также
- SyncMutex::lock() - Waits for an exclusive lock
- SyncMutex::unlock() - Unlocks the mutex
Вернуться к: SyncMutex