Last active
January 19, 2018 22:58
-
-
Save rowanl/911001b66f5ca0d5a413004d7709cf11 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
private <T> CompletionStage<T> wrapContext(Supplier<T> toRun) { | |
return supplyAsync(toRun, executionContext); // here we are passing the context to run the method in, this means this is running in our new actor context | |
} | |
// and here is the magic, we are returning async and we are doing it in the context of executionContext. For the JS folk this is like using call or apply, we are saying do this call, but do this call within a different context than the http thread you were called from | |
public CompletionStage<List<Charity>> findList() { | |
return wrapContext(() -> ebeanServer.find(Charity.class).findList()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment