AsyncTask: added onError() main thread hook, closes #2512

This commit is contained in:
Dylan K. Taylor 2019-04-16 17:44:14 +01:00
parent b4f6c1e1a6
commit e62bbd4754
2 changed files with 9 additions and 0 deletions

View File

@ -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

View File

@ -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.