CDI SDK
SDK for transporting chunks of data reliably and with low latency using a polled mode network driver.
Loading...
Searching...
No Matches
cdi_queue_api.h
Go to the documentation of this file.
1// -------------------------------------------------------------------------------------------
2// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
3// This file is part of the AWS CDI-SDK, licensed under the BSD 2-Clause "Simplified" License.
4// License details at: https://github.com/aws/aws-cdi-sdk/blob/mainline/LICENSE
5// -------------------------------------------------------------------------------------------
6
13#ifndef CDI_QUEUE_API_H__
14#define CDI_QUEUE_API_H__
15
16#include <stdbool.h>
17#include <stdint.h>
18
19#include "cdi_os_api.h"
20
21//*********************************************************************************************************************
22//***************************************** START OF DEFINITIONS AND TYPES ********************************************
23//*********************************************************************************************************************
24
26#define CDI_FIXED_QUEUE_SIZE (0)
27
32typedef struct CdiQueueState* CdiQueueHandle;
33
55
58
59//*********************************************************************************************************************
60//******************************************* START OF PUBLIC FUNCTIONS ***********************************************
61//*********************************************************************************************************************
62
76CDI_INTERFACE bool CdiQueueCreate(const char* name_str, uint32_t item_count, uint32_t grow_count,
77 uint32_t max_grow_count, uint32_t item_byte_size, CdiQueueSignalMode signal_mode,
78 CdiQueueHandle* ret_handle_ptr);
79
90CDI_INTERFACE bool CdiQueuePop(CdiQueueHandle handle, void* item_dest_ptr);
91
105CDI_INTERFACE bool CdiQueuePopWait(CdiQueueHandle handle, int timeout_ms, CdiSignalType abort_wait_signal,
106 void* item_dest_ptr);
107
125CDI_INTERFACE bool CdiQueuePopWaitMultiple(CdiQueueHandle handle, int timeout_ms,
126 CdiSignalType* abort_wait_signal_array, int num_signals,
127 uint32_t* ret_signal_index_ptr, void* item_dest_ptr);
128
137CDI_INTERFACE bool CdiQueuePush(CdiQueueHandle handle, const void* item_ptr);
138
150CDI_INTERFACE bool CdiQueuePushWait(CdiQueueHandle handle, int timeout_ms, CdiSignalType abort_wait_signal,
151 const void* item_ptr);
152
168CDI_INTERFACE bool CdiQueuePushWaitMultiple(CdiQueueHandle handle, int timeout_ms,
169 CdiSignalType* abort_wait_signal_array, int num_signals,
170 uint32_t* ret_signal_index_ptr, const void* item_ptr);
171
180
188
197
206
213
225
233typedef void (*CdiQueueCallback)(const CdiQueueCbData* data_ptr);
234
235#ifdef DEBUG
243CDI_INTERFACE void CdiQueueDebugEnable(CdiQueueHandle handle, CdiQueueCallback cb_ptr);
244
250CDI_INTERFACE void CdiQueueDebugDisable(CdiQueueHandle handle);
251#endif //DEBUG
252
259
260#endif // CDI_QUEUE_API_H__
This file contains the declarations for OS functions for creating/managing/freeing threads,...
struct CdiSignalType_t * CdiSignalType
Define portable signal type. Don't use void* here, which prevents the compiler from type checking.
Definition cdi_os_api.h:189
CDI_INTERFACE CdiSignalType CdiQueueGetPopWaitSignal(CdiQueueHandle handle)
Definition queue.c:540
CDI_INTERFACE bool CdiQueuePush(CdiQueueHandle handle, const void *item_ptr)
Definition queue.c:417
CDI_INTERFACE void CdiQueueDestroy(CdiQueueHandle handle)
Definition queue.c:579
CDI_INTERFACE void CdiQueueFlush(CdiQueueHandle handle)
Definition queue.c:515
CdiQueueSignalMode
This enumeration is used in the internal queue structure to indicate the type of OS signals,...
Definition cdi_queue_api.h:38
@ kQueueSignalPushWait
In this mode, use CdiQueuePushWait() to block and wait on a full queue. Use CdiQueueGetPushWaitSignal...
Definition cdi_queue_api.h:47
@ kQueueMultipleWritersFlag
Optional flag to add locking for thread safe pushing into the queue.
Definition cdi_queue_api.h:53
@ kQueueSignalNone
In this mode signals are not used.
Definition cdi_queue_api.h:39
@ kQueueSignalPopWait
In this mode, use CdiQueuePopWait() to block and wait on an empty queue. Use CdiQueueGetPopWaitSignal...
Definition cdi_queue_api.h:43
@ kQueueSignalPopPushWait
In this mode, signals are enabled for both push and pop operations (see above).
Definition cdi_queue_api.h:49
@ kQueueSignalModeMask
Mask that only includes the main mode options. Used for ignoring option flags.
Definition cdi_queue_api.h:51
CDI_INTERFACE bool CdiQueuePopWait(CdiQueueHandle handle, int timeout_ms, CdiSignalType abort_wait_signal, void *item_dest_ptr)
Definition queue.c:389
CDI_INTERFACE bool CdiQueuePop(CdiQueueHandle handle, void *item_dest_ptr)
Definition queue.c:338
CDI_INTERFACE CdiSignalType CdiQueueGetPushWaitSignal(CdiQueueHandle handle)
Definition queue.c:528
CDI_INTERFACE bool CdiQueueCreate(const char *name_str, uint32_t item_count, uint32_t grow_count, uint32_t max_grow_count, uint32_t item_byte_size, CdiQueueSignalMode signal_mode, CdiQueueHandle *ret_handle_ptr)
Creates a queue. Memory is allocated by this function.
Definition queue.c:266
CDI_INTERFACE const char * CdiQueueGetName(CdiQueueHandle handle)
Definition queue.c:552
void(* CdiQueueCallback)(const CdiQueueCbData *data_ptr)
Definition cdi_queue_api.h:233
CDI_INTERFACE bool CdiQueuePopWaitMultiple(CdiQueueHandle handle, int timeout_ms, CdiSignalType *abort_wait_signal_array, int num_signals, uint32_t *ret_signal_index_ptr, void *item_dest_ptr)
Definition queue.c:394
CDI_INTERFACE bool CdiQueueIsEmpty(CdiQueueHandle handle)
Definition queue.c:521
CDI_INTERFACE bool CdiQueuePushWaitMultiple(CdiQueueHandle handle, int timeout_ms, CdiSignalType *abort_wait_signal_array, int num_signals, uint32_t *ret_signal_index_ptr, const void *item_ptr)
Definition queue.c:487
CDI_INTERFACE bool CdiQueuePushWait(CdiQueueHandle handle, int timeout_ms, CdiSignalType abort_wait_signal, const void *item_ptr)
Definition queue.c:482
struct CdiQueueState * CdiQueueHandle
Type used as the handle (pointer to an opaque structure) for a queue. Each handle represents a instan...
Definition cdi_queue_api.h:32
#define CDI_INTERFACE
Specify C linkage when compiling as C++ and define API interface export for Windows.
Definition cdi_utility_api.h:34
A structure of this type is passed as the parameter to CdiQueueCallback(). It contains the state of a...
Definition cdi_queue_api.h:218
bool is_pop
True if read triggered the callback, otherwise a write triggered it.
Definition cdi_queue_api.h:219
CdiSinglyLinkedListEntry * read_ptr
Current read pointer in the queue.
Definition cdi_queue_api.h:220
CdiSinglyLinkedListEntry * write_ptr
Current write pointer in the queue.
Definition cdi_queue_api.h:221
void * item_data_ptr
Pointer to item data.
Definition cdi_queue_api.h:222
int occupancy
The number of entries currently enqueued.
Definition cdi_queue_api.h:223
This structure represents a single list entry.
Definition singly_linked_list_api.h:49