Skip to content
Snippets Groups Projects
Commit 53f9c94d authored by ricardo.dossanto1's avatar ricardo.dossanto1
Browse files

Delete queue_mgt.h

parent d3cc3597
Branches
Tags
No related merge requests found
#ifndef QUEUE_MGT_H
#define QUEUE_MGT_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <assert.h>
#include <semaphore.h>
#include <unistd.h>
#include <stdbool.h>
#include <stdint.h>
typedef struct {
int head;
int tail;
int count; // Nombre d'éléments actuellement dans la file
int size; // Taille en octets d'un élément de la file
int capacity; // Nombre maximal d'éléments pouvant être stockés dans la file
void *buffer; // Tampon de la file
pthread_mutex_t *mutex;
sem_t *used;
sem_t *libre;
bool closed;
bool endTask;
} queue_t;
/* Description: queue initialization
Parameters: queue: pointer on the queue handle (contains internal parameters)
element_byte_size_max: number of byte of a single element of the queue
nb_of_elements_max: maximum number of element the queue can contain
Return: error code or 0 on success
*/
int init_queue(queue_t *queue, int element_byte_size_max, int nb_of_elements_max);
/* Description: queue destruction. Unlock potential blocking functions in send() and
receive() are stopped. The all ressources are freed.
Parameters: queue: pointer on the queue handle
*/
void destroy_queue(queue_t *queue);
/* Description: send an element in a queue. This function blocks if the queue is full,
waiting that at least one element has been read.
Parameters: queue: pointer on the queue handle
element: pointer on the element to send
*/
void send(queue_t *queue, void *element);
/* Description: receive an element from a queue. This function blocks if the queue is empty,
waiting that at least one element has been written into it.
Parameters: queue: pointer on the queue handle
element: pointer on the element to receive
*/
void receive(queue_t *queue, void *element);
/*
* Description: close queue since destroying all queues in task f seems to be an unpredicatble behaviour
* it will also tell the end of the task the queue was in
* Parameters: the queue pointer
*/
void close_queue(queue_t* queue);
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment