- $mypid = getmypid();
-
- // Check if we should pass some low priority process
- $highest_priority = 0;
- $found = false;
- $passing_slow = false;
-
- // The higher the number of parallel workers, the more we prefetch to prevent concurring access
- // We decrease the limit with the number of entries left in the queue
- $worker_queues = Config::get("system", "worker_queues", 4);
- $queue_length = Config::get('system', 'worker_fetch_limit', 1);
- $lower_job_limit = $worker_queues * $queue_length * 2;
- $entries = max($entries - $deferred, 0);
-
- // Now do some magic
- $exponent = 2;
- $slope = $queue_length / pow($lower_job_limit, $exponent);
- $limit = min($queue_length, ceil($slope * pow($entries, $exponent)));
-
- Logger::log('Deferred: ' . $deferred . ' - Total: ' . $entries . ' - Maximum: ' . $queue_length . ' - jobs per queue: ' . $limit, Logger::DEBUG);
- $ids = [];
- if (self::passingSlow($highest_priority)) {
- // Are there waiting processes with a higher priority than the currently highest?
+ $waiting = [];
+ $priorities = [PRIORITY_CRITICAL, PRIORITY_HIGH, PRIORITY_MEDIUM, PRIORITY_LOW, PRIORITY_NEGLIGIBLE];
+ foreach ($priorities as $priority) {