Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

simple future facade for Scala

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 notes
Octocat-spinner-32 project
Octocat-spinner-32 sff4s-actors
Octocat-spinner-32 sff4s-akka
Octocat-spinner-32 sff4s-api
Octocat-spinner-32 sff4s-juc
Octocat-spinner-32 sff4s-twitter-util
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.md
README.md

sff4s

sff4s (simple future facade for Scala) is a Scala wrapper around several future implementations.

libraryDependencies ++= Seq(
  "com.eed3si9n" %% "sff4s-api" % "0.1.0",
  "com.eed3si9n" %% "sff4s-juc" % "0.1.0")

The API mostly mimics that of twitter util's Future:

val factory = sff4s.impl.ActorsFuture
val f = factory future {
  Thread.sleep(1000)
  1
}
val g = f map { _ + 1 }
g(2000) // => This blocks for the futures result (and eventually returns 2)

// Another option:
g onSuccess { value =>
  println(value) // => prints "2"
}

// Using for expressions:
val xFuture = factory future {1}
val yFuture = factory future {2}

for {
  x <- xFuture
  y <- yFuture
} {
  println(x + y) // => prints "3"
}

// Using implicit conversion
import factory._
val native = scala.actors.Futures future {5}
val w: sff4s.Future[Int] = native
w() // => This blocks for the futures result (and eventually returns 5)

sff4s-api

Platform independent API consisting of abstract class Future[+A], which represents a future value; and trait Futures, which represents the dispatcher to create the future values.

sff4s-actors

Wrapper around scala.actors.Future.

sff4s-juc

Wrapper around java.util.concurrent.Future.

sff4s-akka

Wrapper around akka.dispatch.Future.

sff4s-twitter-util

Wrapper around com.twitter.util.Future. Note unlike other implementation, TwitterUtilFuture.future does not process the calculation in the background. Instead, you're supposed to create a Promise object and set the value using your own concurrency mechanism.

Something went wrong with that request. Please try again.