• Sven Over's avatar
    fix dead-lock in Future when executor discards function · 08a2ff01
    Sven Over authored
    Summary:
    This diff adds two tests to futures/test/ViaTest.cpp:
    viaDummyExecutorFutureSetValueFirst and
    viaDummyExecutorFutureSetCallbackFirst. The latter resulted in a
    dead-lock before the fix contained in this diff.
    
    It is important that the callback function is destroyed after
    it is executed, since it may capture objects (like a Promise)
    that should be destroyed (so that e.g. a corresponding Future
    throws BrokenPromise). When the callback is executed via an
    executor, it is possible that the executor doesn't get around to
    executing the task. We shouldn't rely on the task being executed
    to do necessary clean-up. That clean-up should (also) happen
    when the task (with its captured data) is destroyed (in the
    spirit of RIAA).
    
    Reviewed By: djwatson
    
    Differential Revision: D4779215
    
    fbshipit-source-id: d029cf8b8f7b55e1b03357749c5fb62d95986ca7
    08a2ff01
Core.h 13.8 KB