Add eventflag_wait_all.

This commit is contained in:
NIIBE Yutaka
2018-11-09 16:04:17 +09:00
parent fffb8aa3b3
commit 2992b894e0
3 changed files with 17 additions and 1 deletions

View File

@@ -1,3 +1,7 @@
2018-11-09 NIIBE Yutaka <gniibe@fsij.org>
* eventflag.c (eventflag_wait_all): New.
2018-10-02 NIIBE Yutaka <gniibe@fsij.org>
* VERSION: 1.11.

View File

@@ -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 <gniibe@fsij.org>
*
* 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)
{

View File

@@ -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);