MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / __libcpp_contention_wait

Function __libcpp_contention_wait

system/lib/libcxx/src/atomic.cpp:151–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149 return __cxx_atomic_load(__platform_state, memory_order_acquire);
150}
151static void __libcpp_contention_wait(__cxx_atomic_contention_t volatile* __contention_state,
152 __cxx_atomic_contention_t const volatile* __platform_state,
153 __cxx_contention_t __old_value) {
154 __cxx_atomic_fetch_add(__contention_state, __cxx_contention_t(1), memory_order_relaxed);
155 // https://github.com/llvm/llvm-project/issues/109290
156 // There are no platform guarantees of a memory barrier in the platform wait implementation
157 __cxx_atomic_thread_fence(memory_order_seq_cst);
158 // We sleep as long as the monitored value hasn't changed.
159 __libcpp_platform_wait_on_address(__platform_state, __old_value);
160 __cxx_atomic_fetch_sub(__contention_state, __cxx_contention_t(1), memory_order_release);
161}
162
163/* When the incoming atomic is the wrong size for the platform wait size, need to
164 launder the value sequence through an atomic from our table. */

Callers 1

__libcpp_atomic_waitFunction · 0.85

Calls 4

__cxx_atomic_fetch_addFunction · 0.50
__cxx_atomic_fetch_subFunction · 0.50

Tested by

no test coverage detected