Async thread remove on NO_THREADS

This commit is contained in:
Shoghi Cervantes 2013-08-28 17:41:01 +02:00
parent b8594ab48f
commit 549ad5eff1

View File

@ -66,8 +66,10 @@ class PocketMinecraftServer{
$this->reloadConfig(); $this->reloadConfig();
$this->stop = false; $this->stop = false;
$this->ticks = 0; $this->ticks = 0;
if(!defined("NO_THREADS")){
$this->asyncThread = new AsyncMultipleQueue(); $this->asyncThread = new AsyncMultipleQueue();
} }
}
function __construct($name, $gamemode = SURVIVAL, $seed = false, $port = 19132, $serverip = "0.0.0.0"){ function __construct($name, $gamemode = SURVIVAL, $seed = false, $port = 19132, $serverip = "0.0.0.0"){
$this->port = (int) $port; $this->port = (int) $port;
@ -188,9 +190,12 @@ class PocketMinecraftServer{
$this->stop = true; $this->stop = true;
$this->trigger("server.close", $reason); $this->trigger("server.close", $reason);
$this->interface->close(); $this->interface->close();
if(!defined("NO_THREADS")){
@$this->asyncThread->stop = true; @$this->asyncThread->stop = true;
} }
} }
}
public function setType($type = "normal"){ public function setType($type = "normal"){
switch(trim(strtolower($type))){ switch(trim(strtolower($type))){
@ -206,6 +211,9 @@ class PocketMinecraftServer{
} }
public function asyncOperation($type, array $data, callable $callable = null){ public function asyncOperation($type, array $data, callable $callable = null){
if(defined("NO_THREADS")){
return false;
}
$d = ""; $d = "";
$type = (int) $type; $type = (int) $type;
switch($type){ switch($type){
@ -229,6 +237,9 @@ class PocketMinecraftServer{
} }
public function asyncOperationChecker(){ public function asyncOperationChecker(){
if(defined("NO_THREADS")){
return false;
}
if(isset($this->asyncThread->output{5})){ if(isset($this->asyncThread->output{5})){
$offset = 0; $offset = 0;
$ID = Utils::readInt(substr($this->asyncThread->output, $offset, 4)); $ID = Utils::readInt(substr($this->asyncThread->output, $offset, 4));