Skip to content

Commit

Permalink
Overload HttpExecution.fromThread with ExecutionContextExecutor param
Browse files Browse the repository at this point in the history
(cherry picked from commit 68854f2)
  • Loading branch information
mkurz authored and mergify-bot committed Apr 9, 2020
1 parent 4b8fa52 commit 052a607
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions core/play/src/main/java/play/libs/concurrent/HttpExecution.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ public static ExecutionContextExecutor fromThread(ExecutionContext delegate) {
return HttpExecutionContext.fromThread(delegate);
}

/**
* An ExecutionContext that executes work on the given ExecutionContext. The current thread's
* context ClassLoader is captured when this method is called and preserved for all executed
* tasks.
*
* @param delegate the delegate execution context.
* @return the execution context wrapped in an {@link play.libs.concurrent.HttpExecutionContext}.
*/
public static ExecutionContextExecutor fromThread(ExecutionContextExecutor delegate) {
return HttpExecutionContext.fromThread(delegate);
}

/**
* An ExecutionContext that executes work on the given ExecutionContext. The current thread's
* context ClassLoader is captured when this method is called and preserved for all executed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public Application(MyExecutionContext myExecutionContext) {

public CompletionStage<Result> index() {
// Wrap an existing thread pool, using the context from the current thread
Executor myEc = HttpExecution.fromThread((Executor) myExecutionContext);
Executor myEc = HttpExecution.fromThread(myExecutionContext);
return supplyAsync(() -> intensiveComputation(), myEc)
.thenApplyAsync(i -> ok("Got result: " + i), myEc);
}
Expand Down

0 comments on commit 052a607

Please sign in to comment.