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

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -