AsyncTask: strip out task cancellation functionality

closes #5854

Cancelling task runs doesn't make any sense.

- It breaks sequential task execution - later tasks might depend on state from earlier tasks
- It doesn't actually cancel the task - at best, it prevents it from running, but cannot interrupt it (though interrupting a task does not make sense either)

We don't use this "feature" in the core anymore since 22b5e5db5e822ac94ed3978ea75bbadcfa8e7f4f, as this was causing unexpected behaviour for plugins anyway, along with the occasional shutdown crash due to inconsistent worker states.
This commit is contained in:
Dylan K. Taylor 2023-07-18 12:45:30 +01:00
parent 90520c8962
commit a74ab756bd
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
2 changed files with 11 additions and 8 deletions

View File

@ -259,7 +259,7 @@ class AsyncPool{
if($task->isTerminated()){
$this->checkCrashedWorker($worker, $task);
throw new AssumptionFailedError("checkCrashedWorker() should have thrown an exception, making this unreachable");
}elseif(!$task->hasCancelledRun()){
}else{
/*
* It's possible for a task to submit a progress update and then finish before the progress
* update is detected by the parent thread, so here we consume any missed updates.

View File

@ -72,17 +72,14 @@ abstract class AsyncTask extends Runnable{
private ?ThreadSafeArray $progressUpdates = null;
private ThreadSafe|string|int|bool|null|float $result = null;
private bool $cancelRun = false;
private bool $submitted = false;
private bool $submitted = false;
private bool $finished = false;
public function run() : void{
$this->result = null;
if(!$this->cancelRun){
$this->onRun();
}
$this->onRun();
$this->finished = true;
$worker = NativeThread::getCurrentThread();
@ -123,12 +120,18 @@ abstract class AsyncTask extends Runnable{
$this->result = is_scalar($result) || is_null($result) || $result instanceof ThreadSafe ? $result : new NonThreadSafeValue($result);
}
/**
* @deprecated
*/
public function cancelRun() : void{
$this->cancelRun = true;
//NOOP
}
/**
* @deprecated
*/
public function hasCancelledRun() : bool{
return $this->cancelRun;
return false;
}
public function setSubmitted() : void{