diff options
author | Nicolas Pennequin <nicolas.pennequin@free.fr> | 2007-10-27 18:08:18 +0000 |
---|---|---|
committer | Nicolas Pennequin <nicolas.pennequin@free.fr> | 2007-10-27 18:08:18 +0000 |
commit | 1839edf64ad0a4b6d96a5dd5ce24ab8075954dc6 (patch) | |
tree | 6b31c67e9168ae2c47eba9f3205f69bdd1328d42 /firmware/kernel.c | |
parent | 41add08c5edb9d3de7e223e860cef035b41a3b01 (diff) | |
download | rockbox-1839edf64ad0a4b6d96a5dd5ce24ab8075954dc6.tar.gz rockbox-1839edf64ad0a4b6d96a5dd5ce24ab8075954dc6.zip |
Add queue_peek to the kernel (written by Mike Sevakis), and use it to improve upon my previous commit.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15336 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/kernel.c')
-rw-r--r-- | firmware/kernel.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/firmware/kernel.c b/firmware/kernel.c index 006a06dfe0..25249c6148 100644 --- a/firmware/kernel.c +++ b/firmware/kernel.c | |||
@@ -537,6 +537,28 @@ bool queue_empty(const struct event_queue* q) | |||
537 | return ( q->read == q->write ); | 537 | return ( q->read == q->write ); |
538 | } | 538 | } |
539 | 539 | ||
540 | bool queue_peek(struct event_queue *q, struct queue_event *ev) | ||
541 | { | ||
542 | if (q->read == q->write) | ||
543 | return false; | ||
544 | |||
545 | bool have_msg = false; | ||
546 | |||
547 | int oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL); | ||
548 | corelock_lock(&q->cl); | ||
549 | |||
550 | if (q->read != q->write) | ||
551 | { | ||
552 | *ev = q->events[q->read & QUEUE_LENGTH_MASK]; | ||
553 | have_msg = true; | ||
554 | } | ||
555 | |||
556 | corelock_unlock(&q->cl); | ||
557 | set_irq_level(oldlevel); | ||
558 | |||
559 | return have_msg; | ||
560 | } | ||
561 | |||
540 | void queue_clear(struct event_queue* q) | 562 | void queue_clear(struct event_queue* q) |
541 | { | 563 | { |
542 | int oldlevel; | 564 | int oldlevel; |