• Phil Willoughby's avatar
    Convert a polling loop to a futex wait · d43e710c
    Phil Willoughby authored
    Summary:Add a new method to MPMCQueue:
    ```
    template <class Clock, typename... Args>
      bool tryWriteUntil(const std::chrono::time_point<Clock>& when,
                         Args&&... args) noexcept
    ```
    This allows you to write producers which terminate reliably in the absence of consumers.
    
    Returns `true` if `args` was enqueued, `false` otherwise.
    
    `Clock` must be one of the types supported by the underlying call to `folly::detail::Futex::futexWaitUntil`; at time of writing these are `std::chrono::steady_clock` and `std::chrono::system_clock`.
    
    Reviewed By: nbronson
    
    Differential Revision: D2895574
    
    fb-gh-sync-id: bdfabcd043191c149f1271e30ffc28476cc8a36e
    shipit-source-id: bdfabcd043191c149f1271e30ffc28476cc8a36e
    d43e710c
TurnSequencer.h 10.2 KB