Skip to content

Update libcxx wait/notify_one/notify_all to use WaitOnAddress/WakeByAddressSingle/WakeByAddressAll on Windows #127221

Closed

Description

@johnplatts

Windows 8 had introduced the WaitOnAddress, WakeByAddressSingle, and WakeByAddressAll functions that can be used to implement __libcpp_platform_wait_on_address and __libcpp_platform_wake_by_address on Windows.

Should a Windows-specific implementation of __libcpp_platform_wait_on_address and __libcpp_platform_wake_by_address that uses the WaitOnAddress/WakeByAddressSingle/WakeByAddressAll APIs be added to libcxx/src/atomic.cpp (although this change requires Windows 8 or later or Windows Server 2012 or later)?

Activity

  1. added
    libc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
    on Feb 14, 2025
  2. johnplatts commented on Mar 13, 2025

    @johnplatts
    Author

    @ldionne Should I go ahead and implement __libcpp_platform_wait_on_address using WaitOnAddress on Windows and implement __libcpp_platform_wake_by_address using WakeByAddressSingle/WakeByAddressAll on Windows (this change will require Windows 8 or later along with linking with libsynchronization.a or synchronization.lib)?

    Changes also need to be made to clang/lib/Driver/ToolChains/MinGW.cpp to ensure that C++ applications or DLL's that statically link against libc++ also link against libsynchronization.lib.

  3. RogerSanders commented on Oct 14, 2025

    @RogerSanders
    Contributor

    Any updates/progress here? I ran into this landmine a few days ago, where using std::atomic_flag wait()/notify_all() for thread synchronization resulted in a 2-3x overall program slowdown vs using std::condition_variable, due specifically to the very inefficient implementation here on Windows. The Microsoft STL has this implemented with a platform check, using WaitOnAddress / WakeByAddressSingle / WakeByAddressAll on Windows 8+, with an efficient fallback using some static memory to hold synchronization primitives for earlier platforms. It should be possible to do the same thing here.

  4. added a commit that references this issue on Oct 15, 2025
    63ee5da
  5. added a commit that references this issue on Nov 13, 2025
    478e45f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    libc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.platform:windows

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions