mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-12 14:35:35 +00:00
Add signature validation for some user-defined callbacks
This commit is contained in:
parent
762405d16a
commit
a95694ed06
@ -24,6 +24,7 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\scheduler;
|
namespace pocketmine\scheduler;
|
||||||
|
|
||||||
use pocketmine\Server;
|
use pocketmine\Server;
|
||||||
|
use pocketmine\utils\Utils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages general-purpose worker threads used for processing asynchronous tasks, and the tasks submitted to those
|
* Manages general-purpose worker threads used for processing asynchronous tasks, and the tasks submitted to those
|
||||||
@ -96,6 +97,7 @@ class AsyncPool{
|
|||||||
* @param \Closure $hook
|
* @param \Closure $hook
|
||||||
*/
|
*/
|
||||||
public function addWorkerStartHook(\Closure $hook) : void{
|
public function addWorkerStartHook(\Closure $hook) : void{
|
||||||
|
Utils::validateCallableSignature(function(int $worker) : void{}, $hook);
|
||||||
$this->workerStartHooks[spl_object_hash($hook)] = $hook;
|
$this->workerStartHooks[spl_object_hash($hook)] = $hook;
|
||||||
foreach($this->workers as $i => $worker){
|
foreach($this->workers as $i => $worker){
|
||||||
$hook($i);
|
$hook($i);
|
||||||
|
@ -45,6 +45,7 @@ class ClosureTask extends Task{
|
|||||||
* @param \Closure $closure Must accept only ONE parameter, $currentTick
|
* @param \Closure $closure Must accept only ONE parameter, $currentTick
|
||||||
*/
|
*/
|
||||||
public function __construct(\Closure $closure){
|
public function __construct(\Closure $closure){
|
||||||
|
Utils::validateCallableSignature(function(int $currentTick) : void{}, $closure);
|
||||||
$this->closure = $closure;
|
$this->closure = $closure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user