0c102f803ab6125397aaccd40cb2fdb3a2f8a610 kent Thu Sep 4 23:53:22 2014 -0700 Adding synQueuePutUnprotected, a minor optimization. diff --git src/lib/synQueue.c src/lib/synQueue.c index a6e322c..34dd626 100644 --- src/lib/synQueue.c +++ src/lib/synQueue.c @@ -45,30 +45,37 @@ } void synQueueFreeAndVals(struct synQueue **pSq) /* Free up synQueue. Be sure no other threads are using * it first though! This will freeMem all the messages */ { struct synQueue *sq = *pSq; if (sq == NULL) return; dlListFreeAndVals(&sq->queue); pthreadCondDestroy(&sq->cond); pthreadMutexDestroy(&sq->mutex); freez(pSq); } +void synQueuePutUnprotected(struct synQueue *sq, void *message) +/* Add message to end of queue without protecting against multithreading + * contention - used before pthreads are launched perhaps. */ +{ +dlAddValTail(sq->queue, message); +} + void synQueuePut(struct synQueue *sq, void *message) /* Add message to end of queue. */ { pthreadMutexLock(&sq->mutex); dlAddValTail(sq->queue, message); pthreadCondSignal(&sq->cond); pthreadMutexUnlock(&sq->mutex); } void *synQueueGet(struct synQueue *sq) /* Get message off start of queue. Wait until there is * a message if queue is empty. */ { void *message; struct dlNode *node;