mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 02:08:21 +00:00
Modernize property type declarations
This commit is contained in:
@ -42,9 +42,6 @@ use const PTHREADS_INHERIT_INI;
|
||||
class AsyncPool{
|
||||
private const WORKER_START_OPTIONS = PTHREADS_INHERIT_INI;
|
||||
|
||||
/** @var int */
|
||||
protected $size;
|
||||
|
||||
/**
|
||||
* @var \SplQueue[]|AsyncTask[][]
|
||||
* @phpstan-var array<int, \SplQueue<AsyncTask>>
|
||||
@ -69,14 +66,12 @@ class AsyncPool{
|
||||
private array $workerStartHooks = [];
|
||||
|
||||
public function __construct(
|
||||
int $size,
|
||||
protected int $size,
|
||||
private int $workerMemoryLimit,
|
||||
private \ClassLoader $classLoader,
|
||||
private \ThreadedLogger $logger,
|
||||
private SleeperHandler $eventLoop
|
||||
){
|
||||
$this->size = $size;
|
||||
}
|
||||
){}
|
||||
|
||||
/**
|
||||
* Returns the maximum size of the pool. Note that there may be less active workers than this number.
|
||||
|
@ -59,8 +59,7 @@ abstract class AsyncTask extends \Threaded{
|
||||
/** @var AsyncWorker|null $worker */
|
||||
public $worker = null;
|
||||
|
||||
/** @var \Threaded */
|
||||
public $progressUpdates;
|
||||
public \Threaded $progressUpdates;
|
||||
|
||||
private string|int|bool|null|float $result = null;
|
||||
private bool $serialized = false;
|
||||
|
@ -27,34 +27,24 @@ use pocketmine\timings\Timings;
|
||||
use pocketmine\timings\TimingsHandler;
|
||||
|
||||
class TaskHandler{
|
||||
protected int $nextRun;
|
||||
|
||||
/** @var Task */
|
||||
protected $task;
|
||||
|
||||
/** @var int */
|
||||
protected $delay;
|
||||
|
||||
/** @var int */
|
||||
protected $period;
|
||||
|
||||
/** @var int */
|
||||
protected $nextRun;
|
||||
|
||||
/** @var bool */
|
||||
protected $cancelled = false;
|
||||
protected bool $cancelled = false;
|
||||
|
||||
private TimingsHandler $timings;
|
||||
|
||||
private string $taskName;
|
||||
private string $ownerName;
|
||||
|
||||
public function __construct(Task $task, int $delay = -1, int $period = -1, ?string $ownerName = null){
|
||||
public function __construct(
|
||||
protected Task $task,
|
||||
protected int $delay = -1,
|
||||
protected int $period = -1,
|
||||
?string $ownerName = null
|
||||
){
|
||||
if($task->getHandler() !== null){
|
||||
throw new \InvalidArgumentException("Cannot assign multiple handlers to the same task");
|
||||
}
|
||||
$this->task = $task;
|
||||
$this->delay = $delay;
|
||||
$this->period = $period;
|
||||
$this->taskName = $task->getName();
|
||||
$this->ownerName = $ownerName ?? "Unknown";
|
||||
$this->timings = Timings::getScheduledTaskTimings($this, $period);
|
||||
|
@ -33,20 +33,16 @@ use pocketmine\utils\ReversePriorityQueue;
|
||||
class TaskScheduler{
|
||||
private bool $enabled = true;
|
||||
|
||||
/**
|
||||
* @var ReversePriorityQueue
|
||||
* @phpstan-var ReversePriorityQueue<int, TaskHandler>
|
||||
*/
|
||||
protected $queue;
|
||||
/** @phpstan-var ReversePriorityQueue<int, TaskHandler> */
|
||||
protected ReversePriorityQueue $queue;
|
||||
|
||||
/**
|
||||
* @var ObjectSet|TaskHandler[]
|
||||
* @phpstan-var ObjectSet<TaskHandler>
|
||||
*/
|
||||
protected $tasks;
|
||||
protected ObjectSet $tasks;
|
||||
|
||||
/** @var int */
|
||||
protected $currentTick = 0;
|
||||
protected int $currentTick = 0;
|
||||
|
||||
public function __construct(
|
||||
private ?string $owner = null
|
||||
|
Reference in New Issue
Block a user