Skip to content
TobiasWrigstad edited this page Dec 24, 2014 · 8 revisions

Thoughts on Self-Fulfilled Future

Self-fulfilled future: a future resulting from an asynchronous self-send.

Blocking on a self-fulfilled future may cause deadlocks.

Hence, blocking on a self-fulfilled future must be treated differently.

Scenario 1:

Actor A calls method M on itself asynchronously which returns a self-fulfilled future F. Getting on F could be implemented by running M in the current thread producing the future F value.

Scenario 2:

Actor A calls method M on actor B which returns a future F. A subsequently chains closure C on F which returns a self-fulfilled (*) future G. Getting on G cannot be implemented by the same strategy as Scenario 1 as the future F value on which the future G value depends may not yet have been produced.

(*) G is self-fulfilled because C will eventually be executed by A because C can capture mutable state in A.

Clone this wiki locally