Package play.libs.concurrent
Class CustomExecutionContext
java.lang.Object
play.libs.concurrent.CustomExecutionContext
- All Implemented Interfaces:
Executor,scala.concurrent.ExecutionContext,scala.concurrent.ExecutionContextExecutor
- Direct Known Subclasses:
CaffeineExecutionContext
public abstract class CustomExecutionContext
extends Object
implements scala.concurrent.ExecutionContextExecutor
Provides a custom execution context from an Pekko dispatcher.
Subclass this to create your own custom execution context, using the full path to the Pekko dispatcher.
class MyCustomExecutionContext extends CustomExecutionContext {
// Dependency inject the actorsystem from elsewhere
public MyCustomExecutionContext(ActorSystem actorSystem) {
super(actorSystem, "full.path.to.my-custom-executor");
}
}
Then use your custom execution context where you have blocking operations that require processing
outside of Play's main rendering thread.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface scala.concurrent.ExecutionContext
scala.concurrent.ExecutionContext.Implicits$, scala.concurrent.ExecutionContext.parasitic$ -
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
CustomExecutionContext
-
-
Method Details
-
prepare
public scala.concurrent.ExecutionContext prepare()- Specified by:
preparein interfacescala.concurrent.ExecutionContext
-
execute
-
reportFailure
- Specified by:
reportFailurein interfacescala.concurrent.ExecutionContext
-
current
Get this executor associated with the current ClassLoader.Note that the returned executor is only valid for the current ClassLoader. It should be used in a transient fashion, long lived references to it should not be kept.
- Returns:
- This executor that will execute its tasks with the current ClassLoader.
-