Last active
October 6, 2015 15:48
-
-
Save jami-i/3016966 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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