RTOS Wrapper
API reference
Loading...
Searching...
No Matches
Classes | Namespaces
FlagsSaver.h File Reference

Atomic two-state flag bitset with optional event-flag waiter. More...

#include <atomic>
#include <climits>
#include <cstddef>
#include <cstdint>
#include "OsAbstraction.h"
#include "OsUtility.h"

Go to the source code of this file.

Classes

struct  hf::FlagsSnapshot< kWordCount >
 Snapshot of a FlagsSaver at a point in time. More...
 
class  hf::FlagsReader< FlagId, kCount >
 Read-side ABC for FlagsSaver. More...
 
class  hf::FlagsWriter< FlagId, kCount >
 Write-side ABC for FlagsSaver. More...
 
class  hf::FlagsSaver< FlagId, kCount >
 Concrete two-state flag bitset. More...
 

Namespaces

namespace  hf
 

Detailed Description

Atomic two-state flag bitset with optional event-flag waiter.

Three types in one header:

Pass an hf::FlagsReader* to consumers that may only inspect / wait, and an hf::FlagsWriter* to consumers that may only publish — keeps the apps↔middleware layering honest.

Storage
Each slot holds one bit (0 = Cleared, 1 = Set); slots are packed into std::atomic<uint64_t> words (64 slots per word). Lookups and writes are lock-free. A change to any slot bumps a 32-bit sequence counter and signals a single bit on a lazily-created OsEventFlags.
Thread-safety
  • Set / Clear / IsSet / Snapshot / Seq / LastChangeMs: lock-free; safe from any task context. Not ISR-safe (FreeRTOS event-group set is not ISR-safe via this path).
  • WaitForChange: backed by a FreeRTOS event group; do not call from ISR.
Allocation
No heap allocation. Storage is a fixed-size atomic word array sized at compile time. The event group is created on first use.