Implemented global, tasks timings

This commit is contained in:
Shoghi Cervantes
2014-07-12 14:09:29 +02:00
parent 0bfa9506d1
commit 9bdd294a66
8 changed files with 348 additions and 14 deletions

View File

@ -178,7 +178,7 @@ class ServerScheduler{
$period = 1;
}
return $this->handle(new TaskHandler($task, $this->nextId(), $delay, $period));
return $this->handle(new TaskHandler(!($task instanceof PluginTask) ? "Scheduler" : null, $task, $this->nextId(), $delay, $period));
}
private function handle(TaskHandler $handler){
@ -201,12 +201,15 @@ class ServerScheduler{
public function mainThreadHeartbeat($currentTick){
$this->currentTick = $currentTick;
while($this->isReady($this->currentTick)){
/** @var TaskHandler $task */
$task = $this->queue->extract();
if($task->isCancelled()){
unset($this->tasks[$task->getTaskId()]);
continue;
}else{
$task->timings->startTiming();
$task->run($this->currentTick);
$task->timings->stopTiming();
}
if($task->isRepeating()){
$task->setNextRun($this->currentTick + $task->getPeriod());