You are here

function _hosting_queue_next_run in Hosting 6.2

Same name and namespace in other branches
  1. 7.4 hosting.queues.inc \_hosting_queue_next_run()
  2. 7.3 hosting.queues.inc \_hosting_queue_next_run()

Calculate the time at which the task queue will run next.

There are two possibilities here - the task was never run, in which case we compute the next time it was run.

The second case is the case where the task wasn't run in the last queue run even though it was scheduled, so we compute the next iteration.

Parameters

$queue mixed: the queue name or a queue array as returned by hosting_get_queues()

Return value

integer the date at which the queue will run as a number of seconds since the UNIX epoch

Related topics

2 calls to _hosting_queue_next_run()
hosting_add_task in task/hosting_task.module
Helper function to generate new task node
hosting_task_view in task/hosting_task.module
Implementation of hook_view().

File

./hosting.queues.inc, line 155
This file defines an API for defining new queues.

Code

function _hosting_queue_next_run($queue) {
  if (!is_array($queue)) {
    $queues = hosting_get_queues();
    $queue = $queues[$queue];
  }
  $freq = $queue['frequency'];
  $last = $queue['last_run'];
  $now = time();
  return max($last + $freq, $now - ($now - $last) % $freq + $freq);
}