inc/synQueue.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

synQueuesynQueueNew ()
void synQueueFree (struct synQueue **pSq)
void synQueueFreeAndVals (struct synQueue **pSq)
void synQueuePut (struct synQueue *sq, void *message)
void * synQueueGet (struct synQueue *sq)
void * synQueueGrab (struct synQueue *sq)
int synQueueSize (struct synQueue *sq)


Function Documentation

void synQueueFree ( struct synQueue **  pSq  ) 

Definition at line 31 of file synQueue.c.

References synQueue::cond, dlListFree, freez(), synQueue::mutex, pthreadCondDestroy(), pthreadMutexDestroy(), and synQueue::queue.

00035 {
00036 struct synQueue *sq = *pSq;
00037 if (sq == NULL)
00038     return;
00039 dlListFree(&sq->queue);
00040 pthreadCondDestroy(&sq->cond);
00041 pthreadMutexDestroy(&sq->mutex);
00042 freez(pSq);
00043 }

Here is the call graph for this function:

void synQueueFreeAndVals ( struct synQueue **  pSq  ) 

Definition at line 45 of file synQueue.c.

References synQueue::cond, dlListFreeAndVals, freez(), synQueue::mutex, pthreadCondDestroy(), pthreadMutexDestroy(), and synQueue::queue.

00048 {
00049 struct synQueue *sq = *pSq;
00050 if (sq == NULL)
00051     return;
00052 dlListFreeAndVals(&sq->queue);
00053 pthreadCondDestroy(&sq->cond);
00054 pthreadMutexDestroy(&sq->mutex);
00055 freez(pSq);
00056 }

Here is the call graph for this function:

void* synQueueGet ( struct synQueue sq  ) 

Definition at line 67 of file synQueue.c.

References synQueue::cond, dlEmpty(), dlPopHead(), freeMem(), synQueue::mutex, pthreadCondWait(), pthreadMutexLock(), pthreadMutexUnlock(), synQueue::queue, and dlNode::val.

00070 {
00071 void *message;
00072 struct dlNode *node;
00073 pthreadMutexLock(&sq->mutex);
00074 while (dlEmpty(sq->queue))
00075     pthreadCondWait(&sq->cond, &sq->mutex);
00076 node = dlPopHead(sq->queue);
00077 pthreadMutexUnlock(&sq->mutex);
00078 message = node->val;
00079 freeMem(node);
00080 return message;
00081 }

Here is the call graph for this function:

void* synQueueGrab ( struct synQueue sq  ) 

Definition at line 83 of file synQueue.c.

References dlPopHead(), freeMem(), synQueue::mutex, pthreadMutexLock(), pthreadMutexUnlock(), synQueue::queue, and dlNode::val.

00086 {
00087 void *message = NULL;
00088 struct dlNode *node;
00089 pthreadMutexLock(&sq->mutex);
00090 node = dlPopHead(sq->queue);
00091 pthreadMutexUnlock(&sq->mutex);
00092 if (node != NULL)
00093     {
00094     message = node->val;
00095     freeMem(node);
00096     }
00097 return message;
00098 }

Here is the call graph for this function:

struct synQueue* synQueueNew (  )  [read]

Definition at line 20 of file synQueue.c.

References AllocVar, synQueue::cond, dlListNew, synQueue::mutex, pthreadCondInit(), pthreadMutexInit(), and synQueue::queue.

00022 {
00023 struct synQueue *sq;
00024 AllocVar(sq);
00025 pthreadMutexInit(&sq->mutex);
00026 pthreadCondInit(&sq->cond);
00027 sq->queue = dlListNew();
00028 return sq;
00029 }

Here is the call graph for this function:

void synQueuePut ( struct synQueue sq,
void *  message 
)

Definition at line 58 of file synQueue.c.

References synQueue::cond, dlAddValTail(), synQueue::mutex, pthreadCondSignal(), pthreadMutexLock(), pthreadMutexUnlock(), and synQueue::queue.

00060 {
00061 pthreadMutexLock(&sq->mutex);
00062 dlAddValTail(sq->queue, message);
00063 pthreadCondSignal(&sq->cond);
00064 pthreadMutexUnlock(&sq->mutex);
00065 }

Here is the call graph for this function:

int synQueueSize ( struct synQueue sq  ) 

Definition at line 100 of file synQueue.c.

References dlCount(), synQueue::mutex, pthreadMutexLock(), pthreadMutexUnlock(), and synQueue::queue.

00102 {
00103 int size;
00104 pthreadMutexLock(&sq->mutex);
00105 size = dlCount(sq->queue);
00106 pthreadMutexUnlock(&sq->mutex);
00107 return size;
00108 }

Here is the call graph for this function:


Generated on Tue Dec 25 19:17:04 2007 for blat by  doxygen 1.5.2