-
Notifications
You must be signed in to change notification settings - Fork 1k
Execution context #304
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
Execution context #304
Conversation
|
||
### The Global Execution Context | ||
|
||
`ExecutionContext.global` is an `ExecutionContext` backed by a [ForkJoinPool](http://docs.oracle.com/javase/tutorial/essential/concurrency/forkjoin.html). It should be sufficient for most situations but requires some care. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look i've changed the link. But you might want to remove it as it points at http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ForkJoinPool.html ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there is a license problem with pointing back to Oracle's Java documentation.
Please break these two sentences into two lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm having second thoughts about mentioning FJ pool here.
The current ExecutionContext.global
implementation, even though it's unlikely to change,
should be mentioned at most in the ScalaDoc API.
Otherwise, our documentation is too flaky, and it becomes hard to maintain the crossreferences.
This doc should discuss only the high-level usage and meaning of execution contexts,
not the specific implementation.
It is also unclear if we should mention minThreads
, numThreads
and maxThreads
configuration settings,
since they are not mentioned explicitly in the API docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest that you refactor this section, so that all mention of ForkJoinPool
is put in a separate section,
entitled e.g. "Execution Contexts based on Fork/Join Pools".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree, references of ExecutionContext.global
are all over that documentation. So you might be right in theory, but in practice people will be using (and abusing) the global EC. Documenting how this works and flagging potential issues isn't low-level details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest that you refactor this section, so that all mention of ForkJoinPool is put in a separate section,
entitled e.g. "Execution Contexts based on Fork/Join Pools".
That's actually what I did by wrapping FJP details into the The Global Execution Context
section.
review by @viktorklang and @axel22? |
@@ -36,6 +36,134 @@ in the case of an application which requires blocking futures, for an underlying | |||
environment to resize itself if necessary to guarantee progress. | |||
--> | |||
|
|||
A typical future look like this: | |||
|
|||
val inverseFuture : Future[Matrix] = Future { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We normally write the type ascription immediately after the identifier, without the space:
val inverseFuture: Future[Matrix] = ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend making the example take the EC as an implicit parameter to foster a culture of getting the EC passed in rather than defining it locally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree - the more idiomatic version below could be sufficient.
Thanks a lot for taking the effort to improve the documentation to this extent! |
Futures provide a way to reason about performing many operations | ||
in parallel-- in an efficient and non-blocking way. | ||
A [Future](http://www.scala-lang.org/api/current/index.html#scala.concurrent.Future) | ||
is a sort of a placeholder object that you can create for a result that does not yet exist. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest:
is a placeholder object for a value that may not yet exist.
@backuitist interested in getting this across the finish line...? |
Sorry, that went off my radar. |
a34a8a3
to
ec26bab
Compare
ec26bab
to
c690c20
Compare
@axel22 @viktorklang lgty now? |
I would fix that one last colon, but it looks good to me. |
c690c20
to
c346d1e
Compare
yay, across the finish line! thank you @backuitist for your great patience, thank you reviewers. (@viktorklang, it's of course not too late for further changes.) |
@SethTisue :-) |
I've integrated some of your comments ;)