Added converters from Executor and ExecutorService to ExecutionContext
This commit is contained in:
parent
b7cf3e9541
commit
2b250f8e4c
1 changed files with 16 additions and 0 deletions
|
|
@ -89,6 +89,22 @@ final case class TaskInvocation(eventStream: EventStream, runnable: Runnable, cl
|
|||
|
||||
object ExecutionContext {
|
||||
implicit def defaultExecutionContext(implicit system: ActorSystem): ExecutionContext = system.dispatcher
|
||||
|
||||
/**
|
||||
* Creates an ExecutionContext from the given ExecutorService
|
||||
*/
|
||||
def fromExecutorService(e: ExecutorService): ExecutionContext = new WrappedExecutorService(e)
|
||||
|
||||
/**
|
||||
* Creates an ExecutionContext from the given Executor
|
||||
*/
|
||||
def fromExecutor(e: ExecutorService): ExecutionContext = new WrappedExecutor(e)
|
||||
|
||||
private class WrappedExecutorService(val executor: ExecutorService) extends ExecutorServiceDelegate with ExecutionContext
|
||||
|
||||
private class WrappedExecutor(val executor: Executor) extends Executor with ExecutionContext {
|
||||
override final def execute(runnable: Runnable): Unit = executor.execute(runnable)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue