mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 02:42:58 +00:00
Transition to spl_object_id()
This commit is contained in:
@ -27,7 +27,7 @@ use pocketmine\utils\Utils;
|
||||
use function array_keys;
|
||||
use function assert;
|
||||
use function count;
|
||||
use function spl_object_hash;
|
||||
use function spl_object_id;
|
||||
use function time;
|
||||
use const PHP_INT_MAX;
|
||||
use const PTHREADS_INHERIT_CONSTANTS;
|
||||
@ -97,7 +97,7 @@ class AsyncPool{
|
||||
*/
|
||||
public function addWorkerStartHook(\Closure $hook) : void{
|
||||
Utils::validateCallableSignature(function(int $worker) : void{}, $hook);
|
||||
$this->workerStartHooks[spl_object_hash($hook)] = $hook;
|
||||
$this->workerStartHooks[spl_object_id($hook)] = $hook;
|
||||
foreach($this->workers as $i => $worker){
|
||||
$hook($i);
|
||||
}
|
||||
@ -109,7 +109,7 @@ class AsyncPool{
|
||||
* @param \Closure $hook
|
||||
*/
|
||||
public function removeWorkerStartHook(\Closure $hook) : void{
|
||||
unset($this->workerStartHooks[spl_object_hash($hook)]);
|
||||
unset($this->workerStartHooks[spl_object_id($hook)]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -25,7 +25,7 @@ namespace pocketmine\scheduler;
|
||||
|
||||
use function is_scalar;
|
||||
use function serialize;
|
||||
use function spl_object_hash;
|
||||
use function spl_object_id;
|
||||
use function unserialize;
|
||||
|
||||
/**
|
||||
@ -256,7 +256,7 @@ abstract class AsyncTask extends \Threaded{
|
||||
*/
|
||||
self::$threadLocalStorage = new \ArrayObject();
|
||||
}
|
||||
self::$threadLocalStorage[spl_object_hash($this)] = $complexData;
|
||||
self::$threadLocalStorage[spl_object_id($this)] = $complexData;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -270,16 +270,16 @@ abstract class AsyncTask extends \Threaded{
|
||||
* @throws \InvalidArgumentException if no data were stored by this AsyncTask instance.
|
||||
*/
|
||||
protected function fetchLocal(){
|
||||
if(self::$threadLocalStorage === null or !isset(self::$threadLocalStorage[spl_object_hash($this)])){
|
||||
if(self::$threadLocalStorage === null or !isset(self::$threadLocalStorage[spl_object_id($this)])){
|
||||
throw new \InvalidArgumentException("No matching thread-local data found on this thread");
|
||||
}
|
||||
|
||||
return self::$threadLocalStorage[spl_object_hash($this)];
|
||||
return self::$threadLocalStorage[spl_object_id($this)];
|
||||
}
|
||||
|
||||
final public function __destruct(){
|
||||
$this->reallyDestruct();
|
||||
if(self::$threadLocalStorage !== null and isset(self::$threadLocalStorage[$h = spl_object_hash($this)])){
|
||||
if(self::$threadLocalStorage !== null and isset(self::$threadLocalStorage[$h = spl_object_id($this)])){
|
||||
unset(self::$threadLocalStorage[$h]);
|
||||
if(self::$threadLocalStorage->count() === 0){
|
||||
self::$threadLocalStorage = null;
|
||||
|
Reference in New Issue
Block a user