Skip to content

Latest commit

 

History

History
59 lines (46 loc) · 1.96 KB

File metadata and controls

59 lines (46 loc) · 1.96 KB

Tasks

build maven javadoc

This is a library meant for library authors that want to build libraries that work across Java, Scala, or Kotlin, without having to worry about interoperability with whatever method of I/O that the library is using under the hood.

Usage

Read the Javadoc. Better documentation is coming.

Migration Note (v0.5.0)

The AsyncFun interface has changed to improve cancellation management and simplify the API. This is a source and binary incompatible change.

Old shape:

Task.fromAsync((executor, callback) -> {
    // ...
    return () -> { /* cleanup */ };
});

New shape:

Task.fromAsync(continuation -> {
    var executor = continuation.getExecutor();
    continuation.invokeOnCancellation(() -> { /* cleanup */ });
    // ...
});

Key differences:

  • The executor and callback are now encapsulated in the Continuation.
  • Cancellation cleanup is registered via continuation.invokeOnCancellation(finalizer) instead of returning a Cancellable.
  • continuation.onCancellation() signals that the task has completed due to cancellation, whereas invokeOnCancellation(finalizer) registers a cleanup action to run when cancellation occurs.

Maven:

<dependency>
  <groupId>org.funfix</groupId>
  <artifactId>tasks-jvm</artifactId>
  <version>0.4.1</version>
</dependency>

Gradle:

dependencies {
    implementation("org.funfix:tasks-jvm:0.4.1")
}

sbt:

libraryDependencies += "org.funfix" % "tasks-jvm" % "0.4.1"