mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
Base PHP7 work to make it "run" - READ NEXT LINES!
All plugins will need to bump the API if they want to use this. NOTE THAT THIS IS NOT THE FINAL API 2.0.0 AND THAT THERE WILL BE MORE CHANGES. To start updating, you might also want to read https://secure.php.net/manual/en/migration70.php and specifically https://secure.php.net/manual/en/migration70.incompatible.php To compile PHP7 with some of the required dependencies, use https://gist.github.com/shoghicp/166ab26ce5cc7a390f45 ONLY LINUX IS TESTED, DO NOT ASK FOR OTHER PLATFORMS! ----- THIS VERSION IS NOT SUPPORTED ----- This version WILL crash randomly in unexpected places due to PHP7, pthreads, PocketMine or cosmic rays. Handle with care, and store under direct sunlight for the best performance.
This commit is contained in:
@ -109,8 +109,7 @@ class AsyncPool{
|
||||
if(!$force and ($task->isRunning() or !$task->isGarbage())){
|
||||
return;
|
||||
}
|
||||
$this->workers[$w = $this->taskWorkers[$task->getTaskId()]]->unstack($task);
|
||||
$this->workerUsage[$w]--;
|
||||
$this->workerUsage[$this->taskWorkers[$task->getTaskId()]]--;
|
||||
}
|
||||
|
||||
unset($this->tasks[$task->getTaskId()]);
|
||||
@ -127,7 +126,7 @@ class AsyncPool{
|
||||
}
|
||||
|
||||
if(count($this->tasks) > 0){
|
||||
usleep(25000);
|
||||
Server::microSleep(25000);
|
||||
}
|
||||
}while(count($this->tasks) > 0);
|
||||
|
||||
|
@ -144,7 +144,9 @@ abstract class AsyncTask extends \Collectable{
|
||||
|
||||
public function cleanObject(){
|
||||
foreach($this as $p => $v){
|
||||
$this->{$p} = null;
|
||||
if(!($v instanceof \Threaded)){
|
||||
$this->{$p} = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ class AsyncWorker extends Worker{
|
||||
|
||||
}
|
||||
|
||||
public function start($options = PTHREADS_INHERIT_NONE){
|
||||
public function start(int $options = PTHREADS_INHERIT_NONE){
|
||||
parent::start(PTHREADS_INHERIT_CONSTANTS | PTHREADS_INHERIT_FUNCTIONS);
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ class FileWriteTask extends AsyncTask{
|
||||
public function onRun(){
|
||||
try{
|
||||
file_put_contents($this->path, $this->contents, (int) $this->flags);
|
||||
}catch (\Exception $e){
|
||||
}catch (\Throwable $e){
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ class SendUsageTask extends AsyncTask{
|
||||
"Content-Type: application/json",
|
||||
"Content-Length: ". strlen($this->data)
|
||||
]);
|
||||
}catch(\Exception $e){
|
||||
}catch(\Throwable $e){
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -160,7 +160,9 @@ class ServerScheduler{
|
||||
}
|
||||
$this->tasks = [];
|
||||
$this->asyncPool->removeTasks();
|
||||
$this->queue = new ReversePriorityQueue();
|
||||
while(!$this->queue->isEmpty()){
|
||||
$this->queue->extract();
|
||||
}
|
||||
$this->ids = 1;
|
||||
}
|
||||
|
||||
@ -245,7 +247,7 @@ class ServerScheduler{
|
||||
$task->timings->startTiming();
|
||||
try{
|
||||
$task->run($this->currentTick);
|
||||
}catch(\Exception $e){
|
||||
}catch(\Throwable $e){
|
||||
Server::getInstance()->getLogger()->critical("Could not execute task " . $task->getTaskName() . ": " . $e->getMessage());
|
||||
$logger = Server::getInstance()->getLogger();
|
||||
if($logger instanceof MainLogger){
|
||||
|
Reference in New Issue
Block a user