October 2018
Intermediate to advanced
420 pages
10h 26m
English
A Future is an object that is used to store a value that is not available when the future is created, but that will be available at a later time. This is an alternative to callbacks in the typical use case of executing an asynchronous action. An asynchronous function is called, so its return value is not available yet. One way to deal with this is to provide a callback that will be called when the action completes. Another option is to return a future in the asynchronous function and set the result of the action in future once the action has completed. The caller of the asynchronous function can then be notified when future is set.
The following figure shows how a Future object can be used: