Bumped to API 2.0.0

This commit is contained in:
Shoghi Cervantes 2015-08-12 21:04:51 +02:00
parent fabb632286
commit d7d05c20a9
3 changed files with 3 additions and 84 deletions

View File

@ -214,87 +214,6 @@ class MemoryManager{
return $cycles;
}
/**
* @param object $object
*
* @return string Object identifier for future checks
*/
public function addObjectWatcher($object){
if(!is_object($object)){
throw new \InvalidArgumentException("Not an object!");
}
$identifier = spl_object_hash($object) . ":" . get_class($object);
if(isset($this->leakInfo[$identifier])){
return $this->leakInfo["id"];
}
$this->leakInfo[$identifier] = [
"id" => $id = md5($identifier . ":" . $this->leakSeed++),
"class" => get_class($object),
"hash" => $identifier
];
$this->leakInfo[$id] = $this->leakInfo[$identifier];
$this->leakWatch[$id] = new \WeakRef($object);
return $id;
}
public function isObjectAlive($id){
if(isset($this->leakWatch[$id])){
return $this->leakWatch[$id]->valid();
}
return false;
}
public function removeObjectWatch($id){
if(!isset($this->leakWatch[$id])){
return;
}
unset($this->leakInfo[$this->leakInfo[$id]["hash"]]);
unset($this->leakInfo[$id]);
unset($this->leakWatch[$id]);
}
public function doObjectCleanup(){
foreach($this->leakWatch as $id => $w){
if(!$w->valid()){
$this->removeObjectWatch($id);
}
}
}
public function getObjectInformation($id, $includeObject = false){
if(!isset($this->leakWatch[$id])){
return null;
}
$valid = false;
$references = 0;
$object = null;
if($this->leakWatch[$id]->acquire()){
$object = $this->leakWatch[$id]->get();
$this->leakWatch[$id]->release();
$valid = true;
$references = getReferenceCount($object, false);
}
return [
"id" => $id,
"class" => $this->leakInfo[$id]["class"],
"hash" => $this->leakInfo[$id]["hash"],
"valid" => $valid,
"references" => $references,
"object" => $includeObject ? $object : null
];
}
public function dumpServerMemory($outputFolder, $maxNesting, $maxStringSize){
gc_disable();

View File

@ -73,7 +73,7 @@ namespace pocketmine {
use pocketmine\wizard\Installer;
const VERSION = "1.6dev";
const API_VERSION = "1.13.0";
const API_VERSION = "2.0.0";
const CODENAME = "[REDACTED]";
const MINECRAFT_VERSION = "v0.12.1 alpha";
const MINECRAFT_VERSION_NETWORK = "0.12.1";

View File

@ -24,8 +24,8 @@ namespace pocketmine\metadata;
use pocketmine\plugin\Plugin;
abstract class MetadataValue{
/** @var \WeakRef<Plugin> */
protected $owningPlugin;
/** @var Plugin */
private $owningPlugin;
protected function __construct(Plugin $owningPlugin){
$this->owningPlugin = new \WeakRef($owningPlugin);