本文整理汇总了PHP中Queue::run方法的典型用法代码示例。如果您正苦于以下问题:PHP Queue::run方法的具体用法?PHP Queue::run怎么用?PHP Queue::run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Queue
的用法示例。
在下文中一共展示了Queue::run方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$id = array_shift($this->args);
$this->out('Running ' . $id);
if (Queue::run($id)) {
$this->out('Success.');
$this->out(Queue::view($id));
$this->out();
} else {
$this->out('Failed to run task. Check logs.');
}
}
示例2: testDifferentCallbacks
public function testDifferentCallbacks()
{
$type = 'test5';
$dataIn1 = "testString1251in";
$dataIn2 = "testString1252in";
$dataOut1 = "testString1251out";
$dataOut2 = "testString1252out";
$runCallback1 = function (InputMessage $inputMessage) use($dataOut1) {
return new OutputMessage($dataOut1);
};
$runCallback2 = function (InputMessage $inputMessage) use($dataOut2) {
return new OutputMessage($dataOut2);
};
$inputMessage1 = new InputMessage($dataIn1);
$identifier1 = $this->queueClient->submitInput($type, $inputMessage1);
$this->queueServer->run($type, $runCallback1);
$outputMessage1 = $this->queueClient->getOutput($type, $identifier1);
$inputMessage2 = new InputMessage($dataIn2);
$identifier2 = $this->queueClient->submitInput($type, $inputMessage2);
$this->queueServer->run($type, $runCallback2);
$outputMessage2 = $this->queueClient->getOutput($type, $identifier2);
$this->assertEquals($dataOut1, $outputMessage1->getData());
$this->assertEquals($dataOut2, $outputMessage2->getData());
}
示例3: run
{
$this->commands[] = $command;
}
public function run()
{
while (!is_null($command = $this->next())) {
$command->execute();
}
}
private function next()
{
if (count($this->commands) === 0 || count($this->commands) <= $this->current_index) {
return null;
} else {
return $this->commands[$this->current_index++];
}
}
}
/**
* Client
*/
$queue = new Queue();
//Invoker
$file = new File("sample.txt");
//Reciever
$queue->addCommand(new TouchCommand($file));
//Command
$queue->addCommand(new CompressCommand($file));
$queue->addCommand(new CopyCommand($file));
$queue->run();