Skip to content
Snippets Groups Projects
Commit 0952625b authored by rswindell's avatar rswindell
Browse files

All the ring buf functions now reset (clear) the semaphores when appropriate.

parent 99d5954a
Branches
Tags
No related merge requests found
......@@ -135,6 +135,13 @@ DWORD RINGBUFCALL RingBufFull( RingBuf* rb )
else
retval = rb->size - (tail - head);
#ifdef RINGBUF_SEM
if(retval==0) /* empty */
sem_reset(&rb->sem);
if(retval<rb->highwater_mark)
sem_reset(&rb->highwater_sem);
#endif
#ifdef RINGBUF_MUTEX
pthread_mutex_unlock(&rb->mutex);
#endif
......@@ -248,6 +255,10 @@ DWORD RINGBUFCALL RingBufRead( RingBuf* rb, BYTE* dst, DWORD cnt )
if(rb->pTail > rb->pEnd)
rb->pTail = rb->pStart;
#ifdef RINGBUF_SEM /* clear semaphores, if appropriate */
RingBufFull( rb );
#endif
#ifdef RINGBUF_MUTEX
pthread_mutex_unlock(&rb->mutex);
#endif
......@@ -302,6 +313,10 @@ void RINGBUFCALL RingBufReInit(RingBuf* rb)
pthread_mutex_lock(&rb->mutex);
#endif
rb->pHead = rb->pTail = rb->pStart;
#ifdef RINGBUF_SEM
sem_reset(&rb->sem);
sem_reset(&rb->highwater_sem);
#endif
#ifdef RINGBUF_MUTEX
pthread_mutex_unlock(&rb->mutex);
#endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment