public function BackgroundProcess::lock in Background Process 8
Same name and namespace in other branches
- 6 BackgroundProcess.class.php \BackgroundProcess::lock()
- 7.2 background_process.inc \BackgroundProcess::lock()
- 7 BackgroundProcess.class.php \BackgroundProcess::lock()
Implements to Lock the Background Process.
2 calls to BackgroundProcess::lock()
- BackgroundProcess::queue in ./
background_process.class.php - Implements Queues.
- BackgroundProcess::start in ./
background_process.class.php - Implements to Call the service handler.
File
- ./
background_process.class.php, line 43
Class
- BackgroundProcess
- BackgroundProcess class.
Code
public function lock($status = BACKGROUND_PROCESS_STATUS_LOCKED) {
// Preliminary select to avoid unnecessary write-attempt.
if (background_process_get_process($this->handle)) {
return FALSE;
}
// "Lock" handle.
$this->start_stamp = $this->start = microtime(TRUE);
if (!background_process_lock_process($this->handle, $status)) {
\Drupal::logger('bg_process')
->error('Could not lock handle %handle', [
'%handle' => $this->handle,
]);
return FALSE;
}
$this->exec_status = $this->status = BACKGROUND_PROCESS_STATUS_LOCKED;
$this
->sendMessage('locked');
return TRUE;
}