From df51c6dc6489b77c21804a66f6e89e4a7b9e7275 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Fri, 9 Mar 2018 19:15:31 +0100 Subject: [PATCH] Add m_cond_broad_cast --- README.md | 9 ++++++++- m-mutex.h | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0e1a3ac4..caa6cd7b 100644 --- a/README.md +++ b/README.md @@ -4072,7 +4072,14 @@ If the variable is not initialized, the behavior is undefined. Within a mutex exclusive section, signal that the event associated to the variable cond of type m\_cond\_t -has occured to other threads. +has occured to at least a single thread. +If the variable is not initialized, the behavior is undefined. + +##### void m\_cond\_broadcast(m\_cond\_t cond) + +Within a mutex exclusive section, +signal that the event associated to the variable cond of type m\_cond\_t +has occured to all waiting threads. If the variable is not initialized, the behavior is undefined. ##### void m\_cond\_wait(m\_cond\_t cond, m\_mutex\_t mutex) diff --git a/m-mutex.h b/m-mutex.h index c5c0cb56..e14a05bd 100644 --- a/m-mutex.h +++ b/m-mutex.h @@ -77,6 +77,16 @@ static inline void m_cond_clear(m_cond_t c) cnd_signal(c); } +static inline void m_cond_signal(m_cond_t c) +{ + cnd_signal(c); +} + +static inline void m_cond_broadcast(m_cond_t c) +{ + cnd_broadcast(c); +} + static inline void m_cond_wait(m_cond_t c, m_mutex_t m) { cnd_wait(c, m); @@ -169,6 +179,11 @@ static inline void m_cond_signal(m_cond_t c) PulseEvent(*c); } +static inline void m_cond_broadcast(m_cond_t c) +{ + PulseEvent(*c); +} + static inline void m_cond_wait(m_cond_t c, m_mutex_t m) { DWORD dwWaitResult = SignalObjectAndWait(*m, *c, INFINITE,FALSE); @@ -245,6 +260,11 @@ static inline void m_cond_signal(m_cond_t c) pthread_cond_signal(c); } +static inline void m_cond_broadcast(m_cond_t c) +{ + pthread_cond_broadcast(c); +} + static inline void m_cond_wait(m_cond_t c, m_mutex_t m) { pthread_cond_wait(c, m);