You are here

private function BackgroundProcess::claim in Background Process 7.2

Claim process. Before executing the callback, make sure no one else is doing it.

1 call to BackgroundProcess::claim()
BackgroundProcess::execute in ./background_process.inc
Execute the background process callback function.

File

./background_process.inc, line 988
External API short overview

Class

BackgroundProcess
@file

Code

private function claim() {
  $this
    ->logDebug(__FUNCTION__);
  $start_stamp = microtime(TRUE);
  $count = db_update('background_process', array(
    'target' => 'background_process',
  ))
    ->fields(array(
    'start_stamp' => $start_stamp,
    'exec_status' => BACKGROUND_PROCESS_STATUS_RUNNING,
  ))
    ->condition('pid', $this->pid)
    ->condition('exec_status', array(
    BACKGROUND_PROCESS_STATUS_DISPATCHED,
  ), 'IN')
    ->execute();
  if ($count) {
    $this->start_stamp = $start_stamp;
    $this->exec_status = BACKGROUND_PROCESS_STATUS_RUNNING;
    $this
      ->sendMessage('claimed');
  }
  return $count;
}