File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
src/library/scala/concurrent/impl
test/files/jvm/future-spec Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ private[concurrent] object Future {
2828
2929 def apply [T ](body : => T )(implicit executor : ExecutionContext ): scala.concurrent.Future [T ] = {
3030 val runnable = new PromiseCompletingRunnable (body)
31- executor.execute(runnable)
31+ executor.prepare. execute(runnable)
3232 runnable.promise.future
3333 }
3434}
Original file line number Diff line number Diff line change @@ -71,6 +71,25 @@ object FutureTests extends MinimalScalaTest {
7171 }
7272 }
7373
74+ " The Future companion object" should {
75+ " call ExecutionContext.prepare on apply" in {
76+ val p = Promise [Boolean ]()
77+ val ec = new ExecutionContext {
78+ val delegate = ExecutionContext .global
79+ override def prepare (): ExecutionContext = {
80+ p.success(true )
81+ delegate.prepare
82+ }
83+ override def execute (r : Runnable ) = delegate.execute(r)
84+ override def reportFailure (t : Throwable ): Unit = delegate.reportFailure(t)
85+ }
86+
87+ val f = Future (" foo" )(ec)
88+ Await .result(f, defaultTimeout) mustBe (" foo" )
89+ Await .result(p.future, defaultTimeout) mustBe (true )
90+ }
91+ }
92+
7493 " The default ExecutionContext" should {
7594 " report uncaught exceptions" in {
7695 val p = Promise [Throwable ]()
You can’t perform that action at this time.
0 commit comments