From 2992b894e04df8c84a5cccb803566ebd5bafb91d Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Fri, 9 Nov 2018 16:04:17 +0900 Subject: [PATCH] Add eventflag_wait_all. --- ChangeLog | 4 ++++ eventflag.c | 13 ++++++++++++- eventflag.h | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 71338e3..26dfcf9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2018-11-09 NIIBE Yutaka + + * eventflag.c (eventflag_wait_all): New. + 2018-10-02 NIIBE Yutaka * VERSION: 1.11. diff --git a/eventflag.c b/eventflag.c index c6a871e..2691713 100644 --- a/eventflag.c +++ b/eventflag.c @@ -1,7 +1,7 @@ /* * eventflag.c - Eventflag * - * Copyright (C) 2013, 2016 Flying Stone Technology + * Copyright (C) 2013, 2016, 2018 Flying Stone Technology * Author: NIIBE Yutaka * * This file is a part of Chopstx, a thread library for embedded. @@ -107,6 +107,17 @@ eventflag_wait (struct eventflag *ev) } +void +eventflag_wait_all (struct eventflag *ev, eventmask_t m) +{ + chopstx_mutex_lock (&ev->mutex); + while ((ev->flags & m) != m) + chopstx_cond_wait (&ev->cond, &ev->mutex); + ev->flags &= ~m; + chopstx_mutex_unlock (&ev->mutex); +} + + eventmask_t eventflag_wait_timeout (struct eventflag *ev, uint32_t usec) { diff --git a/eventflag.h b/eventflag.h index 35beb43..f1bc074 100644 --- a/eventflag.h +++ b/eventflag.h @@ -8,6 +8,7 @@ struct eventflag { void eventflag_init (struct eventflag *ev); eventmask_t eventflag_wait (struct eventflag *ev); +void eventflag_wait_all (struct eventflag *ev, eventmask_t m); eventmask_t eventflag_wait_timeout (struct eventflag *ev, uint32_t usec); void eventflag_signal (struct eventflag *ev, eventmask_t m);