PHP code example of cosmic-beacon / critical-section
1. Go to this page and download the library: Download cosmic-beacon/critical-section library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cosmic-beacon / critical-section example snippets
php
$criticalSection = new FileCriticalSection();
$code = __FILE__;
if ($criticalSection->enter($code, 30)) {
doSomething();
$criticalSection->leave($code);
}
php
$criticalSection = new FileCriticalSection();
$code = __FILE__;
if ($criticalSection->canEnter($code)) {
$criticalSection->enter($code);
doSomething();
$criticalSection->leave($code);
}
php
$criticalSection = new FileCriticalSection();
$code = __FILE__;
if ($criticalSection->enter($code, 0)) {
doSomething();
$criticalSection->leave($code);
}