mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-11 00:09:39 +00:00
AsyncTask: added onError() main thread hook, closes #2512
This commit is contained in:
parent
b4f6c1e1a6
commit
e62bbd4754
@ -239,6 +239,7 @@ class AsyncPool{
|
||||
|
||||
if($task->isCrashed()){
|
||||
$this->logger->critical("Could not execute asynchronous task " . (new \ReflectionClass($task))->getShortName() . ": Task crashed");
|
||||
$task->onError();
|
||||
}elseif(!$task->hasCancelledRun()){
|
||||
/*
|
||||
* It's possible for a task to submit a progress update and then finish before the progress
|
||||
|
@ -183,6 +183,14 @@ abstract class AsyncTask extends \Threaded{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from the main thread when the async task experiences an error during onRun(). Use this for things like
|
||||
* promise rejection.
|
||||
*/
|
||||
public function onError() : void{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves mixed data in thread-local storage. Data stored using this storage is **only accessible from the thread it
|
||||
* was stored on**. Data stored using this method will **not** be serialized.
|
||||
|
Loading…
x
Reference in New Issue
Block a user