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 {
115
115
116
116
def fromExecutorService (es : ExecutorService , reporter : Throwable => Unit = ExecutionContext .defaultReporter): ExecutionContextImpl with ExecutionContextExecutorService =
117
117
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 ]
119
119
override def execute (command : Runnable ) = executor.right.get.execute(command)
120
120
override def shutdown () { asExecutorService.shutdown() }
121
121
override def shutdownNow () = asExecutorService.shutdownNow()
Original file line number Diff line number Diff line change @@ -1027,6 +1027,26 @@ trait ExecutionContextPrepare extends TestBase {
1027
1027
testMap()
1028
1028
}
1029
1029
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
+
1030
1050
object Test
1031
1051
extends App
1032
1052
with FutureCallbacks
@@ -1037,6 +1057,7 @@ with BlockContexts
1037
1057
with Exceptions
1038
1058
with CustomExecutionContext
1039
1059
with ExecutionContextPrepare
1060
+ with ExecutorServiceExecutionContext
1040
1061
{
1041
1062
System .exit(0 )
1042
1063
}
You can’t perform that action at this time.
0 commit comments