PHP - Fonction Mutex :: lock ()

La fonction Mutex :: lock () peut acquérir Mutex.

Syntaxe

final public static boolean Mutex::lock( long $mutex )

La fonction Mutex :: lock () peut tenter de verrouiller le Mutex pour un appelant. Une tentative de verrouillage du Mutex possédé (verrouillé) par un autre thread peut entraîner un blocage.

La fonction Mutex :: lock () peut renvoyer une indication booléenne de succès.

Exemple

<?php
   $mutex = Mutex::create();
   var_dump(Mutex::lock($mutex));
   var_dump(Mutex::unlock($mutex));

   Mutex::destroy($mutex);
?>