LibJuno 1.0.4
LibJuno is a lightweight C11 library designed specifically for embedded systems.
Loading...
Searching...
No Matches
processor_app.h File Reference

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"
Include dependency graph for processor_app.h:
This graph shows which files directly or indirectly include this file:

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.
 

Detailed Description

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:

PROCESSOR_APP_T tProcessor;
ProcessorApp_Init(&tProcessor,
&tBroker2, &tPipeArray,
MyFailureHandler, NULL);
tProcessor.tRoot.ptApi->OnStart(&tProcessor.tRoot);
// ... scheduler loop ...
tProcessor.tRoot.ptApi->OnProcess(&tProcessor.tRoot);
// ...
tProcessor.tRoot.ptApi->OnExit(&tProcessor.tRoot);
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.
Definition processor_app.cpp:110
struct PROCESSOR_APP_TAG PROCESSOR_APP_T
Definition processor_app.h:98

Typedef Documentation

◆ PROCESSOR_APP_T

typedef struct PROCESSOR_APP_TAG PROCESSOR_APP_T

Function Documentation

◆ JUNO_MODULE_DERIVE()

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:

PROCESSOR_APP_T *ptProcessor = (PROCESSOR_APP_T *)ptApp;

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.

◆ ProcessorApp_Init()

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.

Parameters
ptAppCaller-owned ProcessorApp storage; must be non-NULL.
ptBrokerThread 2 broker root; must be non-NULL and outlive ptApp.
ptPipeArrayBacking array for the subscription pipe; must be non-NULL and outlive ptApp.
pfcnFailureHandlerDiagnostic callback invoked before any error return; may be NULL.
pvFailureUserDataOpaque pointer passed to the failure handler; may be NULL.
Returns
JUNO_STATUS_SUCCESS on success; JUNO_STATUS_NULLPTR_ERROR if any required pointer is NULL.