75 lines
1.3 KiB
C
75 lines
1.3 KiB
C
#pragma once
|
|
|
|
#ifdef __cplusplus
|
|
extern "C"
|
|
{
|
|
#endif
|
|
|
|
#include "stellar/mq.h"
|
|
#include "uthash/utarray.h"
|
|
|
|
#include <stdbool.h>
|
|
|
|
struct mq_message
|
|
{
|
|
struct mq_runtime *rt;
|
|
struct
|
|
{
|
|
int topic_id;
|
|
} header;
|
|
void *body;
|
|
struct mq_message *next, *prev;
|
|
} __attribute__((aligned(sizeof(void *))));
|
|
|
|
typedef struct mq_subscriber
|
|
{
|
|
int topic_subscriber_idx;
|
|
int plugin_idx;
|
|
on_msg_cb_func *msg_cb;
|
|
void *msg_cb_arg;
|
|
struct mq_subscriber *next, *prev;
|
|
}stellar_mq_subscriber __attribute__((aligned(sizeof(void*))));
|
|
|
|
|
|
struct mq_topic
|
|
{
|
|
char *topic_name;
|
|
int topic_id;
|
|
int subscriber_cnt;
|
|
int is_destroyed;
|
|
on_msg_dispatch_cb_func *dispatch_cb;
|
|
void *dispatch_cb_arg;
|
|
mq_msg_free_cb_func *free_cb;
|
|
void *free_cb_arg;
|
|
struct mq_subscriber *subscribers;
|
|
}__attribute__((aligned(sizeof(void*))));
|
|
|
|
struct mq_schema
|
|
{
|
|
UT_array *topic_array;
|
|
int mq_topic_num;
|
|
int mq_topic_subscriber_num;
|
|
};
|
|
|
|
|
|
enum mq_property
|
|
{
|
|
MQ_MAILBOX = 0,
|
|
MQ_DEATH_LETTER = 1,
|
|
MQ_MAX,
|
|
};
|
|
|
|
struct mq_runtime
|
|
{
|
|
struct mq_schema *schema;
|
|
struct mq_message *mq[MQ_MAX];// message queue
|
|
size_t mq_len[MQ_MAX];
|
|
bool is_cleaning;
|
|
bool defer_enabled;
|
|
};
|
|
|
|
int mq_runtime_publish_message_immediate(struct mq_runtime *rt, int topic_id, void *msg);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif |