What is a future and how does it work?
developIn programming, a future is an abstraction for a value that may become available at some point in the future. A future exists in one of two states:
- Unresolved: The value is not yet available. If you attempt to access the value while the future is unresolved, the current R process will block (wait) until the future is resolved.
- Resolved: The value is available and can be accessed instantaneously.
How and when a future is resolved depends on the chosen strategy (via plan()). Strategies can range from sequential (evaluating in the current R session) to asynchronous (evaluating in parallel on the local machine or on a compute cluster).
Using asynchronous futures allows the main R process to continue executing other tasks while the future is being resolved in the background, providing a powerful mechanism for parallel and distributed processing.