function _hosting_queue_next_run

7.x-3.x hosting.queues.inc _hosting_queue_next_run($queue)

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_form_submit_messages in ./hosting.module
Submit handler for hosting node forms: Display helpful messages.
hosting_task_view in task/hosting_task.module
Implements hook_view().

File

./hosting.queues.inc, line 169
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 = REQUEST_TIME;
  return max($last + $freq, ($now - (($now - $last) % $freq)) + $freq);
}