|
LibJuno 1.0.4
LibJuno is a lightweight C11 library designed specifically for embedded systems.
|
MonitorApp — Thread 1 subscriber application for the udp-threads example. More...
#include "juno/app/app_api.h"#include "juno/ds/array_api.h"#include "juno/sb/broker_api.h"#include "juno/status.h"

Go to the source code of this file.
Typedefs | |
| typedef struct MONITOR_APP_TAG | MONITOR_APP_T |
Functions | |
| struct MONITOR_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 MonitorApp instance. | |
| JUNO_STATUS_T | MonitorApp_Init (MONITOR_APP_T *ptApp, JUNO_SB_BROKER_ROOT_T *ptBroker, JUNO_DS_ARRAY_ROOT_T *ptPipeArray, JUNO_FAILURE_HANDLER_T pfcnFailureHandler, void *pvFailureUserData) |
| Initialize a MonitorApp instance. | |
MonitorApp — Thread 1 subscriber application for the udp-threads example.
MonitorApp implements the JUNO_APP_API_T lifecycle interface and runs on Thread 1. On each scheduler cycle it dequeues all UDP_THREAD_MSG_T messages that SenderApp has published to Thread 1's software-bus broker and logs them.
Structural pattern:
MONITOR_APP_T embeds JUNO_APP_ROOT_T as its first member, enabling safe up-cast from JUNO_APP_ROOT_T* to MONITOR_APP_T*.JUNO_SB_PIPE_T is embedded directly in the struct (no heap allocation). The broker stores a pointer to this pipe after registration in OnStart.JUNO_DS_ARRAY_ROOT_T* injected at Init time provides the backing queue storage for the pipe; it must outlive the app instance.Init time. No resource is allocated by MonitorApp itself.Lifecycle:
OnStart — initializes the pipe for UDPTH_MSG_MID and registers it with the broker.OnProcess — drains the pipe, logging each dequeued message.OnExit — no-op; the embedded pipe is released with the struct. | typedef struct MONITOR_APP_TAG MONITOR_APP_T |
| struct MONITOR_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 MonitorApp instance.
All storage is caller-owned (stack or static). The composition root allocates this struct and injects all dependencies via MonitorApp_Init.
Member layout:
JUNO_MODULE_SUPER (tRoot) — Embedded via JUNO_MODULE_DERIVE; the scheduler dispatches via a JUNO_APP_ROOT_T* and the lifecycle functions recover the full struct by casting to MONITOR_APP_T*.ptBroker — Thread 1's broker; set at Init time; never NULL after Init._ptPipeArray — Backing array for the pipe's internal queue; injected at Init time; must outlive the pipe registration._pfcnFailureHandler — Diagnostic callback invoked before any error return; may be NULL._pvFailureUserData — Opaque user data passed to the failure handler; may be NULL.tPipe — Embedded subscription pipe; initialized in OnStart and registered with ptBroker. No separate allocation. | JUNO_STATUS_T MonitorApp_Init | ( | MONITOR_APP_T * | ptApp, |
| JUNO_SB_BROKER_ROOT_T * | ptBroker, | ||
| JUNO_DS_ARRAY_ROOT_T * | ptPipeArray, | ||
| JUNO_FAILURE_HANDLER_T | pfcnFailureHandler, | ||
| void * | pvFailureUserData | ||
| ) |
Initialize a MonitorApp instance.
Wires the internal vtable, stores all injected dependencies, and verifies that no required pointer is NULL. The pipe (tPipe) is NOT initialized here; pipe initialization is deferred to OnStart so that the broker registration occurs at the correct point in the application lifecycle.
The caller must ensure:
ptApp, ptBroker, and ptPipeArray are all non-NULL.ptBroker and ptPipeArray outlive this MONITOR_APP_T instance.| ptApp | Caller-owned app storage; must be non-NULL. |
| ptBroker | Thread 1's broker instance; must be non-NULL. |
| ptPipeArray | Backing array for the pipe's internal queue; must be non-NULL and must outlive the pipe registration. |
| pfcnFailureHandler | Diagnostic callback invoked before any error return; may be NULL. |
| pvFailureUserData | Opaque pointer passed through to the failure handler; may be NULL. |
JUNO_STATUS_SUCCESS on success; JUNO_STATUS_NULLPTR_ERROR if any required pointer is NULL.