Skip to content

Fix formatting of code snippets in Future docs #787

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 2, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions overviews/core/_posts/2012-09-20-futures.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ As explained in the `ForkJoinPool` API, this is only possible if the pool is exp
Fortunately the concurrent package provides a convenient way for doing so:

import scala.concurrent.Future
import scala.concurrent.blocking
import scala.concurrent.blocking

Future {
blocking {
Expand Down Expand Up @@ -165,16 +165,16 @@ One might be tempted to have an `ExecutionContext` that runs computations within

val currentThreadExecutionContext = ExecutionContext.fromExecutor(
new Executor {
// Do not do this!
// Do not do this!
def execute(runnable: Runnable) { runnable.run() }
})

This should be avoided as it introduces non-determinism in the execution of your future.

Future {
doSomething
}(ExecutionContext.global).map {
doSomethingElse
doSomething
}(ExecutionContext.global).map {
doSomethingElse
}(currentThreadExecutionContext)

The `doSomethingElse` call might either execute in `doSomething`'s thread or in the main thread, and therefore be either asynchronous or synchronous.
Expand Down