playframework - Play framework 2, how to use execution context in Java? -
the official documents describe how use in scala. http://www.playframework.com/documentation/2.1.0/threadpools.
future { // blocking or expensive code here }(contexts.myexecutioncontext)
i can excutioncontext like:
executioncontext myexecutioncontext = akka.system().dispatchers().lookup("my-context");
but how add in code blow?
return async( future(new callable<string>() { public string call() { return dosth(); }).map(new f.function<string,result>() { public result apply(string i) { return ok(i); } })
i think answer should be:
executioncontext myexecutioncontext = akka.system().dispatchers().lookup("my-context"); return async( akka.aspromise(futures.future(new callable<string>() { public string call() { return dosth(); } }, myexecutioncontext)).map(new f.function<string,result>() { public result apply(string i) { return ok(i); } }) );
Comments
Post a Comment