61 if (membuf !=
nullptr)
132 if (membuf !=
nullptr)
144 mtx->~stk_fastmutex_t();
203 if (membuf !=
nullptr)
213 if (slock !=
nullptr)
215 slock->~stk_spinlock_t();
257 if (membuf !=
nullptr)
343 if (membuf !=
nullptr)
414 :
handle(initial_count, max_count)
429 if (membuf !=
nullptr)
518 if (membuf !=
nullptr)
566 return ef->
handle.
Wait(flags, options, timeout);
584 if (actual_flags !=
nullptr)
586 *actual_flags = actual;
607 if (membuf !=
nullptr)
619 ctx->~stk_ef_sync_ctx_t();
632 if (actual_flags !=
nullptr)
634 *actual_flags = actual;
654 stk_pipe_t(uint8_t *buf,
size_t capacity,
size_t element_size)
655 :
handle(buf, capacity, element_size)
669 STK_ASSERT(buf_size >= capacity * element_size);
672 if ((membuf !=
nullptr) && (buf_size >= (capacity * element_size)))
725 return ToCWaitResult(pipe->
handle.
ReadEx(data, timeout));
751 if (written !=
nullptr)
756 return ToCWaitResult(wr);
781 if (read_count !=
nullptr)
786 return ToCWaitResult(wr);
819 if (read_count !=
nullptr)
824 return ToCWaitResult(wr);
903 :
handle(buf, capacity, msg_size)
922 if ((membuf !=
nullptr) && (buf_size >= (capacity * msg_size)))
951 return ToCWaitResult(mq->
handle.
PutEx(msg, timeout));
999 return ToCWaitResult(mq->
handle.
GetEx(msg, timeout));
1141 if (membuf !=
nullptr)
1153 rw->~stk_rwmutex_t();
1252 if ((membuf !=
nullptr) && (count != 0U))
1262 if (barrier !=
nullptr)
1264 barrier->~stk_barrier_t();
Collection of memory-related primitives (stk::memory namespace).
Top-level STK include. Provides the Kernel class template and all built-in task-switching strategies.
#define STK_ASSERT(e)
Runtime assertion. Halts execution if the expression e evaluates to false.
Collection of synchronization primitives (stk::sync namespace).
C language binding/interface for SuperTinyKernel RTOS.
Barrier * stk_barrier_get_instance(stk_barrier_t *barrier)
Get the underlying C++ stk::sync::Barrier object wrapped by a stk_barrier_t handle.
stk_ef_val_t stk_ef_and(stk_ef_t *ef, stk_ef_val_t mask)
AND the flags word with a mask (equivalent of ThreadX tx_event_flags_set(TX_AND)).
FastMutex * stk_fastmutex_get_instance(stk_fastmutex_t *mtx)
Get the underlying C++ stk::sync::FastMutex object wrapped by a stk_fastmutex_t handle.
void stk_barrier_destroy(stk_barrier_t *barrier)
Destroy a Barrier.
void stk_sem_signal(stk_sem_t *sem)
Signal/Release a semaphore resource.
size_t stk_pipe_get_capacity(const stk_pipe_t *pipe)
Get the maximum number of elements the pipe can hold.
void stk_msgq_reset(stk_msgq_t *mq)
Discard all messages and reset the queue to the empty state.
bool stk_msgq_is_full(const stk_msgq_t *mq)
Check whether the queue is currently full.
stk_pipe_t * stk_pipe_create(stk_pipe_mem_t *const membuf, uint8_t *buf, uint32_t buf_size, size_t capacity, size_t element_size)
Create a Pipe (using provided memory).
bool stk_event_set(stk_event_t *ev)
Set the event to signaled state.
stk_wait_result_t stk_rwmutex_timed_lock_ex(stk_rwmutex_t *rw, stk_timeout_t timeout)
Try to acquire the write lock with a timeout, preserving the full outcome.
void stk_mutex_destroy(stk_mutex_t *mtx)
Destroy a Mutex.
size_t stk_pipe_get_count(const stk_pipe_t *pipe)
Get the current number of elements in the pipe.
bool stk_sem_trysignal(stk_sem_t *sem)
Try to signal/release a semaphore resource without exceeding max_count.
bool stk_pipe_write(stk_pipe_t *pipe, const void *data, stk_timeout_t timeout)
Write a single element to the pipe.
SemaphoreT< stk_sem_val_t > * stk_sem_get_instance(stk_sem_t *sem)
Get the underlying C++ stk::sync::SemaphoreT<stk_sem_val_t> object wrapped by a stk_sem_t handle.
size_t stk_pipe_read_bulk(stk_pipe_t *pipe, void *dst, size_t count, stk_timeout_t timeout)
Read multiple elements from the pipe.
size_t stk_pipe_trywrite_bulk(stk_pipe_t *pipe, const void *src, size_t count)
Attempt to write multiple elements to the pipe without blocking.
stk_wait_result_t stk_pipe_read_bulk_triggered_ex(stk_pipe_t *pipe, void *dst, size_t trigger, size_t max_count, size_t *read_count, stk_timeout_t timeout)
Read at least trigger elements, then drain up to max_count, preserving the full outcome.
bool stk_rwmutex_try_read_lock(stk_rwmutex_t *rw)
Try to acquire the read lock without blocking.
stk_ef_val_t stk_ef_trywait(stk_ef_t *ef, stk_ef_val_t flags, uint32_t options)
Non-blocking flag poll.
size_t stk_pipe_get_space(const stk_pipe_t *pipe)
Get the number of free slots currently available.
void stk_ef_destroy(stk_ef_t *ef)
Destroy an EventFlags object.
bool stk_event_wait(stk_event_t *ev, stk_timeout_t timeout)
Wait for the event to become signaled.
stk_wait_result_t stk_msgq_put_ex(stk_msgq_t *mq, const void *msg, stk_timeout_t timeout)
Put a message into the queue, preserving the full outcome.
stk_wait_result_t
Outcome of a cancellable, timed kernel wait (see stk_cv_wait_ex(), stk_mutex_timed_lock_ex(),...
stk_sem_val_t stk_sem_get_count(const stk_sem_t *sem)
Get the current counter value.
stk_ef_t * stk_ef_create(stk_ef_mem_t *const membuf, stk_ef_val_t initial_flags)
Create an EventFlags object (using provided memory).
bool stk_rwmutex_trylock(stk_rwmutex_t *rw)
Try to acquire the write lock without blocking.
bool stk_cv_wait(stk_cv_t *cv, stk_mutex_t *mtx, stk_timeout_t timeout)
Wait for a signal on the condition variable.
stk_wait_result_t stk_msgq_peekfront_ex(stk_msgq_t *mq, void *msg, stk_timeout_t timeout)
Peek at the front-inserted message without removing it, preserving the full outcome.
void stk_spinlock_destroy(stk_spinlock_t *slock)
Destroy the SpinLock.
void stk_fastmutex_destroy(stk_fastmutex_t *mtx)
Destroy a FastMutex.
void stk_cv_notify_one(stk_cv_t *cv)
Wake one task waiting on the condition variable.
bool stk_spinlock_trylock(stk_spinlock_t *slock)
Attempt to acquire the SpinLock immediately.
stk_spinlock_t * stk_spinlock_create(stk_spinlock_mem_t *const membuf)
Create a recursive SpinLock.
bool stk_msgq_tryget(stk_msgq_t *mq, void *msg)
Attempt to get a message from the queue without blocking.
bool stk_event_trywait(stk_event_t *ev)
Wait for the event to become signaled.
stk_wait_result_t stk_pipe_read_bulk_ex(stk_pipe_t *pipe, void *dst, size_t count, size_t *read_count, stk_timeout_t timeout)
Read multiple elements from the pipe, preserving the full outcome.
sync::SpinLock * stk_spinlock_get_instance(stk_spinlock_t *slock)
Get the underlying C++ stk::sync::SpinLock object wrapped by a stk_spinlock_t handle.
size_t stk_msgq_get_space(const stk_msgq_t *mq)
Get the number of free slots currently available.
stk_wait_result_t stk_cv_wait_ex(stk_cv_t *cv, stk_mutex_t *mtx, stk_timeout_t timeout)
Wait for a signal on the condition variable, preserving the full outcome.
void stk_event_destroy(stk_event_t *ev)
Destroy an Event.
stk_wait_result_t stk_pipe_read_ex(stk_pipe_t *pipe, void *data, stk_timeout_t timeout)
Read a single element from the pipe, preserving the full outcome.
bool stk_pipe_is_storage_valid(const stk_pipe_t *pipe)
Verify that the backing storage is valid and the pipe is ready for use.
bool stk_msgq_trypeekfront(stk_msgq_t *mq, void *msg)
Attempt to peek at the front message without blocking.
#define STK_NO_WAIT
No timeout constant.
bool stk_mutex_timed_lock(stk_mutex_t *mtx, stk_timeout_t timeout)
Try to lock the mutex with a timeout.
EventFlagsT< stk_ef_val_t > * stk_ef_get_instance(stk_ef_t *ef)
Get the underlying C++ stk::sync::EventFlagsT<stk_ef_val_t> object wrapped by a stk_ef_t handle.
bool stk_msgq_peekfront(stk_msgq_t *mq, void *msg, stk_timeout_t timeout)
Peek at the most recently front-inserted message without removing it.
void stk_ef_sync_ctx_destroy(stk_ef_sync_ctx_t *ctx)
Destroy a rendezvous context.
void stk_mutex_lock(stk_mutex_t *mtx)
Lock the mutex. Blocks until available.
Pipe * stk_pipe_get_instance(stk_pipe_t *pipe)
Get the underlying C++ stk::sync::Pipe object wrapped by a stk_pipe_t handle.
size_t stk_pipe_write_bulk(stk_pipe_t *pipe, const void *src, size_t count, stk_timeout_t timeout)
Write multiple elements to the pipe.
void stk_rwmutex_lock(stk_rwmutex_t *rw)
Acquire the lock for exclusive writing. Blocks until available.
stk_mutex_t * stk_mutex_create(stk_mutex_mem_t *const membuf)
Create a Mutex (using provided memory).
stk_wait_result_t stk_ef_sync(stk_ef_t *ef, stk_ef_sync_ctx_t *ctx, stk_ef_val_t set_flags, stk_ef_val_t wait_flags, stk_timeout_t timeout, stk_ef_val_t *actual_flags)
Atomically set flags and wait for a group of flags: a multi-task rendezvous (equivalent of FreeRTOS x...
stk_ef_val_t stk_ef_clear(stk_ef_t *ef, stk_ef_val_t flags)
Clear one or more flags.
void stk_cv_destroy(stk_cv_t *cv)
Destroy a Condition Variable.
stk_wait_result_t stk_ef_trywait_ex(stk_ef_t *ef, stk_ef_val_t flags, uint32_t options, stk_ef_val_t *actual_flags)
Non-blocking flag poll with stk_wait_result_t and full flags snapshot.
stk_barrier_result_t
Outcome of a stk_barrier_wait_ex() call.
bool stk_msgq_is_empty(const stk_msgq_t *mq)
Check whether the queue is currently empty.
uint32_t stk_barrier_get_threshold(const stk_barrier_t *barrier)
Get the number of tasks required to trip the barrier.
bool stk_mutex_trylock(stk_mutex_t *mtx)
Try locking the mutex. Does not block if already locked.
void stk_rwmutex_read_lock(stk_rwmutex_t *rw)
Acquire the lock for shared reading. Blocks until available.
bool stk_sem_trysignal_ceiling(stk_sem_t *sem, stk_sem_val_t ceiling)
Try to signal/release a semaphore resource without exceeding a caller-supplied ceiling.
size_t stk_msgq_get_capacity(const stk_msgq_t *mq)
Get the maximum number of messages the queue can hold.
stk_msgq_t * stk_msgq_create(stk_msgq_mem_t *const membuf, uint8_t *buf, uint32_t buf_size, size_t capacity, size_t msg_size)
Create a MessageQueue (using provided memory).
void stk_mutex_unlock(stk_mutex_t *mtx)
Unlock the mutex.
stk_sem_t * stk_sem_create(stk_sem_mem_t *const membuf, stk_sem_val_t initial_count, stk_sem_val_t max_count)
Create a Semaphore (using provided memory).
void stk_pipe_destroy(stk_pipe_t *pipe)
Destroy a Pipe.
stk_wait_result_t stk_fastmutex_timed_lock_ex(stk_fastmutex_t *mtx, stk_timeout_t timeout)
Try to lock the FastMutex with a timeout, preserving the full outcome.
size_t stk_pipe_get_element_size(const stk_pipe_t *pipe)
Get the size of each element in bytes.
stk_wait_result_t stk_sem_wait_ex(stk_sem_t *sem, stk_timeout_t timeout)
Wait for a semaphore resource, preserving the full outcome.
stk_event_t * stk_event_create(stk_event_mem_t *const membuf, bool manual_reset)
Create an Event (using provided memory).
bool stk_sem_wait(stk_sem_t *sem, stk_timeout_t timeout)
Wait for a semaphore resource.
bool stk_msgq_putfront(stk_msgq_t *mq, const void *msg, stk_timeout_t timeout)
Put a message into the front of the queue (priority insert).
size_t stk_msgq_get_count(const stk_msgq_t *mq)
Get the current number of messages waiting in the queue.
bool stk_fastmutex_timed_lock(stk_fastmutex_t *mtx, stk_timeout_t timeout)
Try to lock the mutex with a timeout.
uint8_t * stk_msgq_get_buffer(stk_msgq_t *mq)
Get a pointer to the raw message data buffer.
stk_wait_result_t stk_msgq_putfront_ex(stk_msgq_t *mq, const void *msg, stk_timeout_t timeout)
Put a message into the front of the queue, preserving the full outcome.
void stk_spinlock_lock(stk_spinlock_t *slock)
Acquire the SpinLock (recursive).
bool stk_msgq_put(stk_msgq_t *mq, const void *msg, stk_timeout_t timeout)
Put a message into the queue.
bool stk_msgq_tryput(stk_msgq_t *mq, const void *msg)
Attempt to put a message into the queue without blocking.
stk_ef_val_t stk_ef_get(stk_ef_t *ef)
Read the current flags word without modifying it.
Event * stk_event_get_instance(stk_event_t *ev)
Get the underlying C++ stk::sync::Event object wrapped by a stk_event_t handle.
bool stk_cv_wait_fastmutex(stk_cv_t *cv, stk_fastmutex_t *mtx, stk_timeout_t timeout)
Wait for a signal on the condition variable, protected by a FastMutex.
stk_wait_result_t stk_ef_wait_ex(stk_ef_t *ef, stk_ef_val_t flags, uint32_t options, stk_timeout_t timeout, stk_ef_val_t *actual_flags)
Wait for one or more flags to be set, reporting the outcome as stk_wait_result_t.
void stk_pipe_reset(stk_pipe_t *pipe)
Discard all elements and reset the pipe to the empty state.
stk_barrier_result_t stk_barrier_wait_ex(stk_barrier_t *barrier)
Block the calling task until count tasks have arrived, preserving the full outcome.
stk_wait_result_t stk_rwmutex_timed_read_lock_ex(stk_rwmutex_t *rw, stk_timeout_t timeout)
Try to acquire the read lock with a timeout, preserving the full outcome.
void stk_sem_destroy(stk_sem_t *sem)
Destroy a Semaphore.
void stk_spinlock_unlock(stk_spinlock_t *slock)
Release the SpinLock.
size_t stk_pipe_tryread_bulk_triggered(stk_pipe_t *pipe, void *dst, size_t max_count)
Non-blocking variant of stk_pipe_read_bulk_triggered.
stk_cv_t * stk_cv_create(stk_cv_mem_t *const membuf)
Create a Condition Variable (using provided memory).
bool stk_sem_trywait(stk_sem_t *sem)
Poll the semaphore without blocking.
sync::RWMutex * stk_rwmutex_get_instance(stk_rwmutex_t *rw)
Get the underlying C++ stk::sync::RWMutex object wrapped by a stk_rwmutex_t handle.
void stk_rwmutex_read_unlock(stk_rwmutex_t *rw)
Release the shared reader lock.
size_t stk_msgq_get_msg_size(const stk_msgq_t *mq)
Get the size of each message in bytes.
bool stk_pipe_tryread(stk_pipe_t *pipe, void *data)
Attempt to read a single element from the pipe without blocking.
ConditionVariable * stk_cv_get_instance(stk_cv_t *cv)
Get the underlying C++ stk::sync::ConditionVariable object wrapped by a stk_cv_t handle.
stk_wait_result_t stk_msgq_peek_ex(stk_msgq_t *mq, void *msg, stk_timeout_t timeout)
Peek at the next message without removing it, preserving the full outcome.
bool stk_fastmutex_trylock(stk_fastmutex_t *mtx)
Try locking the mutex. Does not block if already locked.
size_t stk_pipe_read_bulk_triggered(stk_pipe_t *pipe, void *dst, size_t trigger, size_t max_count, stk_timeout_t timeout)
Read at least trigger elements, then drain up to max_count without blocking.
bool stk_msgq_get(stk_msgq_t *mq, void *msg, stk_timeout_t timeout)
Get a message from the queue.
void stk_event_pulse(stk_event_t *ev)
Pulse the event (signal then immediately reset).
bool stk_msgq_tryputfront(stk_msgq_t *mq, const void *msg)
Attempt to put a message into the front of the queue without blocking.
bool stk_pipe_is_full(const stk_pipe_t *pipe)
Check whether the pipe is currently full.
bool stk_pipe_is_empty(const stk_pipe_t *pipe)
Check whether the pipe is currently empty.
stk_ef_sync_ctx_t * stk_ef_sync_ctx_create(stk_ef_sync_ctx_mem_t *const membuf)
Create a rendezvous context (using provided memory).
bool stk_pipe_read(stk_pipe_t *pipe, void *data, stk_timeout_t timeout)
Read a single element from the pipe.
void stk_fastmutex_lock(stk_fastmutex_t *mtx)
Lock the mutex. Blocks until available.
stk_wait_result_t stk_pipe_write_ex(stk_pipe_t *pipe, const void *data, stk_timeout_t timeout)
Write a single element to the pipe, preserving the full outcome.
bool stk_event_reset(stk_event_t *ev)
Reset the event to non-signaled state.
void stk_fastmutex_unlock(stk_fastmutex_t *mtx)
Unlock the mutex.
stk_wait_result_t stk_msgq_get_ex(stk_msgq_t *mq, void *msg, stk_timeout_t timeout)
Get a message from the queue, preserving the full outcome.
bool stk_msgq_is_storage_valid(const stk_msgq_t *mq)
Verify that the backing storage is valid and the queue is ready for use.
stk_fastmutex_t * stk_fastmutex_create(stk_fastmutex_mem_t *const membuf)
Create a FastMutex (using provided memory).
bool stk_rwmutex_timed_lock(stk_rwmutex_t *rw, stk_timeout_t timeout)
Try to acquire the write lock with a timeout.
void stk_rwmutex_destroy(stk_rwmutex_t *rw)
Destroy an RWMutex.
void stk_msgq_destroy(stk_msgq_t *mq)
Destroy a MessageQueue.
stk_wait_result_t stk_event_wait_ex(stk_event_t *ev, stk_timeout_t timeout)
Wait for the event to become signaled, preserving the full outcome.
stk_ef_val_t stk_ef_set(stk_ef_t *ef, stk_ef_val_t flags)
Set one or more flags.
stk_barrier_t * stk_barrier_create(stk_barrier_mem_t *const membuf, uint32_t count)
Create a Barrier (using provided memory).
bool stk_rwmutex_timed_read_lock(stk_rwmutex_t *rw, stk_timeout_t timeout)
Try to acquire the read lock with a timeout.
int32_t stk_timeout_t
Timeout value.
Mutex * stk_mutex_get_instance(stk_mutex_t *mtx)
Get the underlying C++ stk::sync::Mutex object wrapped by a stk_mutex_t handle.
bool stk_msgq_peek(stk_msgq_t *mq, void *msg, stk_timeout_t timeout)
Peek at the next message to be delivered without removing it.
stk_ef_val_t stk_ef_wait(stk_ef_t *ef, stk_ef_val_t flags, uint32_t options, stk_timeout_t timeout)
Wait for one or more flags to be set.
stk_wait_result_t stk_mutex_timed_lock_ex(stk_mutex_t *mtx, stk_timeout_t timeout)
Try to lock the mutex with a timeout, preserving the full outcome.
bool stk_msgq_trypeek(stk_msgq_t *mq, void *msg)
Attempt to peek at the next message without blocking.
void stk_cv_notify_all(stk_cv_t *cv)
Wake all tasks waiting on the condition variable.
stk_wait_result_t stk_pipe_write_bulk_ex(stk_pipe_t *pipe, const void *src, size_t count, size_t *written, stk_timeout_t timeout)
Write multiple elements to the pipe, preserving the full outcome.
stk_rwmutex_t * stk_rwmutex_create(stk_rwmutex_mem_t *const membuf)
Create an RWMutex (using provided memory).
stk_wait_result_t stk_cv_wait_ex_fastmutex(stk_cv_t *cv, stk_fastmutex_t *mtx, stk_timeout_t timeout)
Wait for a signal on the condition variable protected by a FastMutex, preserving the full outcome.
bool stk_pipe_trywrite(stk_pipe_t *pipe, const void *data)
Attempt to write a single element to the pipe without blocking.
void stk_rwmutex_unlock(stk_rwmutex_t *rw)
Release the exclusive writer lock.
MessageQueue * stk_msgq_get_instance(stk_msgq_t *mq)
Get the underlying C++ stk::sync::MessageQueue object wrapped by a stk_msgq_t handle.
bool stk_barrier_wait(stk_barrier_t *barrier)
Block the calling task until count tasks have called stk_barrier_wait().
size_t stk_pipe_tryread_bulk(stk_pipe_t *pipe, void *dst, size_t count)
Attempt to read multiple elements from the pipe without blocking.
@ STK_WAIT_RESULT_TIMEOUT
The wake was caused by a timeout expiry.
@ STK_WAIT_RESULT_SIGNAL
The wake was caused by a signal.
@ STK_WAIT_RESULT_CANCELED
The wait was cancelled by another task, independent of signal/timeout.
@ STK_WAIT_RESULT_FAIL
The kernel returned an error without actually waiting.
@ STK_BARRIER_RELEASED
Released because the barrier tripped; this task was not the last arrival.
@ STK_BARRIER_LAST_ARRIVAL
This task was the last arrival and tripped the barrier.
Namespace of STK package.
static T * ConstructIn(Mem &mem, Args &&... args)
Construct object T in-place inside a C memory container.
EWaitResult
Wait result (see IKernelService::Wait).
@ WAIT_RESULT_CANCELED
The wait was cancelled by another task via IKernel::CancelTaskWait(), independent of signal/timeout.
@ WAIT_RESULT_TIMEOUT
The wake was caused by a timeout expiry.
@ WAIT_RESULT_SIGNAL
The wake was caused by a signal.
Synchronization primitives for task coordination and resource protection.
Cyclic barrier that blocks a fixed-size group of tasks until all of them have arrived.
uint32_t GetThreshold() const
Get the number of tasks required to trip the barrier.
bool Wait()
Block the calling task until count tasks have called Wait().
@ BARRIER_LAST_ARRIVAL
This task was the last arrival and tripped the barrier.
EResult WaitEx()
Block the calling task until count tasks have called Wait(), preserving the full outcome.
Condition Variable primitive for signaling between tasks based on specific predicates.
EWaitResult WaitEx(IMutex &mutex, Timeout timeout_ticks=WAIT_INFINITE)
Wait for a signal, preserving the full wait outcome.
void NotifyOne()
Wake one waiting task.
bool Wait(IMutex &mutex, Timeout timeout_ticks=WAIT_INFINITE)
Wait for a signal.
void NotifyAll()
Wake all waiting tasks.
Binary synchronization event (signaled / non-signaled) primitive.
bool Set()
Set event to signaled state.
void Pulse()
Pulse event: attempt to release waiters and then reset (Win32 PulseEvent() semantics).
bool TryWait()
Poll event state without blocking.
EWaitResult WaitEx(Timeout timeout_ticks=WAIT_INFINITE)
Wait until event becomes signaled or the timeout expires, preserving the full wait outcome.
bool Reset()
Reset event to non-signaled state.
bool Wait(Timeout timeout_ticks=WAIT_INFINITE)
Wait until event becomes signaled or the timeout expires.
Event flags group for multi-flag synchronization between tasks, with a selectable flags word type.
T And(T mask)
AND the flags word with a mask (equivalent of ThreadX tx_event_flags_set(TX_AND)).
T Set(T flags)
Set one or more flags.
EWaitResult WaitEx(T flags, uint32_t options, Timeout timeout_ticks, T &actual_flags)
Wait for one or more flags to be set, reporting the outcome via EWaitResult.
T Clear(T flags)
Clear one or more flags.
T Wait(T flags, uint32_t options=OPT_WAIT_ANY, Timeout timeout_ticks=WAIT_INFINITE)
Wait for one or more flags to be set.
T Get() const
Read the current flags word without modifying it.
T TryWait(T flags, uint32_t options=OPT_WAIT_ANY)
Non-blocking flag poll.
EWaitResult Sync(SyncContext &ctx, T set_flags, T wait_flags, Timeout timeout_ticks, T &actual_flags)
Atomically set flags and wait for a group of flags: a multi-task rendezvous (equivalent of FreeRTOS x...
State of one Sync() rendezvous group, supplied by the caller.
Non-recursive (binary) mutex primitive with ownership tracking.
bool TryLock()
Try to acquire the lock without blocking.
void Lock() override
Acquire lock.
bool TimedLock(Timeout timeout_ticks)
Acquire lock.
void Unlock() override
Release lock.
EWaitResult TimedLockEx(Timeout timeout_ticks)
Acquire lock, preserving the full wait outcome.
Fixed-capacity, fixed-message-size FIFO queue for inter-task communication.
bool TryPeek(void *msg_ptr)
Attempt to peek at the next message without blocking.
bool TryPeekFront(void *msg_ptr)
Attempt to peek at the front message without blocking.
bool IsEmpty() const
Check whether the queue is currently empty.
bool PeekFront(void *msg_ptr, Timeout timeout_ticks=WAIT_INFINITE)
Peek at the front of the queue (the message Get() returns next) without removing it.
size_t GetCapacity() const
Get the maximum number of messages the queue can hold.
EWaitResult PutEx(const void *msg_ptr, Timeout timeout_ticks=WAIT_INFINITE)
Put a message into the back of the queue (FIFO order), preserving the full wait outcome.
bool TryPutFront(const void *msg_ptr)
Attempt to put a message into the front of the queue without blocking.
size_t GetMsgSize() const
Get the size of each message in bytes.
bool TryPut(const void *msg_ptr)
Attempt to put a message into the back of the queue without blocking.
EWaitResult PeekFrontEx(void *msg_ptr, Timeout timeout_ticks=WAIT_INFINITE)
Peek at the front of the queue without removing it, preserving the full wait outcome.
size_t GetSpace() const
Get the number of free slots currently available.
EWaitResult PutFrontEx(const void *msg_ptr, Timeout timeout_ticks=WAIT_INFINITE)
Put a message into the front of the queue (LIFO / priority-insert order), preserving the full wait ou...
size_t GetCount() const
Get the current number of messages in the queue.
bool TryGet(void *msg_ptr)
Attempt to get a message from the queue without blocking.
uint8_t * GetBuffer()
Get pointer to the message buffer.
bool Peek(void *msg_ptr, Timeout timeout_ticks=WAIT_INFINITE)
Peek at the next message to be delivered (the one Get() returns next) without removing it.
EWaitResult PeekEx(void *msg_ptr, Timeout timeout_ticks=WAIT_INFINITE)
Peek at the next message to be delivered without removing it, preserving the full wait outcome.
EWaitResult GetEx(void *msg_ptr, Timeout timeout_ticks=WAIT_INFINITE)
Get a message from the queue, preserving the full wait outcome.
bool PutFront(const void *msg_ptr, Timeout timeout_ticks=WAIT_INFINITE)
Put a message into the front of the queue (LIFO / priority-insert order).
bool IsStorageValid() const
Verify that the backing storage is valid and the pool is ready for use.
bool Put(const void *msg_ptr, Timeout timeout_ticks=WAIT_INFINITE)
Put a message into the back of the queue (FIFO order).
bool Get(void *msg_ptr, Timeout timeout_ticks=WAIT_INFINITE)
Get a message from the queue.
bool IsFull() const
Check whether the queue is currently full.
void Reset()
Discard all messages and reset the queue to the empty state.
Recursive mutex primitive that allows the same thread to acquire the lock multiple times.
EWaitResult TimedLockEx(Timeout timeout_ticks)
Acquire lock, preserving the full wait outcome.
bool TimedLock(Timeout timeout_ticks)
Acquire lock.
bool TryLock()
Try to acquire the lock without blocking.
void Unlock() override
Release lock.
void Lock() override
Acquire lock.
Thread-safe FIFO communication pipe for inter-task data passing.
size_t WriteBulk(const void *src, size_t count, Timeout timeout_ticks=WAIT_INFINITE)
Write multiple elements to the pipe.
bool TryRead(void *data)
Attempt to read a single element from the pipe without blocking.
size_t TryReadBulkTriggered(void *dst, size_t max_count)
Non-blocking variant of ReadBulkTriggered.
void Reset()
Discard all elements and reset the pipe to the empty state.
EWaitResult WriteBulkEx(const void *src, size_t count, size_t &written, Timeout timeout_ticks=WAIT_INFINITE)
Write multiple elements to the pipe, preserving the full wait outcome.
bool Read(void *data, Timeout timeout_ticks=WAIT_INFINITE)
Read a single element from the pipe.
EWaitResult ReadBulkTriggeredEx(void *dst, size_t trigger, size_t max_count, size_t &read_count, Timeout timeout_ticks=WAIT_INFINITE)
Read at least trigger elements, then drain up to max_count without blocking, preserving the full wait...
EWaitResult ReadBulkEx(void *dst, size_t count, size_t &read_count, Timeout timeout_ticks=WAIT_INFINITE)
Read multiple elements from the pipe, preserving the full wait outcome.
EWaitResult ReadEx(void *data, Timeout timeout_ticks=WAIT_INFINITE)
Read a single element from the pipe, preserving the full wait outcome.
size_t ReadBulk(void *dst, size_t count, Timeout timeout_ticks=WAIT_INFINITE)
Read multiple elements from the pipe.
bool Write(const void *data, Timeout timeout_ticks=WAIT_INFINITE)
Write a single element to the pipe.
size_t GetElementSize() const
Get the size of each element in bytes.
size_t TryWriteBulk(const void *src, size_t count)
Attempt to write multiple elements to the pipe without blocking.
bool IsEmpty() const
Check if the pipe is currently empty.
EWaitResult WriteEx(const void *data, Timeout timeout_ticks=WAIT_INFINITE)
Write a single element to the pipe, preserving the full wait outcome.
size_t GetCapacity() const
Get the maximum number of elements the pipe can hold.
bool TryWrite(const void *data)
Attempt to write a single element to the pipe without blocking.
size_t GetCount() const
Get the current number of elements in the pipe.
bool IsFull() const
Check if the pipe is currently full.
size_t TryReadBulk(void *dst, size_t count)
Attempt to read multiple elements from the pipe without blocking.
size_t GetSpace() const
Get the number of free slots currently available.
size_t ReadBulkTriggered(void *dst, size_t trigger, size_t max_count, Timeout timeout_ticks=WAIT_INFINITE)
Read at least trigger elements, then drain up to max_count without blocking.
bool IsStorageValid() const
Verify that the backing storage is valid and the pipe is ready for use.
Reader-Writer Lock synchronization primitive for non-recursive shared and exclusive access.
bool TryLock()
Attempt to acquire the lock for exclusive writing without blocking.
bool TimedLock(Timeout timeout_ticks)
Acquire the lock for exclusive writing with a timeout.
void Unlock() override
Release the exclusive writer lock (IMutex interface).
void Lock() override
Acquire the lock for exclusive writing (IMutex interface).
EWaitResult TimedReadLockEx(Timeout timeout_ticks)
Acquire the lock for shared reading with a timeout, preserving the full wait outcome.
EWaitResult TimedLockEx(Timeout timeout_ticks)
Acquire the lock for exclusive writing with a timeout, preserving the full wait outcome.
bool TimedReadLock(Timeout timeout_ticks)
Acquire the lock for shared reading with a timeout.
void ReadUnlock()
Release the shared reader lock.
void ReadLock()
Acquire the lock for shared reading.
bool TryReadLock()
Attempt to acquire the lock for shared reading without blocking.
Counting semaphore primitive for resource management and signaling, with a selectable counter type.
static constexpr T COUNT_MAX
Max count value supported (maximum value of T).
T GetCount() const
Get current counter value.
bool Wait(Timeout timeout_ticks=WAIT_INFINITE)
Wait for a signal (decrement counter).
bool TrySignal()
Try to post a signal without exceeding max_count.
void Signal()
Post a signal (increment counter).
bool TryWait()
Poll the semaphore without blocking (decrement counter if available).
EWaitResult WaitEx(Timeout timeout_ticks=WAIT_INFINITE)
Wait for a signal (decrement counter), preserving the full wait outcome.
void Unlock()
Release the lock or decrement the recursion counter.
bool TryLock()
Attempt to acquire the lock without blocking.
void Lock()
Acquire the lock.
Opaque memory container for a Mutex instance.
Opaque memory container for a FastMutex instance.
Opaque memory container for SpinLock object.
Opaque memory container for a ConditionVariable instance.
Opaque memory container for an Event instance.
Opaque memory container for a Semaphore instance.
Opaque memory container for an EventFlags instance.
Opaque memory container for a rendezvous context.
Opaque memory container for a Pipe control-block.
Opaque memory container for a MessageQueue instance.
Opaque memory container for an RWMutex instance.
Opaque memory container for a Barrier instance.
stk_event_t(bool manual_reset)
stk_sem_t(stk_sem_val_t initial_count, stk_sem_val_t max_count)
SemaphoreT< stk_sem_val_t > handle
EventFlagsT< stk_ef_val_t > handle
stk_ef_t(stk_ef_val_t initial_flags)
EventFlagsT< stk_ef_val_t >::SyncContext handle
stk_pipe_t(uint8_t *buf, size_t capacity, size_t element_size)
stk_msgq_t(uint8_t *buf, size_t capacity, size_t msg_size)
stk_barrier_t(uint32_t count)