SyncMutex::__construct
(PECL sync >= 1.0.0)
SyncMutex::__construct — Constructs a new SyncMutex object
パラメータ
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
+add a note
User Contributed Notes
There are no user contributed notes for this page.
↑ and ↓ to navigate •
Enter to select •
Esc to close
Press Enter without
selection to search using Google