Skip to content

Instantly share code, notes, and snippets.

@girish3
Created September 30, 2018 12:43
Show Gist options
  • Save girish3/5d32a3f8124e3a4dcf7e2b43c201a3cb to your computer and use it in GitHub Desktop.
Save girish3/5d32a3f8124e3a4dcf7e2b43c201a3cb to your computer and use it in GitHub Desktop.
[Futures and Promises] #design_pattern

In the broadest sense,

  • A future or promise can be thought of as a value that will eventually become available.
  • Future is used for sychronizing program execution.
  • Future acts as a proxy for an result which will be eventually available.
  • The construct ( future X ) immediately returns a future for the value of the expression X and concurrently begins evaluating X. When the evaluation of X yields a value, that value replaces the future.
  • A future is a placeholder object for a result that does not yet exist. A promise is a writable, single-assignment container, which completes a future. Promises can complete the future with a result to indicate success, or with an exception to indicate failure.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment