|
LibJuno 1.0.4
LibJuno is a lightweight C11 library designed specifically for embedded systems.
|
Linux/pthreads implementation of the Thread module vtable. More...
#include "juno/thread_linux.h"#include "juno/status.h"#include "juno/macros.h"#include <string.h>
Functions | |
| static JUNO_STATUS_T | Stop (JUNO_THREAD_ROOT_T *ptRoot) |
| Signal the managed thread to exit cooperatively. | |
| static JUNO_STATUS_T | Join (JUNO_THREAD_ROOT_T *ptRoot) |
| Block until the managed thread exits. | |
| static JUNO_STATUS_T | Free (JUNO_THREAD_ROOT_T *ptRoot) |
| Release platform resources held by the Thread module instance. | |
| JUNO_STATUS_T | JunoThread_LinuxInit (JUNO_THREAD_T *ptThread, void *(*pfcnEntry)(void *), void *pvArg, JUNO_FAILURE_HANDLER_T pfcnFailureHandler, void *pvFailureUserData) |
| Initialise a Thread module instance and immediately spawn the OS thread. | |
Variables | |
| static const JUNO_THREAD_API_T | s_tJunoThreadLinuxApi |
Linux/pthreads implementation of the Thread module vtable.
Provides the static s_tJunoThreadLinuxApi vtable and the RAII entry point JunoThread_LinuxInit. Thread creation is handled entirely inside JunoThread_LinuxInit (RAII pattern); no separate Create vtable slot exists. The pthread_t handle is stored in the JUNO_THREAD_LINUX_T derivation, not in the freestanding root, so thread_api.h remains compilable without POSIX headers.
pthreads headers are included only in this translation unit via juno/thread_linux.h; all other translation units that need only the generic interface include juno/thread_api.h.
|
static |
Release platform resources held by the Thread module instance.
Zeroes the _tHandle field in the Linux derivation, resetting it to a known-clean state. Must be called only after Join has returned successfully.
| ptRoot | Thread module root instance (caller-owned). Must not be NULL. |
JUNO_STATUS_SUCCESS on success. JUNO_STATUS_NULLPTR_ERROR if ptRoot is NULL.
|
static |
Block until the managed thread exits.
Calls pthread_join on the handle stored in the Linux derivation and blocks until the thread entry function returns. On success, zeroes the _tHandle field so the instance may be safely reused or freed.
| ptRoot | Thread module root instance (caller-owned). Must not be NULL. |
JUNO_STATUS_SUCCESS on success. JUNO_STATUS_NULLPTR_ERROR if ptRoot is NULL. JUNO_STATUS_ERR if pthread_join() fails. | JUNO_STATUS_T JunoThread_LinuxInit | ( | JUNO_THREAD_T * | ptThread, |
| void *(*)(void *) | pfcnEntry, | ||
| void * | pvArg, | ||
| JUNO_FAILURE_HANDLER_T | pfcnFailureHandler, | ||
| void * | pvFailureUserData | ||
| ) |
Initialise a Thread module instance and immediately spawn the OS thread.
ptThread and pfcnEntry (returns JUNO_STATUS_NULLPTR_ERROR if either is NULL).JunoThread_Init to wire s_tJunoThreadLinuxApi, clear bStop, and store the failure handler.ptThread->tLinux._tHandle.pthread_create; on failure returns JUNO_STATUS_ERR.pthread_t in ptThread->tLinux._tHandle.| ptThread | Caller-owned JUNO_THREAD_T union. Must not be NULL. |
| pfcnEntry | Thread entry function. Must not be NULL. |
| pvArg | Argument forwarded verbatim to pfcnEntry; may be NULL. |
| pfcnFailureHandler | Diagnostic callback invoked before any error return; may be NULL. |
| pvFailureUserData | Opaque pointer threaded to pfcnFailureHandler; may be NULL. |
JUNO_STATUS_SUCCESS on success. JUNO_STATUS_NULLPTR_ERROR if a required pointer is NULL. JUNO_STATUS_ERR if pthread_create() fails.
|
static |
Signal the managed thread to exit cooperatively.
Sets ptRoot->bStop to true. Does not cancel, signal, or interrupt the thread; the entry function must poll bStop and return voluntarily.
| ptRoot | Thread module root instance (caller-owned). Must not be NULL. |
JUNO_STATUS_SUCCESS on success. JUNO_STATUS_NULLPTR_ERROR if ptRoot is NULL.
|
static |