• Benoit Lize's avatar
    [PartitionAlloc] Extend SpinningFutex to Windows. · d7f053aa
    Benoit Lize authored
    SpinningFutex is essentially an OS-provided lock with spinning in
    userspace before sleeping. This is implemented on Linux using futex(),
    which is not available on Windows. However, SRWLocks have the
    TryAcquireSRWLockExclusive() function which is functionally equivalent
    to the userspace CAS for futex()s.
    
    This CL:
    - Renames SpinningFutex to SpinningMutex
    - Extracts the common code
    - Extends it to Windows by using SRWLock instead of futex()
    
    The fast path is likely a bit slower than on Linux, as there is still an
    external function call, but it should be pretty comparable.
    
    Bug: 1061437
    Change-Id: I7d71055865568738a569d7252f38a7a6773795e0
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2467916
    Commit-Queue: Benoit L <lizeb@chromium.org>
    Reviewed-by: default avatarBartek Nowierski <bartekn@chromium.org>
    Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#816987}
    d7f053aa
spinning_mutex.cc 2.71 KB