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