Skip to content

Commit 1810ac0

Browse files
committed
Merge pull request #4132 from phaller/ticket/7444
SI-7444 docs: null Executor allowed in ExecutionContext factories
2 parents 74046bb + a6e77f7 commit 1810ac0

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/library/scala/concurrent/ExecutionContext.scala

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,9 @@ object ExecutionContext {
110110
* The explicit global `ExecutionContext`. Invoke `global` when you want to provide the global
111111
* `ExecutionContext` explicitly.
112112
*
113-
* The default `ExecutionContext` implementation is backed by a port of
114-
* [[http://gee.cs.oswego.edu/dl/jsr166/dist/jsr166-4jdk7docs/java/util/concurrent/ForkJoinPool.html java.util.concurrent.ForkJoinPool]].
113+
* The default `ExecutionContext` implementation is backed by a work-stealing thread pool. By default,
114+
* the thread pool uses a target number of worker threads equal to the number of
115+
* [[https://docs.oracle.com/javase/8/docs/api/java/lang/Runtime.html#availableProcessors-- available processors]].
115116
*
116117
* @return the global `ExecutionContext`
117118
*/
@@ -122,15 +123,16 @@ object ExecutionContext {
122123
* The implicit global `ExecutionContext`. Import `global` when you want to provide the global
123124
* `ExecutionContext` implicitly.
124125
*
125-
* The default `ExecutionContext` implementation is backed by a port of
126-
* [[http://gee.cs.oswego.edu/dl/jsr166/dist/jsr166-4jdk7docs/java/util/concurrent/ForkJoinPool.html java.util.concurrent.ForkJoinPool]].
126+
* The default `ExecutionContext` implementation is backed by a work-stealing thread pool. By default,
127+
* the thread pool uses a target number of worker threads equal to the number of
128+
* [[https://docs.oracle.com/javase/8/docs/api/java/lang/Runtime.html#availableProcessors-- available processors]].
127129
*/
128130
implicit lazy val global: ExecutionContextExecutor = impl.ExecutionContextImpl.fromExecutor(null: Executor)
129131
}
130132

131133
/** Creates an `ExecutionContext` from the given `ExecutorService`.
132134
*
133-
* @param e the `ExecutorService` to use
135+
* @param e the `ExecutorService` to use. If `null`, a new `ExecutorService` is created with [[http://www.scala-lang.org/api/current/index.html#scala.concurrent.ExecutionContext$@global:scala.concurrent.ExecutionContextExecutor default configuration]].
134136
* @param reporter a function for error reporting
135137
* @return the `ExecutionContext` using the given `ExecutorService`
136138
*/
@@ -147,14 +149,14 @@ object ExecutionContext {
147149
* val ec = ExecutionContext.fromExecutorService(Executors.newSingleThreadExecutor())
148150
* }}}
149151
*
150-
* @param e the `ExecutorService` to use
152+
* @param e the `ExecutorService` to use. If `null`, a new `ExecutorService` is created with [[http://www.scala-lang.org/api/current/index.html#scala.concurrent.ExecutionContext$@global:scala.concurrent.ExecutionContextExecutor default configuration]].
151153
* @return the `ExecutionContext` using the given `ExecutorService`
152154
*/
153155
def fromExecutorService(e: ExecutorService): ExecutionContextExecutorService = fromExecutorService(e, defaultReporter)
154156

155157
/** Creates an `ExecutionContext` from the given `Executor`.
156158
*
157-
* @param e the `Executor` to use
159+
* @param e the `Executor` to use. If `null`, a new `Executor` is created with [[http://www.scala-lang.org/api/current/index.html#scala.concurrent.ExecutionContext$@global:scala.concurrent.ExecutionContextExecutor default configuration]].
158160
* @param reporter a function for error reporting
159161
* @return the `ExecutionContext` using the given `Executor`
160162
*/
@@ -163,7 +165,7 @@ object ExecutionContext {
163165

164166
/** Creates an `ExecutionContext` from the given `Executor` with the [[scala.concurrent.ExecutionContext$.defaultReporter default reporter]].
165167
*
166-
* @param e the `Executor` to use
168+
* @param e the `Executor` to use. If `null`, a new `Executor` is created with [[http://www.scala-lang.org/api/current/index.html#scala.concurrent.ExecutionContext$@global:scala.concurrent.ExecutionContextExecutor default configuration]].
167169
* @return the `ExecutionContext` using the given `Executor`
168170
*/
169171
def fromExecutor(e: Executor): ExecutionContextExecutor = fromExecutor(e, defaultReporter)

0 commit comments

Comments
 (0)