Go to the source code of this file.
Data Structures | |
struct | PrivateTopic |
Internal representation of a Topic instance. More... | |
Macros | |
#define | DECLARE_TOPIC(topic) |
Macro to declare a topic instance. | |
#define | INIT_TOPIC(topic, commentInboxSize, messageSize) |
Macro to initialise a declared topic instance. | |
#define | CREATE_TOPIC(topic, commentInboxSize, messageSize) |
Macro to define and initialize a topic instance. | |
Functions | |
bool | Topic_publish (PrivateTopic *topic, uint8_t *article) |
Publish an "article" to all discovered subscribers of a topic. | |
struct PrivateTopic |
Internal representation of a Topic instance.
Holds the complete state for a topic managed by the publisher. This structure is primarily manipulated by the CREATE_TOPIC
macro and the Topic_publish
function.
Data Fields | ||
---|---|---|
Topic | public | Public topic interface. |
const SubInbox_t * | subscriptions | Subscription inbox array pointer. |
size_t | numSubscriptions | Number of subscriptions to the topic. |
#define DECLARE_TOPIC | ( | topic | ) |
Macro to declare a topic instance.
This macro performs several key actions for creating a publishable topic:
PrivateTopic
variable named topic
.__<topic>_subscriptions_start
, __<topic>_subscriptions_end
) #define INIT_TOPIC | ( | topic, | |
commentInboxSize, | |||
messageSize ) |
Macro to initialise a declared topic instance.
This macro:
startTopic
decorated with the constructor attribute. This ensures startTopic
runs automatically before main()
.startTopic
:commentInbox
) for receiving "comments" sent via Topic_comment
.topic
variable. #define CREATE_TOPIC | ( | topic, | |
commentInboxSize, | |||
messageSize ) |
Macro to define and initialize a topic instance.
This macro combines the DECLARE_TOPIC and INIT_TOPIC macros to create a topic in one step and initialise it automatically at run-time prior to main function entry.
NOTE: If used, this macro must be placed at global scope within a file
TODO: Replace while(1) with assert when printf redirect is implemented
bool Topic_publish | ( | PrivateTopic * | topic, |
uint8_t * | article ) |
Publish an "article" to all discovered subscribers of a topic.
Iterate through the array of subscriber queues that were discovered during initialization. For each valid (non-NULL) queue handle found in the array, attempt to send the provided article
data to the queue without blocking.
topic | Pointer to the PrivateTopic structure representing the topic to publish from. This contains the discovered subscriber list. |
article | Pointer to the data buffer containing the article/message to publish. The size and structure must be consistent with what subscribers expect and the size used when subscribers created their queues. |
true
if the arguments (topic
, article
) are valid and the publishing loop completed. Note: Does not guarantee successful delivery to all subscribers (queues might be full, handles might be invalid if subscriber didn't create queue correctly, etc.). false
if topic
or article
is NULL.