You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: overviews/core/_posts/2012-09-20-futures.md
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -200,13 +200,13 @@ once.
200
200
Once a `Future` object is given a value or an exception, it becomes
201
201
in effect immutable-- it can never be overwritten.
202
202
203
-
The simplest way to create a future object is to invoke the `Future`
203
+
The simplest way to create a future object is to invoke the `Future.apply`
204
204
method which starts an asynchronous computation and returns a
205
205
future holding the result of that computation.
206
206
The result becomes available once the future completes.
207
207
208
208
Note that `Future[T]` is a type which denotes future objects, whereas
209
-
`Future` is a method which creates and schedules an asynchronous
209
+
`Future.apply` is a method which creates and schedules an asynchronous
210
210
computation, and then returns a future object which will be completed
211
211
with the result of that computation.
212
212
@@ -226,7 +226,7 @@ a request to obtain a list of friends of a particular user:
226
226
}
227
227
228
228
Above, we first import the contents of the `scala.concurrent` package
229
-
to make the type `Future`and the construct `Future`visible.
229
+
to make the type `Future` visible.
230
230
We will explain the second import shortly.
231
231
232
232
We then initialize a session variable which we will use to send
@@ -237,7 +237,7 @@ has to be sent over a network, which can take a long time.
237
237
This is illustrated with the call to the method `getFriends` that returns `List[Friend]`.
238
238
To better utilize the CPU until the response arrives, we should not
239
239
block the rest of the program-- this computation should be scheduled
240
-
asynchronously. The `Future` method does exactly that-- it performs
240
+
asynchronously. The `Future.apply` method does exactly that-- it performs
241
241
the specified computation block concurrently, in this case sending
242
242
a request to the server and waiting for a response.
243
243
@@ -258,7 +258,7 @@ The line `import ExecutionContext.Implicits.global` above imports
258
258
the default global execution context.
259
259
Execution contexts execute tasks submitted to them, and
260
260
you can think of execution contexts as thread pools.
261
-
They are essential for the `Future` method because
261
+
They are essential for the `Future.apply` method because
262
262
they handle how and when the asynchronous computation is executed.
263
263
You can define your own execution contexts and use them with `Future`,
264
264
but for now it is sufficient to know that
@@ -749,7 +749,7 @@ the throwable types it matches.
749
749
-->
750
750
751
751
<!--
752
-
Invoking the `Future` construct uses a global execution context to start an asynchronous computation. In the case the client desires to use a custom execution context to start an asynchronous computation:
752
+
Invoking the `Future.apply` construct uses a global execution context to start an asynchronous computation. In the case the client desires to use a custom execution context to start an asynchronous computation:
0 commit comments