mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-23 00:55:57 +00:00
Move task timings responsibility from scheduler to handler
This commit is contained in:
parent
51f43fb375
commit
e20be3eeba
@ -48,7 +48,7 @@ class TaskHandler{
|
||||
protected $cancelled = false;
|
||||
|
||||
/** @var TimingsHandler */
|
||||
public $timings;
|
||||
private $timings;
|
||||
|
||||
/** @var string */
|
||||
private $taskName;
|
||||
@ -161,7 +161,12 @@ class TaskHandler{
|
||||
* @param int $currentTick
|
||||
*/
|
||||
public function run(int $currentTick){
|
||||
$this->task->onRun($currentTick);
|
||||
$this->timings->startTiming();
|
||||
try{
|
||||
$this->task->onRun($currentTick);
|
||||
}finally{
|
||||
$this->timings->stopTiming();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -189,14 +189,12 @@ class TaskScheduler{
|
||||
unset($this->tasks[$task->getTaskId()]);
|
||||
continue;
|
||||
}else{
|
||||
$task->timings->startTiming();
|
||||
try{
|
||||
$task->run($this->currentTick);
|
||||
}catch(\Throwable $e){
|
||||
$this->logger->critical("Could not execute task " . $task->getTaskName() . ": " . $e->getMessage());
|
||||
$this->logger->logException($e);
|
||||
}
|
||||
$task->timings->stopTiming();
|
||||
}
|
||||
if($task->isRepeating()){
|
||||
$task->setNextRun($this->currentTick + $task->getPeriod());
|
||||
|
Loading…
x
Reference in New Issue
Block a user