mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-26 13:19:55 +00:00
Merge branch 'stable'
This commit is contained in:
commit
a604176ac2
@ -57,7 +57,10 @@ class AsyncPool{
|
|||||||
/** @var int[] */
|
/** @var int[] */
|
||||||
private $workerLastUsed = [];
|
private $workerLastUsed = [];
|
||||||
|
|
||||||
/** @var \Closure[] */
|
/**
|
||||||
|
* @var \Closure[]
|
||||||
|
* @phpstan-var (\Closure(int $workerId) : void)[]
|
||||||
|
*/
|
||||||
private $workerStartHooks = [];
|
private $workerStartHooks = [];
|
||||||
|
|
||||||
public function __construct(int $size, int $workerMemoryLimit, \ClassLoader $classLoader, \ThreadedLogger $logger){
|
public function __construct(int $size, int $workerMemoryLimit, \ClassLoader $classLoader, \ThreadedLogger $logger){
|
||||||
@ -88,6 +91,8 @@ class AsyncPool{
|
|||||||
* The signature should be `function(int $worker) : void`
|
* The signature should be `function(int $worker) : void`
|
||||||
*
|
*
|
||||||
* This function will call the hook for every already-running worker.
|
* This function will call the hook for every already-running worker.
|
||||||
|
*
|
||||||
|
* @phpstan-param \Closure(int $workerId) : void $hook
|
||||||
*/
|
*/
|
||||||
public function addWorkerStartHook(\Closure $hook) : void{
|
public function addWorkerStartHook(\Closure $hook) : void{
|
||||||
Utils::validateCallableSignature(function(int $worker) : void{}, $hook);
|
Utils::validateCallableSignature(function(int $worker) : void{}, $hook);
|
||||||
@ -99,6 +104,8 @@ class AsyncPool{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a previously-registered callback listening for workers being started.
|
* Removes a previously-registered callback listening for workers being started.
|
||||||
|
*
|
||||||
|
* @phpstan-param \Closure(int $workerId) : void $hook
|
||||||
*/
|
*/
|
||||||
public function removeWorkerStartHook(\Closure $hook) : void{
|
public function removeWorkerStartHook(\Closure $hook) : void{
|
||||||
unset($this->workerStartHooks[spl_object_id($hook)]);
|
unset($this->workerStartHooks[spl_object_id($hook)]);
|
||||||
|
@ -38,11 +38,15 @@ use pocketmine\utils\Utils;
|
|||||||
*/
|
*/
|
||||||
class ClosureTask extends Task{
|
class ClosureTask extends Task{
|
||||||
|
|
||||||
/** @var \Closure */
|
/**
|
||||||
|
* @var \Closure
|
||||||
|
* @phpstan-var \Closure(int) : void
|
||||||
|
*/
|
||||||
private $closure;
|
private $closure;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Closure $closure Must accept only ONE parameter, $currentTick
|
* @param \Closure $closure Must accept only ONE parameter, $currentTick
|
||||||
|
* @phpstan-param \Closure(int) : void $closure
|
||||||
*/
|
*/
|
||||||
public function __construct(\Closure $closure){
|
public function __construct(\Closure $closure){
|
||||||
Utils::validateCallableSignature(function(int $currentTick){}, $closure);
|
Utils::validateCallableSignature(function(int $currentTick){}, $closure);
|
||||||
|
@ -183,6 +183,7 @@ class Internet{
|
|||||||
* @param string[] $extraHeaders extra headers to send as a plain string array
|
* @param string[] $extraHeaders extra headers to send as a plain string array
|
||||||
* @param array $extraOpts extra CURLOPT_* to set as an [opt => value] map
|
* @param array $extraOpts extra CURLOPT_* to set as an [opt => value] map
|
||||||
* @param \Closure|null $onSuccess function to be called if there is no error. Accepts a resource argument as the cURL handle.
|
* @param \Closure|null $onSuccess function to be called if there is no error. Accepts a resource argument as the cURL handle.
|
||||||
|
* @phpstan-param (\Closure(resource) : void)|null $onSuccess
|
||||||
*
|
*
|
||||||
* @return array a plain array of three [result body : string, headers : array[], HTTP response code : int]. Headers are grouped by requests with strtolower(header name) as keys and header value as values
|
* @return array a plain array of three [result body : string, headers : array[], HTTP response code : int]. Headers are grouped by requests with strtolower(header name) as keys and header value as values
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user