1313extern "C" {
1414#endif
1515
16- // Similar to emscripten_async_wait_callback_t but with a volatile first
17- // argument.
18- typedef void (* emscripten_async_wait_volatile_callback_t )(volatile void * address , uint32_t value , ATOMICS_WAIT_RESULT_T waitResult , void * userData );
19-
2016#define emscripten_lock_t volatile uint32_t
2117
2218// Use with syntax "emscripten_lock_t l = EMSCRIPTEN_LOCK_T_STATIC_INITIALIZER;"
@@ -34,7 +30,6 @@ void emscripten_lock_init(emscripten_lock_t * _Nonnull lock);
3430// NOTE: This function can be only called in a Worker, and not on the main
3531// browser thread, because the main browser thread cannot synchronously
3632// sleep to wait for locks.
37-
3833bool emscripten_lock_wait_acquire (emscripten_lock_t * _Nonnull lock , int64_t maxWaitNanoseconds );
3934
4035// Similar to emscripten_lock_wait_acquire(), but instead of waiting for at most
@@ -74,6 +69,10 @@ bool emscripten_lock_busyspin_wait_acquire(emscripten_lock_t * _Nonnull lock, do
7469// acquire without contention from other threads.
7570void emscripten_lock_busyspin_waitinf_acquire (emscripten_lock_t * _Nonnull lock );
7671
72+ // Similar to emscripten_async_wait_callback_t but with a volatile first
73+ // argument.
74+ typedef void (* emscripten_async_wait_volatile_callback_t )(volatile void * address , uint32_t value , ATOMICS_WAIT_RESULT_T waitResult , void * userData );
75+
7776// Registers an *asynchronous* lock acquire operation. The calling thread will
7877// asynchronously try to obtain the given lock after the calling thread yields
7978// back to the event loop. If the attempt is successful within
@@ -187,6 +186,16 @@ ATOMICS_WAIT_TOKEN_T emscripten_condvar_wait_async(emscripten_condvar_t * _Nonnu
187186// ("broadcast" operation).
188187void emscripten_condvar_signal (emscripten_condvar_t * _Nonnull condvar , int64_t numWaitersToSignal );
189188
189+ // If the given memory address contains value val, puts the calling thread to
190+ // sleep waiting for that address to be notified.
191+ // Returns -EINVAL if addr is null.
192+ int emscripten_futex_wait (volatile void /*uint32_t*/ * _Nonnull addr , uint32_t val , double maxWaitMilliseconds );
193+
194+ // Wakes the given number of threads waiting on a location. Pass count ==
195+ // INT_MAX to wake all waiters on that location.
196+ // Returns -EINVAL if addr is null.
197+ int emscripten_futex_wake (volatile void /*uint32_t*/ * _Nonnull addr , int count );
198+
190199#ifdef __cplusplus
191200}
192201#endif
0 commit comments