Merge pull request #425 from Massive-Dynamics/timeout-unsuccessful-cancel
Change Timeout.cancel() to return a boolean value
This commit is contained in:
commit
53fb5165c9
@ -501,13 +501,13 @@ public class HashedWheelTimer implements Timer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
public boolean cancel() {
|
||||
if (!state.compareAndSet(ST_INIT, ST_CANCELLED)) {
|
||||
// TODO return false
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
wheel[stopIndex].remove(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -44,9 +44,11 @@ public interface Timeout {
|
||||
boolean isCancelled();
|
||||
|
||||
/**
|
||||
* Cancels the {@link TimerTask} associated with this handle. It the
|
||||
* task has been executed or cancelled already, it will return with no
|
||||
* side effect.
|
||||
* Attempts to cancel the {@link TimerTask} associated with this handle.
|
||||
* If the task has been executed or cancelled already, it will return with
|
||||
* no side effect.
|
||||
*
|
||||
* @return True if the cancellation completed successfully, otherwise false
|
||||
*/
|
||||
void cancel();
|
||||
boolean cancel();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user