ndn-lite
msg-queue.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 Xinyu Ma
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v3.0. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
9 #ifndef FORWARDER_MSG_QUEUE_H_
10 #define FORWARDER_MSG_QUEUE_H_
11 
12 #include <inttypes.h>
13 #include <stdbool.h>
14 #include <stddef.h>
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
32 #define NDN_MSGQUEUE_SIZE 4096
33 
34 #pragma pack(1)
35 struct ndn_msg;
36 #pragma pack()
37 
44 typedef void(*ndn_msg_callback)(void *self,
45  size_t param_length,
46  void *param);
47 
50 void
51 ndn_msgqueue_init(void);
52 
61 struct ndn_msg*
62 ndn_msgqueue_post(void *target,
63  ndn_msg_callback reason,
64  size_t param_length,
65  void *param);
66 
73 bool
75 
81 bool
82 ndn_msgqueue_empty(void);
83 
89 void
91 
97 void
98 ndn_msgqueue_cancel(struct ndn_msg* msg);
99 
102 #ifdef __cplusplus
103 }
104 #endif
105 
106 #endif // #define FORWARDER_MSG_QUEUE_H_
struct ndn_msg * ndn_msgqueue_post(void *target, ndn_msg_callback reason, size_t param_length, void *param)
Post a message to the queue.
Definition: msg-queue.c:75
uint8_t param[]
Definition: msg-queue.c:32
void ndn_msgqueue_process(void)
Dispatch current messages.
Definition: msg-queue.c:128
Definition: msg-queue.c:28
void(* ndn_msg_callback)(void *self, size_t param_length, void *param)
The callback function of message.
Definition: msg-queue.h:44
bool ndn_msgqueue_dispatch(void)
Dispatch a message on the top of the queue.
Definition: msg-queue.c:65
bool ndn_msgqueue_empty(void)
Return if the messque queue is empty.
Definition: msg-queue.c:52
void ndn_msgqueue_init(void)
Init the message queue.
Definition: msg-queue.c:47
void ndn_msgqueue_cancel(struct ndn_msg *msg)
Cancel a posted message.
Definition: msg-queue.c:136