Improved CallbackTask timings data

This commit is contained in:
Shoghi Cervantes 2014-09-01 12:44:52 +02:00
parent ff48eb3d4d
commit 11f684d803
3 changed files with 20 additions and 1 deletions

View File

@ -1920,6 +1920,7 @@ class Server{
$lastLoop = 0;
$connectionTimer = Timings::$connectionTimer;
while($this->isRunning){
//TODO: move this to tick
$connectionTimer->startTiming();
foreach($this->interfaces as $interface){
if($interface->process()){

View File

@ -45,6 +45,13 @@ class CallbackTask extends Task{
$this->args[] = $this;
}
/**
* @return callable
*/
public function getCallable(){
return $this->callable;
}
public function onRun($currentTicks){
call_user_func_array($this->callable, $this->args);
}

View File

@ -184,7 +184,18 @@ class ServerScheduler{
$period = 1;
}
return $this->handle(new TaskHandler(get_class($task), $task, $this->nextId(), $delay, $period));
if($task instanceof CallbackTask){
$callable = $task->getCallable();
if(is_array($callable)){
$taskName = "Callback#" . get_class($callable[0]) . "::" . $callable[1];
}else{
$taskName = "Callback#" . $callable;
}
}else{
$taskName = get_class($task);
}
return $this->handle(new TaskHandler($taskName, $task, $this->nextId(), $delay, $period));
}
private function handle(TaskHandler $handler){