mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-16 02:38:54 +00:00
Added settings.async-workers to tune the amount of AsyncTask workers
This commit is contained in:
parent
7f795bc041
commit
bf49cafeae
@ -1322,7 +1322,6 @@ class Server{
|
||||
$this->banByIP = new BanList($this->dataPath . "banned-ips.txt");
|
||||
$this->banByIP->load();
|
||||
|
||||
$this->scheduler = new ServerScheduler();
|
||||
$this->console = new CommandReader();
|
||||
|
||||
$version = new VersionString($this->getPocketMineVersion());
|
||||
@ -1359,6 +1358,10 @@ class Server{
|
||||
"auto-save" => true,
|
||||
));
|
||||
|
||||
ServerScheduler::$WORKERS = $this->getProperty("settings.async-workers", ServerScheduler::$WORKERS);
|
||||
|
||||
$this->scheduler = new ServerScheduler();
|
||||
|
||||
if($this->getConfigBoolean("enable-rcon", false) === true){
|
||||
$this->rcon = new RCON($this->getConfigString("rcon.password", ""), $this->getConfigInt("rcon.port", $this->getPort()), ($ip = $this->getIp()) != "" ? $ip : "0.0.0.0", $this->getConfigInt("rcon.threads", 1), $this->getConfigInt("rcon.clients-per-thread", 50));
|
||||
}
|
||||
@ -1679,7 +1682,7 @@ class Server{
|
||||
$this->logger->info("Default game type: " . self::getGamemodeString($this->getGamemode())); //TODO: string name
|
||||
|
||||
$this->logger->info("Done (" . round(microtime(true) - \pocketmine\START_TIME, 3) . 's)! For help, type "help" or "?"');
|
||||
$this->scheduler->scheduleAsyncTask(new ExampleTask());
|
||||
|
||||
if(Utils::getOS() === "win"){ //Workaround less usleep() waste
|
||||
$this->tickProcessorWindows();
|
||||
}else{
|
||||
|
@ -7,6 +7,7 @@ settings:
|
||||
advanced-cache: false
|
||||
upnp-forwarding: false
|
||||
send-usage: true
|
||||
async-workers: 3
|
||||
|
||||
debug:
|
||||
#If > 1, it will show debug messages in the console
|
||||
|
@ -24,13 +24,10 @@ namespace pocketmine\scheduler;
|
||||
class AsyncWorker extends \Worker{
|
||||
public $path;
|
||||
|
||||
public function __construct(){
|
||||
public function start($options = PTHREADS_INHERIT_ALL){
|
||||
$this->path = \pocketmine\PATH;
|
||||
return parent::start(PTHREADS_INHERIT_ALL & ~PTHREADS_INHERIT_CLASSES);
|
||||
}
|
||||
|
||||
public function start(){
|
||||
|
||||
return parent::start($options & ~PTHREADS_INHERIT_CLASSES);
|
||||
}
|
||||
|
||||
public function run(){
|
||||
|
@ -28,7 +28,7 @@ use pocketmine\plugin\Plugin;
|
||||
use pocketmine\utils\ReversePriorityQueue;
|
||||
|
||||
class ServerScheduler{
|
||||
protected static $WORKERS = 3;
|
||||
public static $WORKERS = 3;
|
||||
/**
|
||||
* @var ReversePriorityQueue<Task>
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user