mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Removed global ServerScheduler - plugins now get their own isolated schedulers
This change breaks pretty much all API pertaining to synchronous task scheduling. Significant changes: - Server->getScheduler() has been removed - Plugin->getScheduler() has been added - every plugin now has its own scheduler - Because schedulers are now per-plugin, it is now unnecessary for PluginTask to exist because stopping plugin tasks on plugin disable is as simple as destroying the plugin's scheduler. Therefore PluginTask has now been removed and it is expected for things to now use the base Task class instead. For the most part, plugins will simply need to change Plugin->getServer()->getScheduler()->... to Plugin->getScheduler()->... Another highlight is that plugin tasks now no longer have global IDs - they are unique to each scheduler.
This commit is contained in:
@ -90,7 +90,6 @@ use pocketmine\resourcepacks\ResourcePackManager;
|
||||
use pocketmine\scheduler\AsyncPool;
|
||||
use pocketmine\scheduler\FileWriteTask;
|
||||
use pocketmine\scheduler\SendUsageTask;
|
||||
use pocketmine\scheduler\ServerScheduler;
|
||||
use pocketmine\snooze\SleeperHandler;
|
||||
use pocketmine\snooze\SleeperNotifier;
|
||||
use pocketmine\tile\Tile;
|
||||
@ -149,8 +148,6 @@ class Server{
|
||||
/** @var AutoUpdater */
|
||||
private $updater = null;
|
||||
|
||||
/** @var ServerScheduler */
|
||||
private $scheduler = null;
|
||||
/** @var AsyncPool */
|
||||
private $asyncPool;
|
||||
|
||||
@ -653,13 +650,6 @@ class Server{
|
||||
return $this->resourceManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ServerScheduler
|
||||
*/
|
||||
public function getScheduler(){
|
||||
return $this->scheduler;
|
||||
}
|
||||
|
||||
public function getAsyncPool() : AsyncPool{
|
||||
return $this->asyncPool;
|
||||
}
|
||||
@ -1525,8 +1515,6 @@ class Server{
|
||||
|
||||
$this->logger->info($this->getLanguage()->translateString("pocketmine.server.start", [TextFormat::AQUA . $this->getVersion() . TextFormat::RESET]));
|
||||
|
||||
$this->scheduler = new ServerScheduler($this->logger);
|
||||
|
||||
if(($poolSize = $this->getProperty("settings.async-workers", "auto")) === "auto"){
|
||||
$poolSize = 2;
|
||||
$processors = Utils::getCoreCount() - 2;
|
||||
@ -2075,10 +2063,6 @@ class Server{
|
||||
$this->getLogger()->debug("Removing event handlers");
|
||||
HandlerList::unregisterAll();
|
||||
|
||||
if($this->scheduler instanceof ServerScheduler){
|
||||
$this->getLogger()->debug("Stopping all tasks");
|
||||
$this->scheduler->cancelAllTasks();
|
||||
}
|
||||
if($this->asyncPool instanceof AsyncPool){
|
||||
$this->getLogger()->debug("Shutting down async task worker pool");
|
||||
$this->asyncPool->shutdown();
|
||||
@ -2534,7 +2518,7 @@ class Server{
|
||||
Timings::$connectionTimer->stopTiming();
|
||||
|
||||
Timings::$schedulerTimer->startTiming();
|
||||
$this->scheduler->mainThreadHeartbeat($this->tickCounter);
|
||||
$this->pluginManager->tickSchedulers($this->tickCounter);
|
||||
Timings::$schedulerTimer->stopTiming();
|
||||
|
||||
Timings::$schedulerAsyncTimer->startTiming();
|
||||
|
Reference in New Issue
Block a user