nanokernel: Add generic fifo routine
Adds the following generic fifo routine: nano_fifo_get_wait_timeout() That routine is a convenience wrapper for invoking the task or fiber specific implementation. Change-Id: I9bd709ea416db834e2a0c5de81257c363e7db066 Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
This commit is contained in:
parent
3d2afc63c0
commit
829967786c
@ -399,6 +399,24 @@ extern void *nano_fifo_get(struct nano_fifo *fifo);
|
||||
*/
|
||||
extern void *nano_fifo_get_wait(struct nano_fifo *fifo);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Get the head element of a fifo, poll/pend with timeout if empty
|
||||
*
|
||||
* This is a convenience wrapper for the execution context-specific APIs. This
|
||||
* is helpful whenever the exact execution context is not known, but should be
|
||||
* avoided when the context is known up-front (to avoid unnecessary overhead).
|
||||
*
|
||||
* @warning It's only valid to call this API from a fiber or a task.
|
||||
*
|
||||
* @param fifo FIFO on which to interact.
|
||||
* @param timeout Timeout measured in ticks
|
||||
*
|
||||
* @return Pointer to head element in the list
|
||||
*/
|
||||
extern void *nano_fifo_get_wait_timeout(struct nano_fifo *fifo,
|
||||
int32_t timeout);
|
||||
|
||||
/*
|
||||
* methods for ISRs
|
||||
*/
|
||||
|
||||
@ -150,8 +150,11 @@ void nano_task_fifo_put(struct nano_fifo *fifo, void *data)
|
||||
void nano_fifo_put(struct nano_fifo *fifo, void *data)
|
||||
{
|
||||
static void (*func[3])(struct nano_fifo *fifo, void *data) = {
|
||||
nano_isr_fifo_put, nano_fiber_fifo_put, nano_task_fifo_put
|
||||
nano_isr_fifo_put,
|
||||
nano_fiber_fifo_put,
|
||||
nano_task_fifo_put
|
||||
};
|
||||
|
||||
func[sys_execution_context_type_get()](fifo, data);
|
||||
}
|
||||
|
||||
@ -259,8 +262,11 @@ void *nano_task_fifo_get_wait(struct nano_fifo *fifo)
|
||||
void *nano_fifo_get_wait(struct nano_fifo *fifo)
|
||||
{
|
||||
static void *(*func[3])(struct nano_fifo *fifo) = {
|
||||
NULL, nano_fiber_fifo_get_wait, nano_task_fifo_get_wait
|
||||
NULL,
|
||||
nano_fiber_fifo_get_wait,
|
||||
nano_task_fifo_get_wait
|
||||
};
|
||||
|
||||
return func[sys_execution_context_type_get()](fifo);
|
||||
}
|
||||
|
||||
@ -340,4 +346,15 @@ void *nano_task_fifo_get_wait_timeout(struct nano_fifo *fifo,
|
||||
irq_unlock(key);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *nano_fifo_get_wait_timeout(struct nano_fifo *fifo, int32_t timeout)
|
||||
{
|
||||
static void *(*func[3])(struct nano_fifo *, int32_t) = {
|
||||
NULL,
|
||||
nano_fiber_fifo_get_wait_timeout,
|
||||
nano_task_fifo_get_wait_timeout
|
||||
};
|
||||
|
||||
return func[sys_execution_context_type_get()](fifo, timeout);
|
||||
}
|
||||
#endif /* CONFIG_NANO_TIMEOUTS */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user