public function acquire($blocking = true)
{
if ($this->locked) {
throw new \RuntimeException('already lock by yourself');
}
if ($blocking === false) {
if (version_compare(PHP_VERSION, '5.6.0') < 0) {
throw new \RuntimeException('php version is at least 5.6.0 for param blocking');
}
if (!sem_acquire($this->lock_id, true)) {
return false;
}
$this->locked = true;
return true;
}
if (!sem_acquire($this->lock_id)) {
return false;
}
$this->locked = true;
return true;
}