CDI SDK
SDK for transporting chunks of data reliably and with low latency using a polled mode network driver.
Loading...
Searching...
No Matches
timeout.h File Reference

The declarations in this header file correspond to the definitions in timeout.c. More...

#include <stdbool.h>
#include "cdi_core_api.h"
#include "cdi_logger_api.h"
#include "cdi_os_api.h"
#include "cdi_pool_api.h"
#include "fifo_api.h"
#include "list_api.h"

Go to the source code of this file.

Data Structures

struct  TimeoutDataState
 TimeoutDataState is the basic object used to build the list of timers This object contains a timeout, a next and previous handle, and user data pointer, and a user data callback function pointer. More...
 
struct  TimeoutInstanceState
 This structure contains all of the state information for the timer instance. This includes signals, thread ID's, and pointers to the memory pool and timer list. More...
 
struct  CdiTimeoutCbData
 Structure for Callback functions to use to return data from callback. More...
 

Macros

#define MAX_TIMERS   25
 Maximum number of timers per timeout instance.
 
#define MAX_TIMERS_GROW   5
 Number of timers that may be added when increasing memory pool if needed.
 

Typedefs

typedef struct TimeoutDataState TimeoutDataState
 TimeoutDataState is the basic object used to build the list of timers This object contains a timeout, a next and previous handle, and user data pointer, and a user data callback function pointer.
 
typedef struct TimeoutDataStateTimeoutHandle
 This is the handle for TimeoutDataState.
 
typedef struct TimeoutInstanceState TimeoutInstanceState
 This structure contains all of the state information for the timer instance. This includes signals, thread ID's, and pointers to the memory pool and timer list.
 
typedef struct TimeoutInstanceStateCdiTimeoutInstanceHandle
 a handle for use with TimeoutInstanceState structure
 
typedef void(* CdiTimeoutCallback) (const CdiTimeoutCbData *data_ptr)
 Callback function definition used by CdiTimeoutAdd.
 

Functions

CdiReturnStatus CdiTimeoutCreate (CdiLogHandle log_handle, CdiTimeoutInstanceHandle *ret_handle)
 Creates a TimeoutInstanceState structure memory allocated for a pool of TimeoutDataState structures as well as all signals and threads setup.
 
void CdiTimeoutDestroy (CdiTimeoutInstanceHandle handle)
 Destroys a TimeoutInstanceState structure freeing associated mememory and other resources such as waking associated threads get them to exit.
 
bool CdiTimeoutAdd (CdiTimeoutInstanceHandle instance_handle, CdiTimeoutCallback cb_ptr, int timeout_us, void *user_data_ptr, TimeoutHandle *ret_handle)
 Adds a timeout to the active timeout list and puts the timeout in order based on when the timeout occurs.
 
bool CdiTimeoutRemove (TimeoutHandle handle, CdiTimeoutInstanceHandle instance_handle)
 Removes a timeout from the timeout list thread, generally upon completion of operation.
 

Detailed Description

The declarations in this header file correspond to the definitions in timeout.c.

Function Documentation

◆ CdiTimeoutAdd()

bool CdiTimeoutAdd ( CdiTimeoutInstanceHandle instance_handle,
CdiTimeoutCallback cb_ptr,
int timeout_us,
void * user_data_ptr,
TimeoutHandle * ret_handle )

Adds a timeout to the active timeout list and puts the timeout in order based on when the timeout occurs.

Parameters
instance_handlePointer to this timeout instance.
cb_ptrPointer to Callback data structure CdiTimeoutCbData
timeout_usTimeout time in microseconds
user_data_ptrPointer to user data for this object.
ret_handlea Handle returned of CdiTimeoutCbData object
Returns
true if timeout was successfully added to timeout list; false if failed

◆ CdiTimeoutCreate()

CdiReturnStatus CdiTimeoutCreate ( CdiLogHandle log_handle,
CdiTimeoutInstanceHandle * ret_handle )

Creates a TimeoutInstanceState structure memory allocated for a pool of TimeoutDataState structures as well as all signals and threads setup.

Parameters
log_handleHandle of log to use for log messages by this object's internal threads.
ret_handlereturns the handle to the TimeoutInstanceState structure
Returns
kCdiStatusOk if successful, other CdiReturnStatus codes on failure

◆ CdiTimeoutDestroy()

void CdiTimeoutDestroy ( CdiTimeoutInstanceHandle handle)

Destroys a TimeoutInstanceState structure freeing associated mememory and other resources such as waking associated threads get them to exit.

Parameters
handleis the handle for the TimeoutInstanceState structure to be destroyed and have associated resources freed.

◆ CdiTimeoutRemove()

bool CdiTimeoutRemove ( TimeoutHandle handle,
CdiTimeoutInstanceHandle instance_handle )

Removes a timeout from the timeout list thread, generally upon completion of operation.

Parameters
handlefor the timeout that is to be removed from the timeout list
instance_handlefor the thread level state data
Returns
true if timeout has successfully been removed from timeout list. false if failed