File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
src/library/scala/concurrent/impl Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ private[concurrent] object ExecutionContextImpl {
115115
116116 def fromExecutorService (es : ExecutorService , reporter : Throwable => Unit = ExecutionContext .defaultReporter): ExecutionContextImpl with ExecutionContextExecutorService =
117117 new ExecutionContextImpl (es, reporter) with ExecutionContextExecutorService {
118- final def asExecutorService : ExecutorService = executor.right.asInstanceOf [ExecutorService ]
118+ final def asExecutorService : ExecutorService = executor.right.get. asInstanceOf [ExecutorService ]
119119 override def execute (command : Runnable ) = executor.right.get.execute(command)
120120 override def shutdown () { asExecutorService.shutdown() }
121121 override def shutdownNow () = asExecutorService.shutdownNow()
Original file line number Diff line number Diff line change @@ -1027,6 +1027,26 @@ trait ExecutionContextPrepare extends TestBase {
10271027 testMap()
10281028}
10291029
1030+ trait ExecutorServiceExecutionContext extends TestBase {
1031+ import java .util .concurrent .Executors
1032+ import scala .concurrent .duration ._
1033+
1034+ def testExecutorServiceEC (): Unit =
1035+ once { done =>
1036+ val ec = ExecutionContext .fromExecutorService(Executors .newCachedThreadPool)
1037+ val p = Promise [Boolean ]()
1038+ ec.execute(new Runnable {
1039+ def run (): Unit = p.success(true )
1040+ })
1041+ assert(Await .result(p.future, 2 .seconds))
1042+ ec.shutdown()
1043+ assert(true )
1044+ done()
1045+ }
1046+
1047+ testExecutorServiceEC()
1048+ }
1049+
10301050object Test
10311051extends App
10321052with FutureCallbacks
@@ -1037,6 +1057,7 @@ with BlockContexts
10371057with Exceptions
10381058with CustomExecutionContext
10391059with ExecutionContextPrepare
1060+ with ExecutorServiceExecutionContext
10401061{
10411062 System .exit(0 )
10421063}
You can’t perform that action at this time.
0 commit comments