You are here

function advancedqueue_cron in Advanced Queue 7

Same name and namespace in other branches
  1. 8 advancedqueue.module \advancedqueue_cron()

Implements hook_cron().

File

./advancedqueue.module, line 96
Helper module for advanced queuing.

Code

function advancedqueue_cron() {

  // Delete older entries and make sure there are no stale items in the table.
  _advancedqueue_cleanup_table();
  if (!variable_get('advancedqueue_use_cron', FALSE)) {
    return;
  }
  if (!($queues = advancedqueue_get_queues_info())) {
    return;
  }
  $end = time() + variable_get('advancedqueue_processing_timeout_cron', 60);
  foreach ($queues as $queue_name => $queue_info) {
    $queue = DrupalQueue::get($queue_name);
    while ($item = $queue
      ->claimItem($queue_info['lease time'])) {
      advancedqueue_process_item($queue, $queue_name, $queue_info, $item, $end);
      if (time() > $end) {

        // We've reached max execution time.
        return;
      }
    }
  }
}