Distributed Publish & Subscribe for IoT
Dispatcher

Register functions to be called after a timeout period expires. More...

Typedefs

typedef void(* DPS_DelayedFunc) (DPS_Node *node, void *data)
 Prototype for a delayed dispatched function call. More...
 
typedef struct _DPS_Dispatcher DPS_Dispatcher
 Opaque type for an dispatcher.
 
typedef void(* DPS_DispatchFunc) (DPS_Node *node, DPS_Dispatcher *dispatcher, void *data)
 Prototype for function to be called by a dispatcher. More...
 

Functions

DPS_DispatcherDPS_CreateDispatcher (DPS_Node *node, DPS_DispatchFunc func)
 Create a dispatcher and register the function to be called. More...
 
void DPS_DestroyDispatcher (DPS_Dispatcher *dispatcher)
 Destroy a dispatcher and free resources. More...
 
DPS_Status DPS_Dispatch (DPS_Dispatcher *dispatcher, void *data, int delay)
 Call the function registered when the dispatcher was created. More...
 
DPS_Status DPS_ScheduleCall (DPS_Node *node, DPS_DelayedFunc func, void *data, int delay)
 Wrapper function that creates a dispatcher and schedules a function to be called after a delay. More...
 

Detailed Description

Register functions to be called after a timeout period expires.

Typedef Documentation

◆ DPS_DelayedFunc

typedef void(* DPS_DelayedFunc) (DPS_Node *node, void *data)

Prototype for a delayed dispatched function call.

This function will be called on the main (internal) node thread and must not block. The dispatcher is internal and not exposed in this usage.

Parameters
nodeThe node used for this dispatcher
dataThe data passed to the DPS_CallDelayedFunc() call

◆ DPS_DispatchFunc

typedef void(* DPS_DispatchFunc) (DPS_Node *node, DPS_Dispatcher *dispatcher, void *data)

Prototype for function to be called by a dispatcher.

This function will be called on the main (internal) node thread and must not block.

Parameters
nodeThe node used for this dispatcher
dispatcherThe dispatcher for this call
dataThe data passed to the DPS_Dispatch() call

Function Documentation

◆ DPS_CreateDispatcher()

DPS_Dispatcher* DPS_CreateDispatcher ( DPS_Node node,
DPS_DispatchFunc  func 
)

Create a dispatcher and register the function to be called.

Parameters
nodeThe node to be used for this dispatcher
funcThe function to be called
Returns
The created dispatcher, or NULL if creation failed

◆ DPS_DestroyDispatcher()

void DPS_DestroyDispatcher ( DPS_Dispatcher dispatcher)

Destroy a dispatcher and free resources.

Parameters
dispatcherThe dispatcher to destroy

◆ DPS_Dispatch()

DPS_Status DPS_Dispatch ( DPS_Dispatcher dispatcher,
void *  data,
int  delay 
)

Call the function registered when the dispatcher was created.

Parameters
dispatcherThe dispatcher to call
dataData to be passed to the function
delayTime delay in millseconds before the function will be called
Returns
  • DPS_OK if the function call is scheduled
  • DPS_ERR_BUSY if the dispatcher cannot schedule the function
  • Or an error status code in which case the callback will not be called.

◆ DPS_ScheduleCall()

DPS_Status DPS_ScheduleCall ( DPS_Node node,
DPS_DelayedFunc  func,
void *  data,
int  delay 
)

Wrapper function that creates a dispatcher and schedules a function to be called after a delay.

The dispatcher is destroyed after the function has been called.

Parameters
nodeThe node to be used for the internal dispatcher
funcThe function to be called
dataData to be passed to the function
delayTime delay in millseconds before the function will be called
Returns
  • DPS_OK if the function call is scheduled
  • DPS_ERR_BUSY if the dispatcher cannot schedule the function
  • Or an error status code in which case the callback will not be called.