public function BackgroundProcess::lock in Background Process 7
Same name and namespace in other branches
- 8 background_process.class.php \BackgroundProcess::lock()
- 6 BackgroundProcess.class.php \BackgroundProcess::lock()
- 7.2 background_process.inc \BackgroundProcess::lock()
2 calls to BackgroundProcess::lock()
- BackgroundProcess::queue in ./
BackgroundProcess.class.php - BackgroundProcess::start in ./
BackgroundProcess.class.php - Start background process
File
- ./
BackgroundProcess.class.php, line 45 - Class for handling background processes.
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)) {
// watchdog('bg_process', 'Will not attempt to lock handle %handle, already exists', array('%handle' => $this->handle), WATCHDOG_NOTICE);
return FALSE;
}
// "Lock" handle
$this->start_stamp = $this->start = microtime(TRUE);
if (!background_process_lock_process($this->handle, $status)) {
// If this happens, we might have a race condition or an md5 clash
watchdog('bg_process', 'Could not lock handle %handle', array(
'%handle' => $this->handle,
), WATCHDOG_ERROR);
return FALSE;
}
$this->exec_status = $this->status = BACKGROUND_PROCESS_STATUS_LOCKED;
$this
->sendMessage('locked');
return TRUE;
}