mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-26 05:14:05 +00:00
scheduler: populate missing return type information
This commit is contained in:
parent
1cc7027f92
commit
f5a18df835
@ -71,6 +71,9 @@ abstract class AsyncTask extends Collectable{
|
|||||||
/** @var bool */
|
/** @var bool */
|
||||||
private $crashed = false;
|
private $crashed = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function run(){
|
public function run(){
|
||||||
$this->result = null;
|
$this->result = null;
|
||||||
|
|
||||||
@ -97,6 +100,9 @@ abstract class AsyncTask extends Collectable{
|
|||||||
return $this->serialized ? unserialize($this->result) : $this->result;
|
return $this->serialized ? unserialize($this->result) : $this->result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function cancelRun(){
|
public function cancelRun(){
|
||||||
$this->cancelRun = true;
|
$this->cancelRun = true;
|
||||||
}
|
}
|
||||||
@ -114,11 +120,18 @@ abstract class AsyncTask extends Collectable{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mixed $result
|
* @param mixed $result
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setResult($result){
|
public function setResult($result){
|
||||||
$this->result = ($this->serialized = !is_scalar($result)) ? serialize($result) : $result;
|
$this->result = ($this->serialized = !is_scalar($result)) ? serialize($result) : $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $taskId
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function setTaskId(int $taskId){
|
public function setTaskId(int $taskId){
|
||||||
$this->taskId = $taskId;
|
$this->taskId = $taskId;
|
||||||
}
|
}
|
||||||
@ -149,6 +162,8 @@ abstract class AsyncTask extends Collectable{
|
|||||||
*
|
*
|
||||||
* @param string $identifier
|
* @param string $identifier
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function saveToThreadStore(string $identifier, $value){
|
public function saveToThreadStore(string $identifier, $value){
|
||||||
if($this->worker === null or $this->isGarbage()){
|
if($this->worker === null or $this->isGarbage()){
|
||||||
@ -161,6 +176,8 @@ abstract class AsyncTask extends Collectable{
|
|||||||
* @see AsyncWorker::removeFromThreadStore()
|
* @see AsyncWorker::removeFromThreadStore()
|
||||||
*
|
*
|
||||||
* @param string $identifier
|
* @param string $identifier
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function removeFromThreadStore(string $identifier) : void{
|
public function removeFromThreadStore(string $identifier) : void{
|
||||||
if($this->worker === null or $this->isGarbage()){
|
if($this->worker === null or $this->isGarbage()){
|
||||||
@ -193,6 +210,8 @@ abstract class AsyncTask extends Collectable{
|
|||||||
* {@link AsyncTask::onProgressUpdate} from the main thread with the given progress parameter.
|
* {@link AsyncTask::onProgressUpdate} from the main thread with the given progress parameter.
|
||||||
*
|
*
|
||||||
* @param mixed $progress A value that can be safely serialize()'ed.
|
* @param mixed $progress A value that can be safely serialize()'ed.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function publishProgress($progress){
|
public function publishProgress($progress){
|
||||||
$this->progressUpdates[] = serialize($progress);
|
$this->progressUpdates[] = serialize($progress);
|
||||||
@ -202,6 +221,8 @@ abstract class AsyncTask extends Collectable{
|
|||||||
* @internal Only call from AsyncPool.php on the main thread
|
* @internal Only call from AsyncPool.php on the main thread
|
||||||
*
|
*
|
||||||
* @param Server $server
|
* @param Server $server
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function checkProgressUpdates(Server $server){
|
public function checkProgressUpdates(Server $server){
|
||||||
while($this->progressUpdates->count() !== 0){
|
while($this->progressUpdates->count() !== 0){
|
||||||
@ -218,6 +239,8 @@ abstract class AsyncTask extends Collectable{
|
|||||||
* @param Server $server
|
* @param Server $server
|
||||||
* @param mixed $progress The parameter passed to {@link AsyncTask::publishProgress}. It is serialize()'ed
|
* @param mixed $progress The parameter passed to {@link AsyncTask::publishProgress}. It is serialize()'ed
|
||||||
* and then unserialize()'ed, as if it has been cloned.
|
* and then unserialize()'ed, as if it has been cloned.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function onProgressUpdate(Server $server, $progress){
|
public function onProgressUpdate(Server $server, $progress){
|
||||||
|
|
||||||
@ -237,6 +260,7 @@ abstract class AsyncTask extends Collectable{
|
|||||||
*
|
*
|
||||||
* @param mixed $complexData the data to store
|
* @param mixed $complexData the data to store
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
* @throws \BadMethodCallException if called from any thread except the main thread
|
* @throws \BadMethodCallException if called from any thread except the main thread
|
||||||
*/
|
*/
|
||||||
protected function storeLocal($complexData){
|
protected function storeLocal($complexData){
|
||||||
|
@ -49,6 +49,9 @@ class AsyncWorker extends Worker{
|
|||||||
$this->memoryLimit = $memoryLimit;
|
$this->memoryLimit = $memoryLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function run(){
|
public function run(){
|
||||||
error_reporting(-1);
|
error_reporting(-1);
|
||||||
|
|
||||||
@ -76,6 +79,9 @@ class AsyncWorker extends Worker{
|
|||||||
return $this->logger;
|
return $this->logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function handleException(\Throwable $e){
|
public function handleException(\Throwable $e){
|
||||||
$this->logger->logException($e);
|
$this->logger->logException($e);
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,8 @@ abstract class Task{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param TaskHandler|null $taskHandler
|
* @param TaskHandler|null $taskHandler
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
final public function setHandler(TaskHandler $taskHandler = null){
|
final public function setHandler(TaskHandler $taskHandler = null){
|
||||||
if($this->taskHandler === null or $taskHandler === null){
|
if($this->taskHandler === null or $taskHandler === null){
|
||||||
@ -72,6 +74,8 @@ abstract class Task{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Actions to execute if the Task is cancelled
|
* Actions to execute if the Task is cancelled
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function onCancel(){
|
public function onCancel(){
|
||||||
|
|
||||||
|
@ -88,6 +88,8 @@ class TaskHandler{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $ticks
|
* @param int $ticks
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setNextRun(int $ticks){
|
public function setNextRun(int $ticks){
|
||||||
$this->nextRun = $ticks;
|
$this->nextRun = $ticks;
|
||||||
@ -135,6 +137,9 @@ class TaskHandler{
|
|||||||
return $this->period;
|
return $this->period;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function cancel(){
|
public function cancel(){
|
||||||
try{
|
try{
|
||||||
if(!$this->isCancelled()){
|
if(!$this->isCancelled()){
|
||||||
@ -145,6 +150,9 @@ class TaskHandler{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function remove(){
|
public function remove(){
|
||||||
$this->cancelled = true;
|
$this->cancelled = true;
|
||||||
$this->task->setHandler(null);
|
$this->task->setHandler(null);
|
||||||
@ -152,6 +160,8 @@ class TaskHandler{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $currentTick
|
* @param int $currentTick
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function run(int $currentTick){
|
public function run(int $currentTick){
|
||||||
$this->timings->startTiming();
|
$this->timings->startTiming();
|
||||||
|
@ -103,6 +103,8 @@ class TaskScheduler{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $taskId
|
* @param int $taskId
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function cancelTask(int $taskId){
|
public function cancelTask(int $taskId){
|
||||||
if(isset($this->tasks[$taskId])){
|
if(isset($this->tasks[$taskId])){
|
||||||
@ -114,6 +116,9 @@ class TaskScheduler{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function cancelAllTasks(){
|
public function cancelAllTasks(){
|
||||||
foreach($this->tasks as $id => $task){
|
foreach($this->tasks as $id => $task){
|
||||||
$this->cancelTask($id);
|
$this->cancelTask($id);
|
||||||
@ -186,6 +191,8 @@ class TaskScheduler{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $currentTick
|
* @param int $currentTick
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function mainThreadHeartbeat(int $currentTick){
|
public function mainThreadHeartbeat(int $currentTick){
|
||||||
$this->currentTick = $currentTick;
|
$this->currentTick = $currentTick;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user