• Robert Sesek's avatar
    Reimplement base::WaitableEvent with Mach messaging on Mac. · d54c0c1e
    Robert Sesek authored
    A WaitableEvent is now a Mach port with a message queue length of one.
    Signaling the event enqueues an empty message on the port, or times out
    if one is already queued. Waiting on the event receives a message on the
    port, dequeuing it if the event is auto-reset, or just peeking it if the
    event is manual-reset.
    
    WaitMany is implemented by adding all the events' ports to a port set and
    receiving on it.
    
    WaitableEventWatcher is implemented using a TYPE_MACH_RECV dispatch source
    for auto-reset events and manual-reset events on 10.12. For manual-reset
    events on macOS prior to 10.12, a lock-protected list of watcher callbacks is
    used instead of dispatch, because dispatch does not provide timely and
    reliable invocation callbacks if the event were to be Reset() immediately after
    Signal().
    
    Bug: 681167
    Change-Id: I22a9294ad0ae8900d16716d8033285fe91510eda
    Reviewed-on: https://chromium-review.googlesource.com/592516
    Commit-Queue: Robert Sesek <rsesek@chromium.org>
    Reviewed-by: default avatarMark Mentovai <mark@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#491860}
    d54c0c1e
waitable_event_mac.cc 8.18 KB