You are here

function elysia_cron_run_available_channel in Elysia Cron 7.2

Same name and namespace in other branches
  1. 6.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

array|bool 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 1559

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;
}