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