ndn-lite
Macros | Typedefs | Functions
Message Queue

Message queue of the forwarder. More...

Collaboration diagram for Message Queue:

Macros

#define NDN_MSGQUEUE_SIZE   4096
 The size of message queue in bytes. More...
 

Typedefs

typedef void(* ndn_msg_callback) (void *self, size_t param_length, void *param)
 The callback function of message. More...
 

Functions

void ndn_msgqueue_init (void)
 Init the message queue. More...
 
struct ndn_msgndn_msgqueue_post (void *target, ndn_msg_callback reason, size_t param_length, void *param)
 Post a message to the queue. More...
 
bool ndn_msgqueue_dispatch (void)
 Dispatch a message on the top of the queue. More...
 
bool ndn_msgqueue_empty (void)
 Return if the messque queue is empty. More...
 
void ndn_msgqueue_process (void)
 Dispatch current messages. More...
 
void ndn_msgqueue_cancel (struct ndn_msg *msg)
 Cancel a posted message. More...
 

Detailed Description

Message queue of the forwarder.

Macro Definition Documentation

◆ NDN_MSGQUEUE_SIZE

#define NDN_MSGQUEUE_SIZE   4096

The size of message queue in bytes.

Typedef Documentation

◆ ndn_msg_callback

typedef void(* ndn_msg_callback) (void *self, size_t param_length, void *param)

The callback function of message.

Parameters
[in,out]selfThe object to receive this message.
[in]param_length[Optional] The length of the param.
[in]param[Optional] Point to a raw memory in size param_length.

Function Documentation

◆ ndn_msgqueue_cancel()

void ndn_msgqueue_cancel ( struct ndn_msg msg)

Cancel a posted message.

Please make sure the pointer is correct and it's used before dispatch.

Parameters
[in]msgPointer to message

◆ ndn_msgqueue_dispatch()

bool ndn_msgqueue_dispatch ( void  )

Dispatch a message on the top of the queue.

Call the message by reason(target, param_length, param) .

Return values
trueOne message dispatched.
falseThe queue is empty. Do nothing.

◆ ndn_msgqueue_empty()

bool ndn_msgqueue_empty ( void  )

Return if the messque queue is empty.

Return values
trueEmpty.
falseNot empty.
Note
This function will defragment the queue if it's empty.

◆ ndn_msgqueue_init()

void ndn_msgqueue_init ( void  )

Init the message queue.

◆ ndn_msgqueue_post()

struct ndn_msg* ndn_msgqueue_post ( void *  target,
ndn_msg_callback  reason,
size_t  param_length,
void *  param 
)

Post a message to the queue.

Parameters
[in]targetThe object to receive this message.
[in]reasonThe message callback function.
[in]length[Optional] The length of parameters param.
[in]param[Optional] The parameters of this message. Its context will be copied into the queue.
Returns
An pointer to cancel the message. NULL if failed.

◆ ndn_msgqueue_process()

void ndn_msgqueue_process ( void  )

Dispatch current messages.

Process all messages currently in the queue. New messages posted during this function will not be dispatched.