Skip to content

Commit

Permalink
Annotate and document that cancel method throws CancellationException
Browse files Browse the repository at this point in the history
  • Loading branch information
mdedetrich committed Apr 3, 2022
1 parent 5d768a7 commit 7950275
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,4 +334,6 @@ cancellableFuture.cancel()

Note that the `.cancel` method on `CancelableFuture` is a best effort implementation and
it also does not handle cleaning up of resources (such as file handles) since further
computations deriving from `.map`/`.flatMap`/`onComplete` may not execute.
computations deriving from `.map`/`.flatMap`/`onComplete` may not execute. If a
`CancelableFuture` was cancelled this way it will fail with a `CancellationException`
exception.
1 change: 1 addition & 0 deletions src/main/scala/markatta/futiles/CancellableFuture.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ trait CancellableFuture[T] extends Future[T] {

/** Attempts to cancel the underlying [[scala.concurrent.Future]]. Note that this is a best effort attempt
*/
@throws[CancellationException]
def cancel(): Unit
}

Expand Down

0 comments on commit 7950275

Please sign in to comment.