kernel/os: Add os_eventq_get_no_wait function This function is needed in interrupt context for quick queue polls.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/10d350c5 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/10d350c5 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/10d350c5 Branch: refs/heads/master Commit: 10d350c5ebb751a371fae7c0d2c73a80af4c2d45 Parents: 271ab1b Author: MichaÅ Narajowski <michal.narajow...@codecoup.pl> Authored: Fri Jan 27 16:01:20 2017 +0100 Committer: MichaÅ Narajowski <michal.narajow...@codecoup.pl> Committed: Mon Apr 24 09:27:37 2017 -0700 ---------------------------------------------------------------------- kernel/os/include/os/os_eventq.h | 1 + kernel/os/src/os_eventq.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/10d350c5/kernel/os/include/os/os_eventq.h ---------------------------------------------------------------------- diff --git a/kernel/os/include/os/os_eventq.h b/kernel/os/include/os/os_eventq.h index 2ae779c..812d822 100644 --- a/kernel/os/include/os/os_eventq.h +++ b/kernel/os/include/os/os_eventq.h @@ -49,6 +49,7 @@ struct os_eventq { void os_eventq_init(struct os_eventq *); int os_eventq_inited(const struct os_eventq *evq); void os_eventq_put(struct os_eventq *, struct os_event *); +struct os_event *os_eventq_get_no_wait(struct os_eventq *evq); struct os_event *os_eventq_get(struct os_eventq *); void os_eventq_run(struct os_eventq *evq); struct os_event *os_eventq_poll(struct os_eventq **, int, os_time_t); http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/10d350c5/kernel/os/src/os_eventq.c ---------------------------------------------------------------------- diff --git a/kernel/os/src/os_eventq.c b/kernel/os/src/os_eventq.c index 626d560..ed9aa37 100644 --- a/kernel/os/src/os_eventq.c +++ b/kernel/os/src/os_eventq.c @@ -96,6 +96,20 @@ os_eventq_put(struct os_eventq *evq, struct os_event *ev) } } +struct os_event * +os_eventq_get_no_wait(struct os_eventq *evq) +{ + struct os_event *ev; + + ev = STAILQ_FIRST(&evq->evq_list); + if (ev) { + STAILQ_REMOVE(&evq->evq_list, ev, os_event, ev_next); + ev->ev_queued = 0; + } + + return ev; +} + /** * Pull a single item from an event queue. This function blocks until there * is an item on the event queue to read.