Skip to content

funfix/tasks

Repository files navigation

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"

About

Task datatype, meant for cross-language interop (Java, Kotlin, Scala)

Topics

Resources

License

Stars

Watchers

Forks

Contributors