forked from len0rd/rockbox
Added queue handling stuff - NOT INTERRUPT SAFE
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@315 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
40c1c2251a
commit
bd2561dcbb
2 changed files with 46 additions and 0 deletions
|
@ -35,3 +35,30 @@ void yield(void)
|
|||
{
|
||||
switch_thread();
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Queue handling stuff
|
||||
****************************************************************************/
|
||||
void queue_init(struct event_queue *q)
|
||||
{
|
||||
q->read = 0;
|
||||
q->write = 0;
|
||||
}
|
||||
|
||||
struct event *queue_wait(struct event_queue *q)
|
||||
{
|
||||
while(q->read == q->write)
|
||||
{
|
||||
switch_thread();
|
||||
}
|
||||
|
||||
return &q->events[(q->read++) & QUEUE_LENGTH_MASK];
|
||||
}
|
||||
|
||||
void queue_post(struct event_queue *q, int id, void *data)
|
||||
{
|
||||
int wr = (q->write++) & QUEUE_LENGTH_MASK;
|
||||
|
||||
q->events[wr].id = id;
|
||||
q->events[wr].data = data;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue