You are here

function background_process_service_group_round_robin in Background Process 8

Same name and namespace in other branches
  1. 6 background_process.module \background_process_service_group_round_robin()
  2. 7.2 background_process.module \background_process_service_group_round_robin()
  3. 7 background_process.module \background_process_service_group_round_robin()

Implements for Round-robin load balancing based on random pick.

1 call to background_process_service_group_round_robin()
background_process_ass_service_group_idle in background_process_ass/background_process_ass.module
Implements to Determine host with most idle workers and claim it.
2 string references to 'background_process_service_group_round_robin'
BackgroundProcess::determineServiceHost in ./background_process.class.php
Implements Function to Determine Service Host.
background_process_get_service_groups in ./background_process.module
Implements to Get service hosts defined in the system.

File

./background_process.module, line 199
This module implements a framework for calling funtions in the background.

Code

function background_process_service_group_round_robin($service_group) {
  static $idx = NULL;
  if (isset($idx)) {
    $idx = ($idx + 1) % count($service_group['hosts']);
  }
  else {
    $idx = rand(0, count($service_group['hosts']) - 1);
  }
  return $service_group['hosts'][$idx];
}