public static function pts_timed_function($function, $time, $parameters = null) { if ($time < 0.5 && $time != -1 || $time > 300) { return; } //TODO improve accuracy by comparing time pre- and post- loop iteration if (function_exists('pcntl_fork')) { $pid = pcntl_fork(); if ($pid != -1) { if ($pid) { return $pid; } else { $loop_continue = true; /* ML: I think this below check can be safely removed $start_id = pts_unique_runtime_identifier(); && ($start_id == pts_unique_runtime_identifier() || $start_id == PTS_INIT_TIME) */ while (pts_test_run_manager::test_run_process_active() !== -1 && is_file(PTS_USER_LOCK) && $loop_continue) { // if ($parameters == null || !is_array($parameters)) // { // $parameters = array(); // } $parameter_array = pts_arrays::to_array($parameters); call_user_func_array(array(self::module_name(), $function), $parameter_array); if ($time > 0) { sleep($time); } else { if ($time == -1) { $loop_continue = false; } } } exit(0); } } } else { trigger_error('php-pcntl must be installed for the ' . self::module_name() . ' module.', E_USER_ERROR); } }
public static function test_run_process_active() { return self::$test_run_process_active = true; }