Package play.libs.concurrent
Class CustomExecutionContext
- 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.
Then use your custom execution context where you have blocking operations that require processing outside of Play's main rendering thread.class MyCustomExecutionContext extends CustomExecutionContext { // Dependency inject the actorsystem from elsewhere public MyCustomExecutionContext(ActorSystem actorSystem) { super(actorSystem, "full.path.to.my-custom-executor"); } }
- See Also:
- Dispatchers, Thread Pools
-
-
Constructor Summary
Constructors Constructor Description CustomExecutionContext(ActorSystem actorSystem, String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Executor
current()
Get this executor associated with the current ClassLoader.void
execute(Runnable command)
scala.concurrent.ExecutionContext
prepare()
void
reportFailure(Throwable cause)
-
-
-
Constructor Detail
-
CustomExecutionContext
public CustomExecutionContext(ActorSystem actorSystem, String name)
-
-
Method Detail
-
prepare
public scala.concurrent.ExecutionContext prepare()
- Specified by:
prepare
in interfacescala.concurrent.ExecutionContext
-
execute
public void execute(Runnable command)
-
reportFailure
public void reportFailure(Throwable cause)
- Specified by:
reportFailure
in interfacescala.concurrent.ExecutionContext
-
current
public Executor 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.
-
-