After calling cancel() or cancel(true) on a Task, the task will still update its progress and value at completion.
--
There are two scenarios here. Consider a long-running computation that returns a list of data as its value. When you say "cancel" the task, you might want to either 1) stop the task and discard any partial result or 2) stop the task and retain the partial result.
At least: there should ways to accomplish both.
The way it works now is compatible with 2). I propose that this behaviour remains, but available through a new method "cancelWithValue()" (or similar). Here it is assumed that the user code will actually be checking thread interruption, ending its computation and making available the partial results.
The proposed fix for the original cancel() method should thus be compatible with scenario 1). I.e., when cancelled, don't update progress and value, regardless of what the user code might do.
--
There are two scenarios here. Consider a long-running computation that returns a list of data as its value. When you say "cancel" the task, you might want to either 1) stop the task and discard any partial result or 2) stop the task and retain the partial result.
At least: there should ways to accomplish both.
The way it works now is compatible with 2). I propose that this behaviour remains, but available through a new method "cancelWithValue()" (or similar). Here it is assumed that the user code will actually be checking thread interruption, ending its computation and making available the partial results.
The proposed fix for the original cancel() method should thus be compatible with scenario 1). I.e., when cancelled, don't update progress and value, regardless of what the user code might do.