You are here

function httprl_acquire_lock in HTTP Parallel Request & Threading Library 7

Same name and namespace in other branches
  1. 6 httprl.module \httprl_acquire_lock()

Get a lock so background calls work.

Parameters

object $result: An object from httprl_send_request.

1 call to httprl_acquire_lock()
httprl_send_request in ./httprl.module
Perform many HTTP requests.

File

./httprl.module, line 2404
HTTP Parallel Request Library module.

Code

function httprl_acquire_lock(&$result) {
  if (empty($result->options['lock_name'])) {
    return FALSE;
  }

  // Get the maximum amount of time this could take.
  $times = array(
    httprl_variable_get('httprl_timeout', HTTPRL_TIMEOUT),
    httprl_variable_get('httprl_global_timeout', HTTPRL_GLOBAL_TIMEOUT),
  );
  if (isset($result->options['timeout'])) {
    $times[] = $result->options['timeout'];
  }
  if (isset($result->options['global_timeout'])) {
    $times[] = $result->options['global_timeout'];
  }
  $time = max($times);
  $name = $result->options['lock_name'];
  return httprl_acquire_headless_lock($name, $time);
}