X-Git-Url: https://git.harvie.cz/?a=blobdiff_plain;f=c%2Fpthread_extra%2Fpthread_msgqueue.c;h=b8562965eef620cce7a21c634bab85129071c4c9;hb=77c7dc7ffcaa64879e90178df5585f22790f46be;hp=168dc7f676fb7eb57b3a684ca11de7aadbcb878a;hpb=5251b63c80878b87d8cb808efd3978bd819c4f8b;p=mirrors%2FPrograms.git diff --git a/c/pthread_extra/pthread_msgqueue.c b/c/pthread_extra/pthread_msgqueue.c index 168dc7f..b856296 100644 --- a/c/pthread_extra/pthread_msgqueue.c +++ b/c/pthread_extra/pthread_msgqueue.c @@ -39,6 +39,10 @@ size_t pthread_mq_waiting(pthread_mq_t *mq) { return mq->msg_count; } +size_t pthread_mq_vacant(pthread_mq_t *mq) { + return (mq->msg_count_max - mq->msg_count); +} + bool pthread_mq_reset(pthread_mq_t *mq) { if(pthread_mutex_lock(&mq->lock)) return false; mq->msg_count = 0; @@ -62,7 +66,7 @@ bool pthread_mq_send_generic(pthread_mq_t *mq, void * data, bool to_front, const ret = pthread_cond_wait(&mq->cond_writable, &mq->lock); } else { //printf("STimed: %p\n", abs_timeout); - assert(abs_timeout != NULL); + //assert(abs_timeout != NULL); ret = pthread_cond_timedwait(&mq->cond_writable, &mq->lock, abs_timeout); } if(ret) { @@ -96,7 +100,7 @@ bool pthread_mq_receive_generic(pthread_mq_t *mq, void * data, bool peek, const ret = pthread_cond_wait(&mq->cond_readable, &mq->lock); } else { //printf("RTimed: %p\n", abs_timeout); - assert(abs_timeout != NULL); + //assert(abs_timeout != NULL); ret = pthread_cond_timedwait(&mq->cond_readable, &mq->lock, abs_timeout); } if(ret) {