本文整理匯總了PHP中Scheduler::addIdleTask方法的典型用法代碼示例。如果您正苦於以下問題:PHP Scheduler::addIdleTask方法的具體用法?PHP Scheduler::addIdleTask怎麽用?PHP Scheduler::addIdleTask使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Scheduler
的用法示例。
在下文中一共展示了Scheduler::addIdleTask方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: runRichards
/**
* The Richards benchmark simulates the task dispatcher of an
* operating system.
**/
function runRichards()
{
$scheduler = new Scheduler();
$scheduler->addIdleTask(ID_IDLE, 0, NULL, COUNT);
$queue = new Packet(NULL, ID_WORKER, KIND_WORK);
$queue = new Packet($queue, ID_WORKER, KIND_WORK);
$scheduler->addWorkerTask(ID_WORKER, 1000, $queue);
$queue = new Packet(NULL, ID_DEVICE_A, KIND_DEVICE);
$queue = new Packet($queue, ID_DEVICE_A, KIND_DEVICE);
$queue = new Packet($queue, ID_DEVICE_A, KIND_DEVICE);
$scheduler->addHandlerTask(ID_HANDLER_A, 2000, $queue);
$queue = new Packet(NULL, ID_DEVICE_B, KIND_DEVICE);
$queue = new Packet($queue, ID_DEVICE_B, KIND_DEVICE);
$queue = new Packet($queue, ID_DEVICE_B, KIND_DEVICE);
$scheduler->addHandlerTask(ID_HANDLER_B, 3000, $queue);
$scheduler->addDeviceTask(ID_DEVICE_A, 4000, NULL);
$scheduler->addDeviceTask(ID_DEVICE_B, 5000, NULL);
$scheduler->schedule();
if ($scheduler->queueCount != EXPECTED_QUEUE_COUNT || $scheduler->holdCount != EXPECTED_HOLD_COUNT) {
$error = "Error during execution: queueCount = " . $scheduler->queueCount . ", holdCount = " . $scheduler->holdCount . ".";
throw new Exception($error);
}
}
示例2: function
define('ID_WORKER', 1);
define('ID_HANDLER_A', 2);
define('ID_HANDLER_B', 3);
define('ID_DEVICE_A', 4);
define('ID_DEVICE_B', 5);
define('NUMBER_OF_IDS', 6);
define('KIND_DEVICE', 0);
define('KIND_WORK', 1);
define('DATA_SIZE', 4);
/**
* The Richards benchmark simulates the task dispatcher of an
* operating system.
**/
$runRichards = function () {
$scheduler = new Scheduler();
$scheduler->addIdleTask(ID_IDLE, 0, null, COUNT);
$queue = new Packet(null, ID_WORKER, KIND_WORK);
$queue = new Packet($queue, ID_WORKER, KIND_WORK);
$scheduler->addWorkerTask(ID_WORKER, 1000, $queue);
$queue = new Packet(null, ID_DEVICE_A, KIND_DEVICE);
$queue = new Packet($queue, ID_DEVICE_A, KIND_DEVICE);
$queue = new Packet($queue, ID_DEVICE_A, KIND_DEVICE);
$scheduler->addHandlerTask(ID_HANDLER_A, 2000, $queue);
$queue = new Packet(null, ID_DEVICE_B, KIND_DEVICE);
$queue = new Packet($queue, ID_DEVICE_B, KIND_DEVICE);
$queue = new Packet($queue, ID_DEVICE_B, KIND_DEVICE);
$scheduler->addHandlerTask(ID_HANDLER_B, 3000, $queue);
$scheduler->addDeviceTask(ID_DEVICE_A, 4000, null);
$scheduler->addDeviceTask(ID_DEVICE_B, 5000, null);
$scheduler->schedule();
if ($scheduler->queueCount != EXPECTED_QUEUE_COUNT || $scheduler->holdCount != EXPECTED_HOLD_COUNT) {