|
LibJuno 1.0.4
LibJuno is a lightweight C11 library designed specifically for embedded systems.
|
Public interface for ProcessorApp — the message-processing application on Thread 2. More...
#include "juno/app/app_api.h"#include "juno/ds/array_api.h"#include "juno/module.h"#include "juno/sb/broker_api.h"#include "juno/types.h"

Go to the source code of this file.
Typedefs | |
| typedef struct PROCESSOR_APP_TAG | PROCESSOR_APP_T |
Functions | |
| struct PROCESSOR_APP_TAG | JUNO_MODULE_DERIVE (JUNO_APP_ROOT_T, JUNO_SB_BROKER_ROOT_T *ptBroker;JUNO_DS_ARRAY_ROOT_T *_ptPipeArray;JUNO_FAILURE_HANDLER_T _pfcnFailureHandler;JUNO_USER_DATA_T *_pvFailureUserData;JUNO_SB_PIPE_T tPipe;) |
| Concrete ProcessorApp instance. | |
| JUNO_STATUS_T | ProcessorApp_Init (PROCESSOR_APP_T *ptApp, JUNO_SB_BROKER_ROOT_T *ptBroker, JUNO_DS_ARRAY_ROOT_T *ptPipeArray, JUNO_FAILURE_HANDLER_T pfcnFailureHandler, void *pvFailureUserData) |
| Initialize a ProcessorApp instance. | |
Public interface for ProcessorApp — the message-processing application on Thread 2.
ProcessorApp implements the JUNO_APP_API_T lifecycle interface. It subscribes to Thread 2's software-bus broker (via an embedded JUNO_SB_PIPE_T) and, on each scheduler cycle, dequeues and processes all messages that UdpBridgeApp has published under UDPTH_MSG_MID. It mirrors the MonitorApp pattern on Thread 1.
The subscription pipe (tPipe) is embedded directly in the struct — no separate allocation is required. Its backing array (_ptPipeArray) and the broker pointer (ptBroker) are injected at ProcessorApp_Init time; pipe initialization itself is deferred to ProcessorApp_OnStart so that registration with the broker occurs in the correct lifecycle phase.
All memory is caller-owned and injected. ProcessorApp allocates nothing.
Typical usage:
| typedef struct PROCESSOR_APP_TAG PROCESSOR_APP_T |
| struct PROCESSOR_APP_TAG JUNO_MODULE_DERIVE | ( | JUNO_APP_ROOT_T | , |
| JUNO_SB_BROKER_ROOT_T *ptBroker;JUNO_DS_ARRAY_ROOT_T *_ptPipeArray;JUNO_FAILURE_HANDLER_T _pfcnFailureHandler;JUNO_USER_DATA_T *_pvFailureUserData;JUNO_SB_PIPE_T tPipe; | |||
| ) |
Concrete ProcessorApp instance.
Embeds JUNO_APP_ROOT_T as its first member via JUNO_MODULE_DERIVE, enabling safe up-cast from a JUNO_APP_ROOT_T * to PROCESSOR_APP_T * inside the lifecycle callbacks. The scheduler holds a JUNO_APP_ROOT_T * and dispatches via the vtable; each callback recovers the full struct with:
The embedded root is accessible as JUNO_MODULE_SUPER (aliased to tRoot).
The tPipe member is embedded — no separate allocation is needed. The composition root owns this struct; no field is heap-allocated. _ptPipeArray, _pfcnFailureHandler, and _pvFailureUserData are stored at init time and forwarded to JunoSb_PipeInit during OnStart.
| JUNO_STATUS_T ProcessorApp_Init | ( | PROCESSOR_APP_T * | ptApp, |
| JUNO_SB_BROKER_ROOT_T * | ptBroker, | ||
| JUNO_DS_ARRAY_ROOT_T * | ptPipeArray, | ||
| JUNO_FAILURE_HANDLER_T | pfcnFailureHandler, | ||
| void * | pvFailureUserData | ||
| ) |
Initialize a ProcessorApp instance.
Wires the internal static vtable into ptApp->tRoot.ptApi, stores ptBroker, ptPipeArray, the failure handler, and user data. Verifies that no required injected pointer is NULL before returning. Pipe initialization is deferred to the OnStart lifecycle callback; this function does not call JunoSb_PipeInit or RegisterSubscriber.
Must be called before any lifecycle operation. All caller-allocated storage; this function does not allocate any memory.
| ptApp | Caller-owned ProcessorApp storage; must be non-NULL. |
| ptBroker | Thread 2 broker root; must be non-NULL and outlive ptApp. |
| ptPipeArray | Backing array for the subscription pipe; must be non-NULL and outlive ptApp. |
| pfcnFailureHandler | Diagnostic callback invoked before any error return; may be NULL. |
| pvFailureUserData | Opaque pointer passed to the failure handler; may be NULL. |
JUNO_STATUS_SUCCESS on success; JUNO_STATUS_NULLPTR_ERROR if any required pointer is NULL.