mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
Modernize private property declarations in src/scheduler
This commit is contained in:
parent
9e59819f06
commit
9de88aa734
@ -42,47 +42,40 @@ use const PTHREADS_INHERIT_INI;
|
||||
class AsyncPool{
|
||||
private const WORKER_START_OPTIONS = PTHREADS_INHERIT_INI;
|
||||
|
||||
/** @var \ClassLoader */
|
||||
private $classLoader;
|
||||
/** @var \ThreadedLogger */
|
||||
private $logger;
|
||||
/** @var int */
|
||||
protected $size;
|
||||
/** @var int */
|
||||
private $workerMemoryLimit;
|
||||
|
||||
/**
|
||||
* @var \SplQueue[]|AsyncTask[][]
|
||||
* @phpstan-var array<int, \SplQueue<AsyncTask>>
|
||||
*/
|
||||
private $taskQueues = [];
|
||||
private array $taskQueues = [];
|
||||
|
||||
/**
|
||||
* @var AsyncWorker[]
|
||||
* @phpstan-var array<int, AsyncWorker>
|
||||
*/
|
||||
private $workers = [];
|
||||
private array $workers = [];
|
||||
/**
|
||||
* @var int[]
|
||||
* @phpstan-var array<int, int>
|
||||
*/
|
||||
private $workerLastUsed = [];
|
||||
private array $workerLastUsed = [];
|
||||
|
||||
/**
|
||||
* @var \Closure[]
|
||||
* @phpstan-var (\Closure(int $workerId) : void)[]
|
||||
*/
|
||||
private $workerStartHooks = [];
|
||||
private array $workerStartHooks = [];
|
||||
|
||||
/** @var SleeperHandler */
|
||||
private $eventLoop;
|
||||
|
||||
public function __construct(int $size, int $workerMemoryLimit, \ClassLoader $classLoader, \ThreadedLogger $logger, SleeperHandler $eventLoop){
|
||||
public function __construct(
|
||||
int $size,
|
||||
private int $workerMemoryLimit,
|
||||
private \ClassLoader $classLoader,
|
||||
private \ThreadedLogger $logger,
|
||||
private SleeperHandler $eventLoop
|
||||
){
|
||||
$this->size = $size;
|
||||
$this->workerMemoryLimit = $workerMemoryLimit;
|
||||
$this->classLoader = $classLoader;
|
||||
$this->logger = $logger;
|
||||
$this->eventLoop = $eventLoop;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -54,7 +54,7 @@ abstract class AsyncTask extends \Threaded{
|
||||
*
|
||||
* Used to store objects which are only needed on one thread and should not be serialized.
|
||||
*/
|
||||
private static $threadLocalStorage = null;
|
||||
private static ?\ArrayObject $threadLocalStorage = null;
|
||||
|
||||
/** @var AsyncWorker|null $worker */
|
||||
public $worker = null;
|
||||
|
@ -30,25 +30,14 @@ use function ini_set;
|
||||
|
||||
class AsyncWorker extends Worker{
|
||||
/** @var mixed[] */
|
||||
private static $store = [];
|
||||
private static array $store = [];
|
||||
|
||||
/** @var \ThreadedLogger */
|
||||
private $logger;
|
||||
/** @var int */
|
||||
private $id;
|
||||
|
||||
/** @var int */
|
||||
private $memoryLimit;
|
||||
|
||||
/** @var SleeperNotifier */
|
||||
private $notifier;
|
||||
|
||||
public function __construct(\ThreadedLogger $logger, int $id, int $memoryLimit, SleeperNotifier $notifier){
|
||||
$this->logger = $logger;
|
||||
$this->id = $id;
|
||||
$this->memoryLimit = $memoryLimit;
|
||||
$this->notifier = $notifier;
|
||||
}
|
||||
public function __construct(
|
||||
private \ThreadedLogger $logger,
|
||||
private int $id,
|
||||
private int $memoryLimit,
|
||||
private SleeperNotifier $notifier
|
||||
){}
|
||||
|
||||
public function getNotifier() : SleeperNotifier{
|
||||
return $this->notifier;
|
||||
|
@ -24,34 +24,18 @@ declare(strict_types=1);
|
||||
namespace pocketmine\scheduler;
|
||||
|
||||
final class BulkCurlTaskOperation{
|
||||
|
||||
/** @var string */
|
||||
private $page;
|
||||
/** @var float */
|
||||
private $timeout;
|
||||
/**
|
||||
* @var string[]
|
||||
* @phpstan-var list<string>
|
||||
*/
|
||||
private $extraHeaders;
|
||||
/**
|
||||
* @var mixed[]
|
||||
* @phpstan-var array<int, mixed>
|
||||
*/
|
||||
private $extraOpts;
|
||||
|
||||
/**
|
||||
* @param string[] $extraHeaders
|
||||
* @param mixed[] $extraOpts
|
||||
* @phpstan-param list<string> $extraHeaders
|
||||
* @phpstan-param array<int, mixed> $extraOpts
|
||||
*/
|
||||
public function __construct(string $page, float $timeout = 10, array $extraHeaders = [], array $extraOpts = []){
|
||||
$this->page = $page;
|
||||
$this->timeout = $timeout;
|
||||
$this->extraHeaders = $extraHeaders;
|
||||
$this->extraOpts = $extraOpts;
|
||||
}
|
||||
public function __construct(
|
||||
private string $page,
|
||||
private float $timeout = 10,
|
||||
private array $extraHeaders = [],
|
||||
private array $extraOpts = []
|
||||
){}
|
||||
|
||||
public function getPage() : string{ return $this->page; }
|
||||
|
||||
|
@ -39,20 +39,14 @@ use pocketmine\utils\Utils;
|
||||
* ```
|
||||
*/
|
||||
class ClosureTask extends Task{
|
||||
|
||||
/**
|
||||
* @var \Closure
|
||||
* @phpstan-var \Closure() : void
|
||||
*/
|
||||
private $closure;
|
||||
|
||||
/**
|
||||
* @param \Closure $closure Must accept zero parameters
|
||||
* @phpstan-param \Closure() : void $closure
|
||||
*/
|
||||
public function __construct(\Closure $closure){
|
||||
public function __construct(
|
||||
private \Closure $closure
|
||||
){
|
||||
Utils::validateCallableSignature(new CallbackType(new ReturnType()), $closure);
|
||||
$this->closure = $closure;
|
||||
}
|
||||
|
||||
public function getName() : string{
|
||||
|
@ -26,14 +26,9 @@ namespace pocketmine\scheduler;
|
||||
use pocketmine\utils\Utils;
|
||||
|
||||
abstract class Task{
|
||||
private ?TaskHandler $taskHandler = null;
|
||||
|
||||
/** @var TaskHandler|null */
|
||||
private $taskHandler = null;
|
||||
|
||||
/**
|
||||
* @return TaskHandler|null
|
||||
*/
|
||||
final public function getHandler(){
|
||||
final public function getHandler() : ?TaskHandler{
|
||||
return $this->taskHandler;
|
||||
}
|
||||
|
||||
|
@ -43,13 +43,10 @@ class TaskHandler{
|
||||
/** @var bool */
|
||||
protected $cancelled = false;
|
||||
|
||||
/** @var TimingsHandler */
|
||||
private $timings;
|
||||
private TimingsHandler $timings;
|
||||
|
||||
/** @var string */
|
||||
private $taskName;
|
||||
/** @var string */
|
||||
private $ownerName;
|
||||
private string $taskName;
|
||||
private string $ownerName;
|
||||
|
||||
public function __construct(Task $task, int $delay = -1, int $period = -1, ?string $ownerName = null){
|
||||
if($task->getHandler() !== null){
|
||||
|
@ -31,11 +31,7 @@ use pocketmine\utils\ObjectSet;
|
||||
use pocketmine\utils\ReversePriorityQueue;
|
||||
|
||||
class TaskScheduler{
|
||||
/** @var string|null */
|
||||
private $owner;
|
||||
|
||||
/** @var bool */
|
||||
private $enabled = true;
|
||||
private bool $enabled = true;
|
||||
|
||||
/**
|
||||
* @var ReversePriorityQueue
|
||||
@ -52,8 +48,9 @@ class TaskScheduler{
|
||||
/** @var int */
|
||||
protected $currentTick = 0;
|
||||
|
||||
public function __construct(?string $owner = null){
|
||||
$this->owner = $owner;
|
||||
public function __construct(
|
||||
private ?string $owner = null
|
||||
){
|
||||
$this->queue = new ReversePriorityQueue();
|
||||
$this->tasks = new ObjectSet();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user