Created
August 7, 2013 07:17
-
-
Save AntonFagerberg/6171895 to your computer and use it in GitHub Desktop.
Play concurrency test
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 play.api._ | |
import play.api.mvc._ | |
import scala.concurrent.{ExecutionContext, Future} | |
import play.api.libs.concurrent.Execution.Implicits._ | |
import play.api.libs.ws.WS | |
object Application extends Controller { | |
def index = Action { | |
println("Start") | |
val wait = Future { | |
println("Future start") | |
for (i <- 0 to 100000000) { Math.pow(i, 3) } | |
println("Future done") | |
} | |
Async { | |
println("Async") | |
wait.map { w => | |
println("Done") | |
Ok(views.html.index("Your new application is ready.")) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment