diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2008-01-03 10:42:46 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2008-01-03 10:42:46 +0000 |
commit | 48cb0a980f657fe1d6484a1322db26c753835f03 (patch) | |
tree | ac9c969f85b51d1f7dbef1765ec641090e3e17d5 /queue.h | |
parent | 29d9729292d44d2827054a1aef27278f3dadd57e (diff) | |
download | rsyslog-48cb0a980f657fe1d6484a1322db26c753835f03.tar.gz rsyslog-48cb0a980f657fe1d6484a1322db26c753835f03.tar.bz2 rsyslog-48cb0a980f657fe1d6484a1322db26c753835f03.zip |
restructured queue interface to use rsRetVal and instances, removed
dependency on globals - now more like a real class
Diffstat (limited to 'queue.h')
-rw-r--r-- | queue.h | 30 |
1 files changed, 8 insertions, 22 deletions
@@ -28,13 +28,12 @@ typedef enum { QUEUETYPE_FIXED_ARRAY, /* a simple queue made out of a fixed (initially malloced) array fast but memoryhog */ QUEUETYPE_LINKEDLIST, /* linked list used as buffer, lower fixed memory overhead but slower */ -} queueTypes_t; +} queueType_t; /* the queue object */ typedef struct { - queueTypes_t qType; - int iMaxQueSize; /* how large can the queue grow? */ - void** pUsr; /* the queued user data structure */ + queueType_t qType; + int iMaxQueueSize; /* how large can the queue grow? */ /* synchronization variables */ pthread_mutex_t *mut; pthread_cond_t *notFull, *notEmpty; @@ -43,29 +42,16 @@ typedef struct { union { /* different data elements based on queue type (qType) */ struct { long head, tail; + void** pBuf; /* the queued user data structure */ } farray; } tVars; } queue_t; -/* this is the first approach to a queue, this time with static - * memory. - */ -typedef struct { - void** pbuf; - long head, tail; - int full, empty; - pthread_mutex_t *mut; - pthread_cond_t *notFull, *notEmpty; -} msgQueue; /* prototypes */ -msgQueue *queueInit (void); -void queueDelete (msgQueue *q); -void queueAdd (msgQueue *q, void* in); -void queueDel (msgQueue *q, void **out); - -/* go-away's */ -extern int iMainMsgQueueSize; -extern msgQueue *pMsgQueue; +rsRetVal queueConstruct(queue_t **ppThis, queueType_t qType, int iMaxQueueSize); +rsRetVal queueDestruct(queue_t *pThis); +rsRetVal queueAdd(queue_t *pThis, void* in); +rsRetVal queueDel(queue_t *pThis, void **out); #endif /* #ifndef QUEUE_H_INCLUDED */ |