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