• Lewis Baker's avatar
    Change folly::fibers::Semaphore to use an intrusive list of waiters · f8a3d164
    Lewis Baker authored
    Summary:
    Now use an intrusive list structure to store the list of waiters waiting
    for the semaphore to be signalled.
    
    This is primarily motivated by the need to support efficient cancellation,
    which requires the ability to efficiently remove a specific element from
    the waiter list without having to scan the list like we would for the
    existing `std::deque`-based list storage.
    
    Another beneift of this change is that it now eliminates memory allocations
    that were previously required by the std::deque container.
    
    The `Semaphore::future_wait()` implementation should now also have one fewer
    allocations as the allocation of the Baton and the Baton::Waiter are now fused.
    
    Reviewed By: yfeldblum
    
    Differential Revision: D21692257
    
    fbshipit-source-id: 9beff176b250ae3f37df9e2138f93b15d2607353
    f8a3d164
Semaphore.h 2.48 KB