What are futures?

后端 未结 7 1715
梦毁少年i
梦毁少年i 2021-02-13 09:29

What are futures? It\'s something to do with lazy evaluation.

7条回答
  •  天涯浪人
    2021-02-13 10:12

    The Wiki Article gives a good overview of Futures. The concept is generally used in concurrent systems, for scheduling computations over values that may or may not have been computed yet, and further, whose computation may or may not already be in progress.

    From the article:

    A future is associated with a specific thread that computes its value. This computation may be started either eagerly when the future is created, or lazily when its value is first needed.

    Not mentioned in the article, futures are a Monad, and so it is possible to project functions on future values into the monad to have them applied to the future value when it becomes available, yielding another future which in turn represents the result of that function.

提交回复
热议问题