mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-20 18:06:40 +00:00
This commit is contained in:
parent
eccd82ca4b
commit
6c442551f7
@ -499,10 +499,10 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
$entity->despawnFrom($this);
|
$entity->despawnFrom($this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$pk = new UnloadChunkPacket();
|
/*$pk = new UnloadChunkPacket();
|
||||||
$pk->chunkX = $x;
|
$pk->chunkX = $x;
|
||||||
$pk->chunkZ = $z;
|
$pk->chunkZ = $z;
|
||||||
$this->dataPacket($pk);
|
$this->dataPacket($pk);*/
|
||||||
$this->getLevel()->freeChunk($x, $z, $this);
|
$this->getLevel()->freeChunk($x, $z, $this);
|
||||||
unset($this->usedChunks[$index]);
|
unset($this->usedChunks[$index]);
|
||||||
|
|
||||||
@ -584,7 +584,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
$this->chunkLoadTask->setNextRun($this->chunkLoadTask->getNextRun() + 30);
|
$this->chunkLoadTask->setNextRun($this->chunkLoadTask->getNextRun() + 30);
|
||||||
}else{
|
}else{
|
||||||
$count = 0;
|
$count = 0;
|
||||||
$limit = (int) $this->server->getProperty("chunk-sending.per-tick", 1);
|
$limit = (int) $this->server->getProperty("chunk-sending.per-tick", 4);
|
||||||
foreach($this->loadQueue as $index => $distance){
|
foreach($this->loadQueue as $index => $distance){
|
||||||
if($count >= $limit){
|
if($count >= $limit){
|
||||||
break;
|
break;
|
||||||
@ -594,8 +594,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
$Z = null;
|
$Z = null;
|
||||||
Level::getXZ($index, $X, $Z);
|
Level::getXZ($index, $X, $Z);
|
||||||
if(!$this->getLevel()->isChunkPopulated($X, $Z)){
|
if(!$this->getLevel()->isChunkPopulated($X, $Z)){
|
||||||
$this->chunkLoadTask->setNextRun($this->chunkLoadTask->getNextRun() + 5);
|
continue;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($this->loadQueue[$index]);
|
unset($this->loadQueue[$index]);
|
||||||
@ -713,10 +712,10 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
$entity->despawnFrom($this);
|
$entity->despawnFrom($this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$pk = new UnloadChunkPacket();
|
/*$pk = new UnloadChunkPacket();
|
||||||
$pk->chunkX = $X;
|
$pk->chunkX = $X;
|
||||||
$pk->chunkZ = $Z;
|
$pk->chunkZ = $Z;
|
||||||
$this->dataPacket($pk);
|
$this->dataPacket($pk);*/
|
||||||
unset($this->usedChunks[$index]);
|
unset($this->usedChunks[$index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -726,17 +726,12 @@ abstract class Block extends Position implements Metadatable{
|
|||||||
* Sets the block position to a new Position object
|
* Sets the block position to a new Position object
|
||||||
*
|
*
|
||||||
* @param Position $v
|
* @param Position $v
|
||||||
*
|
|
||||||
* @throws \RuntimeException
|
|
||||||
*/
|
*/
|
||||||
final public function position(Position $v){
|
final public function position(Position $v){
|
||||||
if(!$v->isValid()){
|
|
||||||
throw new \RuntimeException("Undefined Level reference");
|
|
||||||
}
|
|
||||||
$this->x = (int) $v->x;
|
$this->x = (int) $v->x;
|
||||||
$this->y = (int) $v->y;
|
$this->y = (int) $v->y;
|
||||||
$this->z = (int) $v->z;
|
$this->z = (int) $v->z;
|
||||||
$this->setLevel($v->getLevel(), false);
|
$this->level = $v->level;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -494,7 +494,7 @@ abstract class Entity extends Position implements Metadatable{
|
|||||||
Server::broadcastPacket($this->hasSpawned, $pk);
|
Server::broadcastPacket($this->hasSpawned, $pk);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!($this instanceof Player) and ($this->lastMotionX != $this->motionX or $this->lastMotionY != $this->motionY or $this->lastMotionZ != $this->motionZ)){
|
if(($this->lastMotionX != $this->motionX or $this->lastMotionY != $this->motionY or $this->lastMotionZ != $this->motionZ)){
|
||||||
$this->lastMotionX = $this->motionX;
|
$this->lastMotionX = $this->motionX;
|
||||||
$this->lastMotionY = $this->motionY;
|
$this->lastMotionY = $this->motionY;
|
||||||
$this->lastMotionZ = $this->motionZ;
|
$this->lastMotionZ = $this->motionZ;
|
||||||
@ -504,6 +504,12 @@ abstract class Entity extends Position implements Metadatable{
|
|||||||
[$this->getID(), $this->motionX, $this->motionY, $this->motionZ]
|
[$this->getID(), $this->motionX, $this->motionY, $this->motionZ]
|
||||||
];
|
];
|
||||||
Server::broadcastPacket($this->hasSpawned, $pk);
|
Server::broadcastPacket($this->hasSpawned, $pk);
|
||||||
|
|
||||||
|
if($this instanceof Player){
|
||||||
|
$this->motionX = 0;
|
||||||
|
$this->motionY = 0;
|
||||||
|
$this->motionZ = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -640,10 +646,10 @@ abstract class Entity extends Position implements Metadatable{
|
|||||||
$entity->despawnFrom($this);
|
$entity->despawnFrom($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
$pk = new UnloadChunkPacket();
|
/*$pk = new UnloadChunkPacket();
|
||||||
$pk->chunkX = $X;
|
$pk->chunkX = $X;
|
||||||
$pk->chunkZ = $Z;
|
$pk->chunkZ = $Z;
|
||||||
$this->dataPacket($pk);
|
$this->dataPacket($pk);*/
|
||||||
}
|
}
|
||||||
$this->getLevel()->freeAllChunks($this);
|
$this->getLevel()->freeAllChunks($this);
|
||||||
}
|
}
|
||||||
|
@ -34,14 +34,8 @@ class ChunkRequestTask extends AsyncTask{
|
|||||||
protected $chunkZ;
|
protected $chunkZ;
|
||||||
protected $compressionLevel;
|
protected $compressionLevel;
|
||||||
|
|
||||||
/** @var string[4096] */
|
/** @var \pocketmine\level\format\ChunkSection[] */
|
||||||
protected $ids;
|
protected $sections;
|
||||||
/** @var string[2048] */
|
|
||||||
protected $meta;
|
|
||||||
/** @var string[2048] */
|
|
||||||
protected $blockLight;
|
|
||||||
/** @var string[2048] */
|
|
||||||
protected $skyLight;
|
|
||||||
/** @var string[256] */
|
/** @var string[256] */
|
||||||
protected $biomeIds;
|
protected $biomeIds;
|
||||||
/** @var int[] */
|
/** @var int[] */
|
||||||
@ -54,30 +48,10 @@ class ChunkRequestTask extends AsyncTask{
|
|||||||
$this->chunkX = $chunkX;
|
$this->chunkX = $chunkX;
|
||||||
$this->chunkZ = $chunkZ;
|
$this->chunkZ = $chunkZ;
|
||||||
$chunk = $level->getChunkAt($chunkX, $chunkZ);
|
$chunk = $level->getChunkAt($chunkX, $chunkZ);
|
||||||
$ids = "";
|
|
||||||
$meta = "";
|
|
||||||
$blockLight = "";
|
|
||||||
$skyLight = "";
|
|
||||||
$this->biomeIds = $chunk->getBiomeIdArray();
|
$this->biomeIds = $chunk->getBiomeIdArray();
|
||||||
$biomeColors = "";
|
$this->biomeColors = $chunk->getBiomeColorArray();
|
||||||
foreach($chunk->getBiomeColorArray() as $color){
|
|
||||||
$biomeColors .= Binary::writeInt($color);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->biomeColors = $biomeColors;
|
$this->sections = $chunk->getSections();
|
||||||
|
|
||||||
for($s = 0; $s < 8; ++$s){
|
|
||||||
$section = $chunk->getSection($s);
|
|
||||||
$ids .= $section->getIdArray();
|
|
||||||
$meta .= $section->getDataArray();
|
|
||||||
$blockLight .= $section->getLightArray();
|
|
||||||
$skyLight .= $section->getSkyLightArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->ids = $ids;
|
|
||||||
$this->meta = $meta;
|
|
||||||
$this->blockLight = $blockLight;
|
|
||||||
$this->skyLight = $skyLight;
|
|
||||||
|
|
||||||
$tiles = "";
|
$tiles = "";
|
||||||
$nbt = new NBT(NBT::LITTLE_ENDIAN);
|
$nbt = new NBT(NBT::LITTLE_ENDIAN);
|
||||||
@ -100,16 +74,33 @@ class ChunkRequestTask extends AsyncTask{
|
|||||||
$orderedSkyLight = "";
|
$orderedSkyLight = "";
|
||||||
$orderedLight = "";
|
$orderedLight = "";
|
||||||
|
|
||||||
|
$ids = "";
|
||||||
|
$meta = "";
|
||||||
|
$blockLight = "";
|
||||||
|
$skyLight = "";
|
||||||
|
$biomeColors = "";
|
||||||
|
|
||||||
|
foreach($this->sections as $section){
|
||||||
|
$ids .= $section->getIdArray();
|
||||||
|
$meta .= $section->getDataArray();
|
||||||
|
$blockLight .= $section->getLightArray();
|
||||||
|
$skyLight .= $section->getSkyLightArray();
|
||||||
|
}
|
||||||
|
|
||||||
for($x = 0; $x < 16; ++$x){
|
for($x = 0; $x < 16; ++$x){
|
||||||
for($z = 0; $z < 16; ++$z){
|
for($z = 0; $z < 16; ++$z){
|
||||||
$orderedIds .= $this->getColumn($this->ids, $x, $z);
|
$orderedIds .= $this->getColumn($ids, $x, $z);
|
||||||
$orderedData .= $this->getHalfColumn($this->meta, $x, $z);
|
$orderedData .= $this->getHalfColumn($meta, $x, $z);
|
||||||
$orderedSkyLight .= $this->getHalfColumn($this->skyLight, $x, $z);
|
$orderedSkyLight .= $this->getHalfColumn($skyLight, $x, $z);
|
||||||
$orderedLight .= $this->getHalfColumn($this->blockLight, $x, $z);
|
$orderedLight .= $this->getHalfColumn($blockLight, $x, $z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$ordered = zlib_encode(Binary::writeLInt($this->chunkX) . Binary::writeLInt($this->chunkZ) . $orderedIds . $orderedData . $orderedSkyLight . $orderedLight . $this->biomeIds . $this->biomeColors . $this->tiles, ZLIB_ENCODING_DEFLATE, $this->compressionLevel);
|
foreach($this->biomeColors as $color){
|
||||||
|
$biomeColors .= Binary::writeInt($color);
|
||||||
|
}
|
||||||
|
|
||||||
|
$ordered = zlib_encode(Binary::writeLInt($this->chunkX) . Binary::writeLInt($this->chunkZ) . $orderedIds . $orderedData . $orderedSkyLight . $orderedLight . $this->biomeIds . $biomeColors . $this->tiles, ZLIB_ENCODING_DEFLATE, $this->compressionLevel);
|
||||||
|
|
||||||
$this->setResult($ordered);
|
$this->setResult($ordered);
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@ use pocketmine\event\LevelTimings;
|
|||||||
use pocketmine\event\player\PlayerInteractEvent;
|
use pocketmine\event\player\PlayerInteractEvent;
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\level\format\Chunk;
|
use pocketmine\level\format\Chunk;
|
||||||
|
use pocketmine\level\format\generic\EmptyChunkSection;
|
||||||
use pocketmine\level\format\LevelProvider;
|
use pocketmine\level\format\LevelProvider;
|
||||||
use pocketmine\level\format\SimpleChunk;
|
use pocketmine\level\format\SimpleChunk;
|
||||||
use pocketmine\level\generator\Generator;
|
use pocketmine\level\generator\Generator;
|
||||||
@ -114,6 +115,9 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
|
|
||||||
private $folderName;
|
private $folderName;
|
||||||
|
|
||||||
|
/** @var Chunk[] */
|
||||||
|
private $chunks = [];
|
||||||
|
|
||||||
/** @var Block[][] */
|
/** @var Block[][] */
|
||||||
protected $changedBlocks = [];
|
protected $changedBlocks = [];
|
||||||
protected $changedCount = [];
|
protected $changedCount = [];
|
||||||
@ -211,7 +215,7 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
$this->chunkTickRadius = min($this->server->getViewDistance(), max(1, (int) $this->server->getProperty("chunk-ticking.tick-radius", 3)));
|
$this->chunkTickRadius = min($this->server->getViewDistance(), max(1, (int) $this->server->getProperty("chunk-ticking.tick-radius", 3)));
|
||||||
$this->chunksPerTick = (int) $this->server->getProperty("chunk-ticking.per-tick", 128);
|
$this->chunksPerTick = (int) $this->server->getProperty("chunk-ticking.per-tick", 128);
|
||||||
$this->chunkTickList = [];
|
$this->chunkTickList = [];
|
||||||
$this->clearChunksOnTick = (bool) $this->server->getProperty("chunk-ticking.clear-tick-list", true);
|
$this->clearChunksOnTick = (bool) $this->server->getProperty("chunk-ticking.clear-tick-list", false);
|
||||||
$this->timings = new LevelTimings($this);
|
$this->timings = new LevelTimings($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -501,15 +505,17 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
}
|
}
|
||||||
$chunk = $this->getChunkAt($chunkX, $chunkZ, true);
|
$chunk = $this->getChunkAt($chunkX, $chunkZ, true);
|
||||||
|
|
||||||
for($Y = 0; $Y < 8; ++$Y){
|
|
||||||
if(!$chunk->isSectionEmpty($Y)){
|
foreach($chunk->getSections() as $section){
|
||||||
$section = $chunk->getSection($Y);
|
if(!($section instanceof EmptyChunkSection)){
|
||||||
for($i = 0; $i < 3; ++$i){
|
$Y = $section->getY();
|
||||||
$k = mt_rand(0, PHP_INT_MAX);
|
$k = mt_rand(0, PHP_INT_MAX);
|
||||||
|
for($i = 0; $i < 3; ++$i){
|
||||||
$j = $k >> 2;
|
$j = $k >> 2;
|
||||||
$x = $j & 0x0f;
|
$x = $j & 0x0f;
|
||||||
$y = ($j >> 8) & 0x0f;
|
$y = ($j >> 8) & 0x0f;
|
||||||
$z = ($j >> 16) & 0x0f;
|
$z = ($j >> 16) & 0x0f;
|
||||||
|
$k %= 1073741827;
|
||||||
$blockId = $section->getBlockId($x, $y, $z);
|
$blockId = $section->getBlockId($x, $y, $z);
|
||||||
if(isset($this->randomTickBlocks[$blockId])){
|
if(isset($this->randomTickBlocks[$blockId])){
|
||||||
$block = Block::get($blockId, $section->getBlockData($x, $y, $z), new Position($chunkX * 16 + $x, $Y * 16 + $y, $chunkZ * 16 + $z, $this));
|
$block = Block::get($blockId, $section->getBlockData($x, $y, $z), new Position($chunkX * 16 + $x, $Y * 16 + $y, $chunkZ * 16 + $z, $this));
|
||||||
@ -1236,7 +1242,7 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
* @return Chunk
|
* @return Chunk
|
||||||
*/
|
*/
|
||||||
public function getChunkAt($x, $z, $create = false){
|
public function getChunkAt($x, $z, $create = false){
|
||||||
return $this->provider->getChunk($x, $z, $create);
|
return isset($this->chunks[$index = "$x:$z"]) ? $this->chunks[$index] : $this->chunks[$index] = $this->provider->getChunk($x, $z, $create);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1272,7 +1278,9 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
foreach($this->getUsingChunk($x, $z) as $player){
|
foreach($this->getUsingChunk($x, $z) as $player){
|
||||||
$player->unloadChunk($x, $z);
|
$player->unloadChunk($x, $z);
|
||||||
}
|
}
|
||||||
|
unset($this->chunks[Level::chunkHash($x, $z)]);
|
||||||
$this->provider->setChunk($x, $z, $chunk);
|
$this->provider->setChunk($x, $z, $chunk);
|
||||||
|
$this->loadChunk($x, $z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1298,7 +1306,7 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isChunkLoaded($x, $z){
|
public function isChunkLoaded($x, $z){
|
||||||
return $this->provider->isChunkLoaded($x, $z);
|
return isset($this->chunks["$x:$z"]) or $this->provider->isChunkLoaded($x, $z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1488,13 +1496,18 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
|
|
||||||
$chunk = $this->provider->getChunk($x, $z, false);
|
$chunk = $this->provider->getChunk($x, $z, false);
|
||||||
if($chunk instanceof Chunk){
|
if($chunk instanceof Chunk){
|
||||||
|
$this->chunks[Level::chunkHash($x, $z)] = $chunk;
|
||||||
return true;
|
return true;
|
||||||
}else{
|
}else{
|
||||||
$this->timings->syncChunkLoadTimer->startTiming();
|
$this->timings->syncChunkLoadTimer->startTiming();
|
||||||
$this->provider->loadChunk($x, $z);
|
$this->provider->loadChunk($x, $z);
|
||||||
$this->timings->syncChunkLoadTimer->stopTiming();
|
$this->timings->syncChunkLoadTimer->stopTiming();
|
||||||
|
|
||||||
return $this->provider->getChunk($x, $z) instanceof Chunk;
|
if(($chunk = $this->provider->getChunk($x, $z)) instanceof Chunk){
|
||||||
|
$this->chunks[Level::chunkHash($x, $z)] = $chunk;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1522,8 +1535,9 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
}
|
}
|
||||||
$this->timings->doChunkUnload->startTiming();
|
$this->timings->doChunkUnload->startTiming();
|
||||||
|
|
||||||
|
unset($this->chunks[$index = Level::chunkHash($x, $z)]);
|
||||||
$this->provider->unloadChunk($x, $z, $safe);
|
$this->provider->unloadChunk($x, $z, $safe);
|
||||||
unset($this->usedChunks[Level::chunkHash($x, $z)]);
|
unset($this->usedChunks[$index]);
|
||||||
Cache::remove("world:" . $this->getID() . ":$x:$z");
|
Cache::remove("world:" . $this->getID() . ":$x:$z");
|
||||||
|
|
||||||
$this->timings->doChunkUnload->stopTiming();
|
$this->timings->doChunkUnload->stopTiming();
|
||||||
|
@ -19,14 +19,14 @@ debug:
|
|||||||
commands: false
|
commands: false
|
||||||
|
|
||||||
chunk-sending:
|
chunk-sending:
|
||||||
per-tick: 1
|
per-tick: 4
|
||||||
compression-level: 7
|
compression-level: 9
|
||||||
|
|
||||||
chunk-ticking:
|
chunk-ticking:
|
||||||
per-tick: 80
|
per-tick: 80
|
||||||
tick-radius: 2
|
tick-radius: 2
|
||||||
light-updates: false
|
light-updates: false
|
||||||
clear-tick-list: true
|
clear-tick-list: false
|
||||||
|
|
||||||
chunk-gc:
|
chunk-gc:
|
||||||
period-in-ticks: 600
|
period-in-ticks: 600
|
||||||
|
@ -29,22 +29,18 @@ use pocketmine\Server;
|
|||||||
*/
|
*/
|
||||||
abstract class AsyncTask extends \Threaded{
|
abstract class AsyncTask extends \Threaded{
|
||||||
|
|
||||||
private $complete = null;
|
public $complete = null;
|
||||||
private $finished = null;
|
public $finished = null;
|
||||||
private $result = null;
|
public $result = null;
|
||||||
|
|
||||||
public function run(){
|
public function run(){
|
||||||
$this->lock();
|
|
||||||
$this->finished = false;
|
$this->finished = false;
|
||||||
$this->complete = false;
|
$this->complete = false;
|
||||||
$this->result = null;
|
$this->result = null;
|
||||||
$this->unlock();
|
|
||||||
|
|
||||||
$this->onRun();
|
$this->onRun();
|
||||||
|
|
||||||
$this->lock();
|
|
||||||
$this->finished = true;
|
$this->finished = true;
|
||||||
$this->unlock();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +48,6 @@ abstract class AsyncTask extends \Threaded{
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isFinished(){
|
public function isFinished(){
|
||||||
|
|
||||||
return $this->finished === true;
|
return $this->finished === true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,6 +83,14 @@ abstract class AsyncTask extends \Threaded{
|
|||||||
$this->result = @serialize($result);
|
$this->result = @serialize($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setTaskId($taskId){
|
||||||
|
$this->taskId = $taskId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTaskId(){
|
||||||
|
return $this->taskId;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Actions to execute when run
|
* Actions to execute when run
|
||||||
*
|
*
|
||||||
|
@ -77,8 +77,10 @@ class ServerScheduler{
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function scheduleAsyncTask(AsyncTask $task){
|
public function scheduleAsyncTask(AsyncTask $task){
|
||||||
|
$id = $this->nextId();
|
||||||
|
$task->setTaskId($id);
|
||||||
$this->asyncPool->submit($task);
|
$this->asyncPool->submit($task);
|
||||||
$this->asyncTaskStorage[spl_object_hash($task)] = $task;
|
$this->asyncTaskStorage[$id] = $task;
|
||||||
++$this->asyncTasks;
|
++$this->asyncTasks;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,6 +224,12 @@ class ServerScheduler{
|
|||||||
|
|
||||||
if($this->asyncTasks > 0){ //Garbage collector
|
if($this->asyncTasks > 0){ //Garbage collector
|
||||||
$this->asyncPool->collect([$this, "collectAsyncTask"]);
|
$this->asyncPool->collect([$this, "collectAsyncTask"]);
|
||||||
|
|
||||||
|
foreach($this->asyncTaskStorage as $asyncTask){
|
||||||
|
if($asyncTask->isFinished() and !$asyncTask->isCompleted()){
|
||||||
|
$this->collectAsyncTask($asyncTask);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,7 +238,7 @@ class ServerScheduler{
|
|||||||
--$this->asyncTasks;
|
--$this->asyncTasks;
|
||||||
$task->onCompletion(Server::getInstance());
|
$task->onCompletion(Server::getInstance());
|
||||||
$task->setCompleted();
|
$task->setCompleted();
|
||||||
unset($this->asyncTaskStorage[spl_object_hash($task)]);
|
unset($this->asyncTaskStorage[$task->getTaskId()]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user