Skip to content

Instantly share code, notes, and snippets.

@jami-i
Last active October 6, 2015 15:48
Show Gist options
  • Save jami-i/3016966 to your computer and use it in GitHub Desktop.
Save jami-i/3016966 to your computer and use it in GitHub Desktop.
package controllers
import java.util.concurrent._
import play.api._
import play.api.mvc._
import play.api.Play.current
import play.api.libs.concurrent._
object TimeoutController extends Controller {
def index(t:Long) = Action {
val promiseOfLong = Akka.future(new TimeoutThread(t).call())
Async{
promiseOfLong.map(i => Ok(""))
}
}
}
case class TimeoutThread(t:Long) extends Callable[Long] {
def call():Long = {
Thread.sleep(t)
t
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment