template<unsigned NumSlots, unsigned SlotSize = 20>
class miosix::FixedEventQueue< NumSlots, SlotSize >
A fixed size event queue.
This guarantees it makes no use of the heap, therefore events can be posted also from within interrupt handlers. This simplifies the development of device drivers.
This class acts as a synchronization point, multiple threads (and IRQs) can post events, and multiple threads can call run() or runOne() (thread pooling).
Events are function that are posted by a thread through post() but executed in the context of the thread that calls run() or runOne()
- Parameters
-
NumSlots | maximum queue length |
SlotSize | size of the Callback objects. This limits the maximum number of parameters that can be bound to a function. If you get compile-time errors in callback.h, consider increasing this value. The default is 20 bytes, which is enough to bind a member function pointer, a "this" pointer and two byte or pointer sized parameters. |
template<unsigned NumSlots, unsigned SlotSize = 20>
Post an event in the queue, or return if the queue was full. Can be called only with interrupts disabled or within an interrupt handler, allowing device drivers to post an event to a thread.
- Parameters
-
event | function function to be called in the thread that calls run() or runOne(). Bind can be used to bind parameters to the function. Unlike with the EventQueue, the operator= of the bound parameters have the restriction that they need to be callable with interrupts disabled so they must not open files, print, ... |
If the call is made from within an InterruptDisableLock the copy constructors can allocate memory, while if the call is made from an interrupt handler or a FastInterruptFisableLock memory allocation is forbidden.
- Returns
- false if there was no space in the queue
template<unsigned NumSlots, unsigned SlotSize = 20>
Post an event in the queue, or return if the queue was full. Can be called only with interrupts disabled or within an interrupt handler, allowing device drivers to post an event to a thread.
- Parameters
-
event | function function to be called in the thread that calls run() or runOne(). Bind can be used to bind parameters to the function. Unlike with the EventQueue, the operator= of the bound parameters have the restriction that they need to be callable with interrupts disabled so they must not open files, print, ... |
If the call is made from within an InterruptDisableLock the copy constructors can allocate memory, while if the call is made from an interrupt handler or a FastInterruptFisableLock memory allocation is forbidden.
- Parameters
-
hppw | returns true if a higher priority thread was awakened as part of posting the event. Can be used inside an IRQ to call the scheduler. |
- Returns
- false if there was no space in the queue