mirror of
https://github.com/Hizenberg469/MultiThreading_Part_A.git
synced 2026-04-20 02:22:23 +03:00
35 lines
547 B
C
35 lines
547 B
C
#ifndef __QUEUE__
|
|
#define __QUEUE__
|
|
|
|
#include <stdbool.h>
|
|
#include <pthread.h>
|
|
|
|
#define Q_DEFAULT_SIZE 5
|
|
struct Queue_t {
|
|
void* elem[Q_DEFAULT_SIZE];
|
|
unsigned int front;
|
|
unsigned int rear;
|
|
unsigned int count;
|
|
pthread_mutex_t q_mutex;
|
|
pthread_cond_t q_cv;
|
|
};
|
|
|
|
struct Queue_t* initQ(void);
|
|
|
|
bool
|
|
is_queue_empty(struct Queue_t* q);
|
|
|
|
bool
|
|
is_queue_full(struct Queue_t* q);
|
|
|
|
bool
|
|
enqueue(struct Queue_t* q, void* ptr);
|
|
|
|
void*
|
|
deque(struct Queue_t* q);
|
|
|
|
void
|
|
print_Queue(struct Queue_t* q);
|
|
|
|
#define Q_COUNT(q) (q->count)
|
|
#endif |