mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
Added extra memory reportings (heap, stack), stop tasks faster, added extra timeouts fro ServerKiller
This commit is contained in:
@ -122,6 +122,7 @@ class AsyncPool{
|
||||
public function removeTasks(){
|
||||
do{
|
||||
foreach($this->tasks as $task){
|
||||
$task->cancelRun();
|
||||
$this->removeTask($task);
|
||||
}
|
||||
|
||||
@ -144,7 +145,9 @@ class AsyncPool{
|
||||
foreach($this->tasks as $task){
|
||||
if($task->isGarbage() and !$task->isRunning()){
|
||||
|
||||
$task->onCompletion($this->server);
|
||||
if(!$task->hasCancelledRun()){
|
||||
$task->onCompletion($this->server);
|
||||
}
|
||||
|
||||
$this->removeTask($task);
|
||||
}elseif($task->isTerminated()){
|
||||
|
@ -35,13 +35,16 @@ abstract class AsyncTask extends \Collectable{
|
||||
|
||||
private $result = null;
|
||||
private $serialized = false;
|
||||
private $cancelRun = false;
|
||||
/** @var int */
|
||||
private $taskId = null;
|
||||
|
||||
public function run(){
|
||||
$this->result = null;
|
||||
|
||||
$this->onRun();
|
||||
if($this->cancelRun !== true){
|
||||
$this->onRun();
|
||||
}
|
||||
|
||||
$this->setGarbage();
|
||||
}
|
||||
@ -62,6 +65,14 @@ abstract class AsyncTask extends \Collectable{
|
||||
return $this->serialized ? unserialize($this->result) : $this->result;
|
||||
}
|
||||
|
||||
public function cancelRun(){
|
||||
$this->cancelRun = true;
|
||||
}
|
||||
|
||||
public function hasCancelledRun(){
|
||||
return $this->cancelRun === true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
|
@ -139,7 +139,7 @@ class SendUsageTask extends AsyncTask{
|
||||
|
||||
public function onRun(){
|
||||
try{
|
||||
Utils::postURL($this->endpoint, $this->data, 10, [
|
||||
Utils::postURL($this->endpoint, $this->data, 5, [
|
||||
"Content-Type: application/json",
|
||||
"Content-Length: ". strlen($this->data)
|
||||
]);
|
||||
|
Reference in New Issue
Block a user