Vacant
authorTomas Mudrunka <tomas@mudrunka.cz>
Tue, 29 Jun 2021 12:22:10 +0000 (14:22 +0200)
committerTomas Mudrunka <tomas@mudrunka.cz>
Tue, 29 Jun 2021 12:22:10 +0000 (14:22 +0200)
c/pthread_extra/pthread_extra.h
c/pthread_extra/pthread_msgqueue.c

index 0652e0a568e146bc71844db1477f1c11f57b5a97..861b8474626ab37da3c969c5ee19d41aeafe27ca 100644 (file)
@@ -64,11 +64,14 @@ typedef struct pthread_mq_t {
 
 bool pthread_mq_init(pthread_mq_t *mq, size_t msg_size, size_t msg_count_max);
 void pthread_mq_free(pthread_mq_t *mq);
-size_t pthread_mq_waiting(pthread_mq_t *mq);
+
 bool pthread_mq_reset(pthread_mq_t *mq);
 bool pthread_mq_send_generic(pthread_mq_t *mq, void * data, bool to_front, const struct timespec *restrict abs_timeout);
 bool pthread_mq_receive_generic(pthread_mq_t *mq, void * data, bool peek, const struct timespec *restrict abs_timeout);
 
+size_t pthread_mq_waiting(pthread_mq_t *mq);
+size_t pthread_mq_vacant(pthread_mq_t *mq);
+
 // Multi mutex locking
 
 #define pthread_mutex_swap(a, b) { pthread_mutex_t *s; s = (a); a = (b); b = s; }
index ff1a37f865e65afdab274ebc76f061b2748d848e..b8562965eef620cce7a21c634bab85129071c4c9 100644 (file)
@@ -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;
This page took 0.166022 seconds and 4 git commands to generate.