LibJuno 1.0.4
LibJuno is a lightweight C11 library designed specifically for embedded systems.
Loading...
Searching...
No Matches
JUNO_THREAD_API_TAG Struct Reference

Thread module vtable (API struct). More...

#include <thread_api.h>

Data Fields

JUNO_STATUS_T(* Stop )(JUNO_THREAD_ROOT_T *ptRoot)
 Signal the managed thread to exit cooperatively.
 
JUNO_STATUS_T(* Join )(JUNO_THREAD_ROOT_T *ptRoot)
 Block until the managed thread exits.
 
JUNO_STATUS_T(* Free )(JUNO_THREAD_ROOT_T *ptRoot)
 Release platform resources held by the Thread module instance.
 

Detailed Description

Thread module vtable (API struct).

Each function pointer receives the module root as its first argument, following the LibJuno vtable dispatch convention. Concrete platform implementations populate this struct and expose it as a const global (e.g., g_junoThreadLinuxApi).

Thread creation is intentionally absent from this vtable. The platform init function (JunoThread_LinuxInit) is responsible for spawning the OS thread as part of RAII initialisation; no separate Create step is needed at the generic interface level.

Field Documentation

◆ Free

JUNO_STATUS_T(* JUNO_THREAD_API_TAG::Free) (JUNO_THREAD_ROOT_T *ptRoot)

Release platform resources held by the Thread module instance.

Resets the OS handle and any platform-specific state so the instance may be reinitialised. Must be called only after Join has returned.

Parameters
ptRootThread module root instance (caller-owned). Must not be NULL.
Returns
JUNO_STATUS_SUCCESS on success; non-zero on failure.

◆ Join

JUNO_STATUS_T(* JUNO_THREAD_API_TAG::Join) (JUNO_THREAD_ROOT_T *ptRoot)

Block until the managed thread exits.

Calls the platform join primitive (e.g., pthread_join) and blocks until the thread entry function returns. Must only be called after Stop (or after the thread has independently set bStop and exited).

Parameters
ptRootThread module root instance (caller-owned). Must not be NULL.
Returns
JUNO_STATUS_SUCCESS on success; non-zero on failure.

◆ Stop

JUNO_STATUS_T(* JUNO_THREAD_API_TAG::Stop) (JUNO_THREAD_ROOT_T *ptRoot)

Signal the managed thread to exit cooperatively.

Sets ptRoot->bStop = true. Does not cancel or forcibly terminate the OS thread; the thread entry function is responsible for observing the flag and returning voluntarily.

Parameters
ptRootThread module root instance (caller-owned). Must not be NULL.
Returns
JUNO_STATUS_SUCCESS on success; non-zero on failure.

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