oveRTOS C++ API
C++20 RAII wrappers for the oveRTOS C API
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ove::EventGroup Class Reference

RAII wrapper around an oveRTOS event-group (bit-field synchronisation object). More...

#include <eventgroup.hpp>

Public Member Functions

 EventGroup ()
 Constructs and initialises the event group with all bits cleared.
 
 ~EventGroup () noexcept
 Destroys the event group, releasing the underlying kernel resource.
 
 EventGroup (const EventGroup &)=delete
 
EventGroupoperator= (const EventGroup &)=delete
 
 EventGroup (EventGroup &&other) noexcept
 Move constructor — transfers ownership of the kernel handle.
 
EventGroupoperator= (EventGroup &&other) noexcept
 Move-assignment operator — transfers ownership of the kernel handle.
 
ove_eventbits_t set_bits (ove_eventbits_t bits)
 Sets one or more event bits atomically.
 
ove_eventbits_t clear_bits (ove_eventbits_t bits)
 Clears one or more event bits atomically.
 
Result< ove_eventbits_t > wait_bits (ove_eventbits_t bits, uint32_t flags, std::chrono::nanoseconds timeout) noexcept
 Waits until the specified event bits are set, or until the timeout expires.
 
Result< ove_eventbits_t > wait_bits_until (ove_eventbits_t bits, uint32_t flags, steady_clock::time_point deadline) noexcept
 Deadline-based variant of wait_bits.
 
ove_eventbits_t set_bits_from_isr (ove_eventbits_t bits)
 Sets one or more event bits from an ISR context.
 
ove_eventbits_t get_bits () const
 Returns the current value of all event bits without blocking.
 
bool valid () const
 Returns true if the underlying kernel handle is non-null.
 
ove_eventgroup_t handle () const
 Returns the raw oveRTOS event-group handle.
 

Detailed Description

RAII wrapper around an oveRTOS event-group (bit-field synchronisation object).

An event group holds a set of event bits that tasks and ISRs can set, clear, and wait on. Multiple bits can be waited on simultaneously with optional all-bits-set or any-bit-set semantics, controlled by the flags parameter of wait_bits().

Note
Not copyable. Move-only when heap allocation is enabled.
set_bits_from_isr() is safe to call from interrupt context.

Constructor & Destructor Documentation

◆ EventGroup() [1/2]

ove::EventGroup::EventGroup ( )
inline

Constructs and initialises the event group with all bits cleared.

Asserts at startup if initialisation fails.

◆ EventGroup() [2/2]

ove::EventGroup::EventGroup ( EventGroup &&  other)
inlinenoexcept

Move constructor — transfers ownership of the kernel handle.

Parameters
otherThe source; its handle is set to null after the move.

Member Function Documentation

◆ operator=()

EventGroup & ove::EventGroup::operator= ( EventGroup &&  other)
inlinenoexcept

Move-assignment operator — transfers ownership of the kernel handle.

Parameters
otherThe source; its handle is set to null after the move.
Returns
Reference to this object.

◆ set_bits()

ove_eventbits_t ove::EventGroup::set_bits ( ove_eventbits_t  bits)
inline

Sets one or more event bits atomically.

Parameters
[in]bitsBitmask of bits to set.
Returns
The value of the event group after the bits were set.

[[nodiscard]] because the post-set bit state is the only way to observe whether your bits actually went on (vs. were cleared by a concurrent wait_bits with clear_on_exit). Cast to (void) if you genuinely don't care.

◆ clear_bits()

ove_eventbits_t ove::EventGroup::clear_bits ( ove_eventbits_t  bits)
inline

Clears one or more event bits atomically.

Parameters
[in]bitsBitmask of bits to clear.
Returns
The value of the event group before the bits were cleared.

[[nodiscard]] because the pre-clear state lets callers detect which bits were actually set at the moment of clearing — useful for race-free "consume" patterns.

◆ wait_bits()

Result< ove_eventbits_t > ove::EventGroup::wait_bits ( ove_eventbits_t  bits,
uint32_t  flags,
std::chrono::nanoseconds  timeout 
)
inlinenoexcept

Waits until the specified event bits are set, or until the timeout expires.

Parameters
[in]bitsBitmask of bits to wait for.
[in]flagsWait flags (e.g., wait-for-all vs. wait-for-any).
[in]timeoutMaximum time to wait.
Returns
On success, the event-group value at the moment the wait condition was satisfied. On failure, an unexpected Error (Error::Timeout on deadline).

◆ wait_bits_until()

Result< ove_eventbits_t > ove::EventGroup::wait_bits_until ( ove_eventbits_t  bits,
uint32_t  flags,
steady_clock::time_point  deadline 
)
inlinenoexcept

Deadline-based variant of wait_bits.

Parameters
[in]bitsBitmask to wait on.
[in]flagsWait flags (e.g., OVE_EVENT_WAIT_ALL).
[in]deadlineove::steady_clock::time_point at which the wait must complete.
Returns
As wait_bitsResult<ove_eventbits_t>.

◆ set_bits_from_isr()

ove_eventbits_t ove::EventGroup::set_bits_from_isr ( ove_eventbits_t  bits)
inline

Sets one or more event bits from an ISR context.

Parameters
[in]bitsBitmask of bits to set.
Returns
The value of the event group after the bits were set.

[[nodiscard]] for the same reason as set_bits — the post-set state is the observable result.

◆ get_bits()

ove_eventbits_t ove::EventGroup::get_bits ( ) const
inline

Returns the current value of all event bits without blocking.

Returns
The current event-group bitmask.

◆ valid()

bool ove::EventGroup::valid ( ) const
inline

Returns true if the underlying kernel handle is non-null.

Returns
true when the event group was successfully initialised.

◆ handle()

ove_eventgroup_t ove::EventGroup::handle ( ) const
inline

Returns the raw oveRTOS event-group handle.

Returns
The opaque ove_eventgroup_t handle.

The documentation for this class was generated from the following file: