|
|
Ring buffer for events. More...
Data Structures | |
struct | os_ring_buffer_ev_s |
Events ring buffer structure. More... | |
Typedefs | |
typedef struct os_ring_buffer_ev_s | os_ring_buffer_ev_t |
Data type for event ring buffer. | |
Functions | |
os_result_t | os_ringbuf_create_ev (os_ring_buffer_ev_t *rb, unsigned char size) |
Creation of the ring buffer for events. | |
os_result_t | os_ringbuf_add_ev (os_ring_buffer_ev_t *rb, os_event_t event) |
Adds one event to the ring buffer. | |
os_result_t | os_ringbuf_get_ev (os_ring_buffer_ev_t *rb, os_event_t *event) |
Gets one event from the buffer. | |
unsigned char | os_ringbuf_items_ev (os_ring_buffer_ev_t *rb) |
Reads number of events in the ring buffer. | |
os_result_t | os_ringbuf_clear_ev (os_ring_buffer_ev_t *rb) |
Clears buffer. |
Ring buffer for events.
This type of ring buffer is a variant of ring buffer (ring_buffer.h). The main difference is that this ring buffer is intentended for events (events.h) storage. Due to small and compact form of the events they are stored inside the buffer. This does not add a lot of operations but simplifies event management. The event is copied to buffer when is added and also when is removed. This introduce a separation in management of lifetime event. Here the event can be created and destroyed in the same part, while general ring buffer requires creation at one size (when is added) and freeing at the other one (when is removed from ring buffer).
Other properties are inherited from ring_buffer (ring_buffer.h), refer there for more information.
os_result_t os_ringbuf_add_ev | ( | os_ring_buffer_ev_t * | rb, |
os_event_t | event | ||
) |
Adds one event to the ring buffer.
Event is copied to ring buffer, so event instance that is an input may be deleted. The function uses critical section, so is thread safe and can be called from ISR.
[in] | rb | pointer to ring buffer structure |
[in] | event | event to be added |
os_result_t os_ringbuf_clear_ev | ( | os_ring_buffer_ev_t * | rb | ) |
Clears buffer.
[in] | rb | pointer to ring buffer structure |
os_result_t os_ringbuf_create_ev | ( | os_ring_buffer_ev_t * | rb, |
unsigned char | size | ||
) |
Creation of the ring buffer for events.
Ring buffer must be created before it is used.
[in] | rb | pointer to the ring buffer structure |
[in] | size | number of items in ring buffer (capacity is size-1) |
os_result_t os_ringbuf_get_ev | ( | os_ring_buffer_ev_t * | rb, |
os_event_t * | event | ||
) |
Gets one event from the buffer.
Event is copied to provided location (event argument). The function uses critical section, so is thread safe and can be called from ISR.
[in] | rb | pointer to ring buffer structure |
[out] | event | is copied to the event (if rb has been read) |
unsigned char os_ringbuf_items_ev | ( | os_ring_buffer_ev_t * | rb | ) |
Reads number of events in the ring buffer.
The function uses critical section, so is thread safe and can be called from ISR.
[in] | rb | pointer to ring buffer structure |