You are here

function elysia_cron_run_available_channel in Elysia Cron 6.2

Same name and namespace in other branches
  1. 7.2 elysia_cron.module \elysia_cron_run_available_channel()

Find an idle channel (not running, or stuck). If found one, set it as running and returns available jobs.

Return value

if found returns array { 'name' => name of channel, 'jobs' => array of active jobs }, else return FALSE

1 call to elysia_cron_run_available_channel()
elysia_cron_run in ./elysia_cron.module
Public function to invoke a complete cron_run

File

./elysia_cron.module, line 1333

Code

function elysia_cron_run_available_channel($ignore_disable = false, $ignore_time = false, $ignore_running = false) {
  global $elysia_cron_settings_by_channel;
  $channels = array_keys($elysia_cron_settings_by_channel);
  $channel = elysia_cron_last_channel();
  $i = array_search($channel, $channels);
  if ($i === FALSE) {
    $i = -1;
  }
  $k = 0;
  $jobs = false;
  for ($j = ($i + 1) % count($channels); $k < count($channels); $j = ($j + 1) % count($channels)) {
    $jobs = elysia_cron_check_run_channel($channels[$j], $ignore_disable, $ignore_time, $ignore_running);
    if ($jobs && count($jobs)) {
      break;
    }
    $k++;
  }
  if ($jobs) {
    elysia_cron_set_last_channel($channels[$j]);
  }
  return $jobs ? array(
    'name' => $channels[$j],
    'jobs' => $jobs,
  ) : false;
}