| 1 |
|
| 2 |
|
| 3 |
#ifndef eslWORKQUEUE_INCLUDED |
| 4 |
#define eslWORKQUEUE_INCLUDED |
| 5 |
#include <esl_config.h> |
| 6 |
|
| 7 |
typedef struct { |
| 8 |
pthread_mutex_t queueMutex; |
| 9 |
pthread_cond_t readerQueueCond; |
| 10 |
pthread_cond_t workerQueueCond; |
| 11 |
|
| 12 |
void **readerQueue; |
| 13 |
int readerQueueCnt; |
| 14 |
int readerQueueHead; |
| 15 |
|
| 16 |
void **workerQueue; |
| 17 |
int workerQueueCnt; |
| 18 |
int workerQueueHead; |
| 19 |
|
| 20 |
int queueSize; |
| 21 |
int pendingWorkers; |
| 22 |
} ESL_WORK_QUEUE; |
| 23 |
|
| 24 |
typedef struct{ |
| 25 |
pthread_mutex_t queueMutex; |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
void **readerQueue; |
| 30 |
int readerQueueCnt; |
| 31 |
int readerQueueHead; |
| 32 |
|
| 33 |
void **workerQueue; |
| 34 |
int workerQueueCnt; |
| 35 |
int workerQueueHead; |
| 36 |
|
| 37 |
void ***workerWaitQueue; |
| 38 |
int workerWaitQueueCnt; |
| 39 |
int workerWaitQueueHead; |
| 40 |
|
| 41 |
void ***readerWaitQueue; |
| 42 |
int readerWaitQueueCnt; |
| 43 |
int readerWaitQueueHead; |
| 44 |
|
| 45 |
int queueSize; |
| 46 |
int waitingWorkers; |
| 47 |
int waitingReaders; |
| 48 |
} ESL_WORK_QUEUE_QUEUELOCK; |
| 49 |
|
| 50 |
|
| 51 |
extern ESL_WORK_QUEUE *esl_workqueue_Create(int size); |
| 52 |
extern void esl_workqueue_Destroy(ESL_WORK_QUEUE *queue); |
| 53 |
|
| 54 |
extern ESL_WORK_QUEUE_QUEUELOCK *esl_workqueue_queuelock_Create(int size); |
| 55 |
extern void esl_workqueue_queuelock_Destroy(ESL_WORK_QUEUE_QUEUELOCK *queue); |
| 56 |
|
| 57 |
extern int esl_workqueue_Init (ESL_WORK_QUEUE *queue, void *ptr); |
| 58 |
extern int esl_workqueue_Complete(ESL_WORK_QUEUE *queue); |
| 59 |
extern int esl_workqueue_Reset (ESL_WORK_QUEUE *queue); |
| 60 |
|
| 61 |
extern int esl_workqueue_queuelock_Init (ESL_WORK_QUEUE_QUEUELOCK *queue, void *ptr); |
| 62 |
extern int esl_workqueue_queuelock_Complete(ESL_WORK_QUEUE_QUEUELOCK *queue); |
| 63 |
extern int esl_workqueue_queuelock_Reset (ESL_WORK_QUEUE_QUEUELOCK *queue); |
| 64 |
|
| 65 |
extern int esl_workqueue_Remove(ESL_WORK_QUEUE *queue, void **obj); |
| 66 |
extern int esl_workqueue_queuelock_Remove(ESL_WORK_QUEUE_QUEUELOCK *queue, void **obj); |
| 67 |
|
| 68 |
extern int esl_workqueue_ReaderUpdate(ESL_WORK_QUEUE *queue, void *in, void **out); |
| 69 |
extern int esl_workqueue_WorkerUpdate(ESL_WORK_QUEUE *queue, void *in, void **out); |
| 70 |
extern int esl_workqueue_queuelock_ReaderUpdate(ESL_WORK_QUEUE_QUEUELOCK *queue, void *in, void **out); |
| 71 |
extern int esl_workqueue_queuelock_WorkerUpdate(ESL_WORK_QUEUE_QUEUELOCK *queue, void *in, void **out); |
| 72 |
|
| 73 |
extern int esl_workqueue_Dump(ESL_WORK_QUEUE *queue); |
| 74 |
extern int esl_workqueue_queuelock_Dump(ESL_WORK_QUEUE_QUEUELOCK *queue); |
| 75 |
#endif |
| 76 |
|