NOTE! THIS SHOULD BE REVERTED LATER! Removed WeakRef dependency

This commit is contained in:
Shoghi Cervantes 2015-08-12 21:14:39 +02:00
parent d7d05c20a9
commit 34dc6ea0d6
5 changed files with 11 additions and 20 deletions

View File

@ -55,13 +55,6 @@ class MemoryManager{
private $chunkCache; private $chunkCache;
private $cacheTrigger; private $cacheTrigger;
/** @var \WeakRef[] */
private $leakWatch = [];
private $leakInfo = [];
private $leakSeed = 0;
public function __construct(Server $server){ public function __construct(Server $server){
$this->server = $server; $this->server = $server;

View File

@ -410,11 +410,6 @@ namespace pocketmine {
} }
} }
if(!extension_loaded("Weakref") and !extension_loaded("weakref")){
$logger->critical("Unable to find the Weakref extension.");
++$errors;
}
if(!extension_loaded("curl")){ if(!extension_loaded("curl")){
$logger->critical("Unable to find the cURL extension."); $logger->critical("Unable to find the cURL extension.");
++$errors; ++$errors;

View File

@ -29,7 +29,7 @@ use pocketmine\utils\PluginException;
abstract class MetadataStore{ abstract class MetadataStore{
/** @var \WeakMap[] */ /** @var \WeakMap[] */
private $metadataMap = []; private $metadataMap;
/** /**
* Adds a metadata value to an object. * Adds a metadata value to an object.
@ -48,8 +48,8 @@ abstract class MetadataStore{
$key = $this->disambiguate($subject, $metadataKey); $key = $this->disambiguate($subject, $metadataKey);
if(!isset($this->metadataMap[$key])){ if(!isset($this->metadataMap[$key])){
$entry = new \WeakMap(); //$entry = new \WeakMap();
$this->metadataMap[$key] = $entry; $this->metadataMap[$key] = new \SplObjectStorage();//$entry;
}else{ }else{
$entry = $this->metadataMap[$key]; $entry = $this->metadataMap[$key];
} }

View File

@ -28,14 +28,14 @@ abstract class MetadataValue{
private $owningPlugin; private $owningPlugin;
protected function __construct(Plugin $owningPlugin){ protected function __construct(Plugin $owningPlugin){
$this->owningPlugin = new \WeakRef($owningPlugin); $this->owningPlugin = $owningPlugin;
} }
/** /**
* @return Plugin * @return Plugin
*/ */
public function getOwningPlugin(){ public function getOwningPlugin(){
return $this->owningPlugin->get(); return $this->owningPlugin;
} }
/** /**

View File

@ -433,7 +433,7 @@ class PluginManager{
if(!isset($this->permSubs[$permission])){ if(!isset($this->permSubs[$permission])){
$this->permSubs[$permission] = []; $this->permSubs[$permission] = [];
} }
$this->permSubs[$permission][spl_object_hash($permissible)] = new \WeakRef($permissible); $this->permSubs[$permission][spl_object_hash($permissible)] = $permissible;
} }
/** /**
@ -456,6 +456,7 @@ class PluginManager{
*/ */
public function getPermissionSubscriptions($permission){ public function getPermissionSubscriptions($permission){
if(isset($this->permSubs[$permission])){ if(isset($this->permSubs[$permission])){
return $this->permSubs[$permission];
$subs = []; $subs = [];
foreach($this->permSubs[$permission] as $k => $perm){ foreach($this->permSubs[$permission] as $k => $perm){
/** @var \WeakRef $perm */ /** @var \WeakRef $perm */
@ -479,9 +480,9 @@ class PluginManager{
*/ */
public function subscribeToDefaultPerms($op, Permissible $permissible){ public function subscribeToDefaultPerms($op, Permissible $permissible){
if($op === true){ if($op === true){
$this->defSubsOp[spl_object_hash($permissible)] = new \WeakRef($permissible); $this->defSubsOp[spl_object_hash($permissible)] = $permissible;
}else{ }else{
$this->defSubs[spl_object_hash($permissible)] = new \WeakRef($permissible); $this->defSubs[spl_object_hash($permissible)] = $permissible;
} }
} }
@ -506,6 +507,7 @@ class PluginManager{
$subs = []; $subs = [];
if($op === true){ if($op === true){
return $this->defSubsOp;
foreach($this->defSubsOp as $k => $perm){ foreach($this->defSubsOp as $k => $perm){
/** @var \WeakRef $perm */ /** @var \WeakRef $perm */
if($perm->acquire()){ if($perm->acquire()){
@ -516,6 +518,7 @@ class PluginManager{
} }
} }
}else{ }else{
return $this->defSubs;
foreach($this->defSubs as $k => $perm){ foreach($this->defSubs as $k => $perm){
/** @var \WeakRef $perm */ /** @var \WeakRef $perm */
if($perm->acquire()){ if($perm->acquire()){