update : 2015.11.03
php.shukuma.com

검색:
 
 
Constructs a new SyncMutex object

SyncMutex::__construct

(PECL sync >= 1.0.0)

SyncMutex::__constructConstructs 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.

Note:

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.

예제

Example #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();
?>

Example #2 SyncMutex::__construct() unnamed mutex example

<?php
$mutex 
= new SyncMutex();

$mutex->lock();

/* ... */

$mutex->unlock();
?>

참고