LibJuno 1.0.4
LibJuno is a lightweight C11 library designed specifically for embedded systems.
Loading...
Searching...
No Matches
thread_api.h
Go to the documentation of this file.
1/*
2 MIT License
3
4 Copyright (c) 2025 Robin A. Onsay
5
6 Permission is hereby granted, free of charge, to any person obtaining
7 a copy of this software and associated documentation files
8 (the "Software"), to deal in the Software without restriction,
9 including without limitation the rights to use, copy, modify, merge,
10 publish, distribute, sublicense, and/or sell copies of the Software,
11 and to permit persons to whom the Software is furnished to do so,
12 subject to the following conditions:
13
14 The above copyright notice and this permission notice shall be
15 included in all copies or substantial portions of the Software.
16
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24*/
25
64#ifndef JUNO_THREAD_API_H
65#define JUNO_THREAD_API_H
66
67#include <stdint.h>
68#include <stdbool.h>
69#include "juno/status.h"
70#include "juno/module.h"
71#include "juno/types.h"
72
73#ifdef __cplusplus
74extern "C"
75{
76#endif
77
78/* -------------------------------------------------------------------------
79 * Forward declarations
80 * ---------------------------------------------------------------------- */
81
83typedef struct JUNO_THREAD_ROOT_TAG JUNO_THREAD_ROOT_T;
84
87
89typedef struct JUNO_THREAD_LINUX_TAG JUNO_THREAD_LINUX_T;
90
94typedef union JUNO_THREAD_TAG JUNO_THREAD_T;
95
96/* -------------------------------------------------------------------------
97 * Module root
98 * ---------------------------------------------------------------------- */
99
117// @{"req": ["REQ-THREAD-001", "REQ-THREAD-007", "REQ-THREAD-008", "REQ-THREAD-009"]}
118struct JUNO_THREAD_ROOT_TAG JUNO_MODULE_ROOT(JUNO_THREAD_API_T,
121 volatile bool bStop;
122);
123
124/* -------------------------------------------------------------------------
125 * Vtable
126 * ---------------------------------------------------------------------- */
127
142// @{"req": ["REQ-THREAD-002", "REQ-THREAD-014"]}
183
184/* -------------------------------------------------------------------------
185 * Generic initialisation
186 * ---------------------------------------------------------------------- */
187
208 JUNO_THREAD_ROOT_T *ptRoot,
209 const JUNO_THREAD_API_T *ptApi,
210 JUNO_FAILURE_HANDLER_T pfcnFailureHandler,
211 void *pvFailureUserData
212);
213
214#ifdef __cplusplus
215}
216#endif
217
218#endif /* JUNO_THREAD_API_H */
#define JUNO_MODULE_ROOT(API_T,...)
Implement a module root struct containing ptApi and failure fields.
Definition module.h:129
void(* JUNO_FAILURE_HANDLER_T)(JUNO_STATUS_T tStatus, const char *pcCustomMessage, JUNO_USER_DATA_T *pvUserData)
Failure handler callback signature.
Definition status.h:110
int32_t JUNO_STATUS_T
Canonical status type for LibJuno functions.
Definition status.h:51
Module system and dependency injection primitives for LibJuno.
Status codes and failure-handling helpers for LibJuno.
Thread module vtable (API struct).
Definition thread_api.h:144
JUNO_STATUS_T(* Free)(JUNO_THREAD_ROOT_T *ptRoot)
Release platform resources held by the Thread module instance.
Definition thread_api.h:181
JUNO_STATUS_T(* Join)(JUNO_THREAD_ROOT_T *ptRoot)
Block until the managed thread exits.
Definition thread_api.h:169
JUNO_STATUS_T(* Stop)(JUNO_THREAD_ROOT_T *ptRoot)
Signal the managed thread to exit cooperatively.
Definition thread_api.h:156
struct JUNO_THREAD_ROOT_TAG JUNO_THREAD_ROOT_T
Forward declaration of the Thread module root struct.
Definition thread_api.h:83
union JUNO_THREAD_TAG JUNO_THREAD_T
Forward declaration of the Thread module union. The full union body is defined in juno/thread_linux....
Definition thread_api.h:94
struct JUNO_THREAD_LINUX_TAG JUNO_THREAD_LINUX_T
Forward declaration of the Linux/POSIX derivation struct.
Definition thread_api.h:89
JUNO_STATUS_T JunoThread_Init(JUNO_THREAD_ROOT_T *ptRoot, const JUNO_THREAD_API_T *ptApi, JUNO_FAILURE_HANDLER_T pfcnFailureHandler, void *pvFailureUserData)
Initialise a Thread module root with a concrete vtable and failure handler.
Definition juno_thread_init.cpp:52
Common module result type aliases used throughout LibJuno.