mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 08:44:01 +00:00
More unloading
This commit is contained in:
parent
1c341337a3
commit
9a2934b85b
@ -26,6 +26,7 @@
|
||||
namespace PocketMine;
|
||||
|
||||
use PocketMine\Block\Block;
|
||||
use PocketMine\Command\CommandReader;
|
||||
use PocketMine\Command\CommandSender;
|
||||
use PocketMine\Command\ConsoleCommandSender;
|
||||
use PocketMine\Command\PluginCommand;
|
||||
@ -320,6 +321,8 @@ class Server{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last server TPS measure
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getTicksPerSecond(){
|
||||
@ -660,6 +663,8 @@ class Server{
|
||||
$this->tickProcessor();
|
||||
}
|
||||
|
||||
$this->pluginManager->disablePlugins();
|
||||
|
||||
foreach(Player::getAll() as $player){
|
||||
$player->kick("server stop");
|
||||
}
|
||||
@ -668,10 +673,10 @@ class Server{
|
||||
$level->unload(true);
|
||||
}
|
||||
|
||||
$this->pluginManager->disablePlugins();
|
||||
|
||||
$this->scheduler->shutdown();
|
||||
$this->tickScheduler->kill();
|
||||
$this->console->kill();
|
||||
//TODO: kill scheduler
|
||||
|
||||
}
|
||||
|
||||
private function tickProcessorWindows(){
|
||||
@ -801,18 +806,10 @@ class Server{
|
||||
|
||||
public function titleTick(){
|
||||
if(defined("PocketMine\\DEBUG") and \PocketMine\DEBUG >= 0 and \PocketMine\ANSI === true){
|
||||
echo "\x1b]0;PocketMine-MP " . $this->getPocketMineVersion() . " | Online " . count(Player::$list) . "/" . $this->getMaxPlayers() . " | RAM " . round((memory_get_usage() / 1024) / 1024, 2) . "/" . round((memory_get_usage(true) / 1024) / 1024, 2) . " MB | U " . round($this->interface->getUploadSpeed() / 1024, 2) . " D " . round($this->interface->getDownloadSpeed() / 1024, 2) . " kB/s | TPS " . $this->getTPS() . "\x07";
|
||||
echo "\x1b]0;PocketMine-MP " . $this->getPocketMineVersion() . " | Online " . count(Player::$list) . "/" . $this->getMaxPlayers() . " | RAM " . round((memory_get_usage() / 1024) / 1024, 2) . "/" . round((memory_get_usage(true) / 1024) / 1024, 2) . " MB | U " . round($this->interface->getUploadSpeed() / 1024, 2) . " D " . round($this->interface->getDownloadSpeed() / 1024, 2) . " kB/s | TPS " . $this->getTicksPerSecond() . "\x07";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last server TPS measure
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getTPS(){
|
||||
return $this->tickScheduler->getTPS();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to execute a server tick
|
||||
|
@ -19,7 +19,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
namespace PocketMine;
|
||||
namespace PocketMine\Command;
|
||||
|
||||
class CommandReader extends \Thread{
|
||||
|
@ -26,17 +26,17 @@ class ServerAllTaskCanceller extends \Threaded{
|
||||
/**
|
||||
* @var ServerTask[]
|
||||
*/
|
||||
protected $temp;
|
||||
public $temp;
|
||||
|
||||
/**
|
||||
* @var ServerTask[]
|
||||
*/
|
||||
protected $pending;
|
||||
public $pending;
|
||||
|
||||
/**
|
||||
* @var ServerTask[]
|
||||
*/
|
||||
protected $runners;
|
||||
public $runners;
|
||||
|
||||
public function __construct($temp, $pending, $runners){
|
||||
$this->temp = $temp;
|
||||
|
@ -28,22 +28,22 @@ class ServerPluginTaskCanceller extends \Threaded{
|
||||
/**
|
||||
* @var Plugin
|
||||
*/
|
||||
protected $plugin;
|
||||
public $plugin;
|
||||
|
||||
/**
|
||||
* @var ServerTask[]
|
||||
*/
|
||||
protected $temp;
|
||||
public $temp;
|
||||
|
||||
/**
|
||||
* @var ServerTask[]
|
||||
*/
|
||||
protected $pending;
|
||||
public $pending;
|
||||
|
||||
/**
|
||||
* @var ServerTask[]
|
||||
*/
|
||||
protected $runners;
|
||||
public $runners;
|
||||
|
||||
public function __construct(Plugin $plugin, $temp, $pending, $runners){
|
||||
$this->plugin = $plugin;
|
||||
|
@ -22,6 +22,7 @@
|
||||
namespace PocketMine\Scheduler;
|
||||
|
||||
use PocketMine\Plugin\Plugin;
|
||||
use PocketMine\Server;
|
||||
|
||||
class ServerScheduler{
|
||||
|
||||
@ -88,6 +89,11 @@ class ServerScheduler{
|
||||
|
||||
}
|
||||
|
||||
public function shutdown(){
|
||||
$this->mainThreadHeartbeat($this->currentTick + 1);
|
||||
$this->executor->shutdown();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Plugin $plugin
|
||||
* @param \Threaded $task
|
||||
@ -255,7 +261,6 @@ class ServerScheduler{
|
||||
$this->runners[$taskId]->cancel0();
|
||||
}
|
||||
|
||||
//TODO
|
||||
$task = new ServerTask(null, new ServerTaskCanceller($taskId, $this->temp, $this->pending, $this->runners));
|
||||
$this->handle($task, 0);
|
||||
for($taskPending = $this->head->getNext(); $taskPending !== null; $taskPending = $taskPending->getNext()){
|
||||
@ -276,7 +281,6 @@ class ServerScheduler{
|
||||
return;
|
||||
}
|
||||
|
||||
//TODO
|
||||
$task = new ServerTask(null, new ServerPluginTaskCanceller($plugin, $this->temp, $this->pending, $this->runners));
|
||||
$this->handle($task, 0);
|
||||
for($taskPending = $this->head->getNext(); $taskPending !== null; $taskPending = $taskPending->getNext()){
|
||||
@ -299,7 +303,6 @@ class ServerScheduler{
|
||||
*
|
||||
*/
|
||||
public function cancelAllTasks(){
|
||||
//TODO
|
||||
$task = new ServerTask(null, new ServerAllTaskCanceller($this->temp, $this->pending, $this->runners));
|
||||
$this->handle($task, 0);
|
||||
for($taskPending = $this->head->getNext(); $taskPending !== null; $taskPending = $taskPending->getNext()){
|
||||
@ -407,6 +410,7 @@ class ServerScheduler{
|
||||
public function mainThreadHeartbeat($currentTick){
|
||||
$this->currentTick = $currentTick;
|
||||
$this->parsePending();
|
||||
|
||||
while($this->isReady($currentTick)){
|
||||
$task = $this->pending->extract();
|
||||
if($task->getPeriod() < -1){
|
||||
@ -444,6 +448,7 @@ class ServerScheduler{
|
||||
*/
|
||||
private function addTask(ServerTask $task){
|
||||
$this->tail->setNext($task);
|
||||
$this->tail = $task;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -22,21 +22,21 @@
|
||||
namespace PocketMine\Scheduler;
|
||||
|
||||
class ServerTaskCanceller extends \Threaded{
|
||||
protected $taskId;
|
||||
public $taskId;
|
||||
/**
|
||||
* @var ServerTask[]
|
||||
*/
|
||||
protected $temp;
|
||||
public $temp;
|
||||
|
||||
/**
|
||||
* @var ServerTask[]
|
||||
*/
|
||||
protected $pending;
|
||||
public $pending;
|
||||
|
||||
/**
|
||||
* @var ServerTask[]
|
||||
*/
|
||||
protected $runners;
|
||||
public $runners;
|
||||
|
||||
public function __construct($taskId, $temp, $pending, $runners){
|
||||
$this->taskId = $taskId;
|
||||
|
@ -23,6 +23,7 @@ namespace PocketMine\Scheduler;
|
||||
|
||||
class TaskPool extends \Pool{
|
||||
public function __construct($workers){
|
||||
$this->workers = array();
|
||||
parent::__construct((int) $workers, "PocketMine\\Scheduler\\TaskWorker");
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user