Skip to content

Commit de8f6de

Browse files
authored
Merge pull request #46 from llIlll/extend_future
[ISSUE42]Add cancel method to Future
2 parents e478c4a + ddfe3f5 commit de8f6de

File tree

1 file changed

+23
-0
lines changed
  • openmessaging-api/src/main/java/io/openmessaging

1 file changed

+23
-0
lines changed

openmessaging-api/src/main/java/io/openmessaging/Future.java

+23
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,29 @@
3232
* @since OMS 1.0.0
3333
*/
3434
public interface Future<V> {
35+
/**
36+
* Attempts to cancel execution of this task. This attempt will
37+
* fail if the task has already completed, has already been cancelled,
38+
* or could not be cancelled for some other reason. If successful,
39+
* and this task has not started when {@code cancel} is called,
40+
* this task should never run. If the task has already started,
41+
* then the {@code mayInterruptIfRunning} parameter determines
42+
* whether the thread executing this task should be interrupted in
43+
* an attempt to stop the task.
44+
*
45+
* <p>After this method returns, subsequent calls to {@link #isDone} will
46+
* always return {@code true}. Subsequent calls to {@link #isCancelled}
47+
* will always return {@code true} if this method returned {@code true}.
48+
*
49+
* @param mayInterruptIfRunning {@code true} if the thread executing this
50+
* task should be interrupted; otherwise, in-progress tasks are allowed
51+
* to complete
52+
* @return {@code false} if the task could not be cancelled,
53+
* typically because it has already completed normally;
54+
* {@code true} otherwise
55+
*/
56+
boolean cancel(boolean mayInterruptIfRunning);
57+
3558
/**
3659
* Returns {@code true} if this task was cancelled before it completed normally.
3760
*

0 commit comments

Comments
 (0)