mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-12 00:39:45 +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()){
|
if($task->isCrashed()){
|
||||||
$this->logger->critical("Could not execute asynchronous task " . (new \ReflectionClass($task))->getShortName() . ": Task crashed");
|
$this->logger->critical("Could not execute asynchronous task " . (new \ReflectionClass($task))->getShortName() . ": Task crashed");
|
||||||
|
$task->onError();
|
||||||
}elseif(!$task->hasCancelledRun()){
|
}elseif(!$task->hasCancelledRun()){
|
||||||
/*
|
/*
|
||||||
* It's possible for a task to submit a progress update and then finish before the progress
|
* 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
|
* 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.
|
* was stored on**. Data stored using this method will **not** be serialized.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user