mirror of
https://gitlab.com/klmp200/LO41.git
synced 2024-11-26 02:54:18 +00:00
36 lines
887 B
C
36 lines
887 B
C
//
|
|
// Created by Antoine Bartuccio on 06/06/2018.
|
|
//
|
|
|
|
#ifndef LO41_SHAREDDATA_H
|
|
#define LO41_SHAREDDATA_H
|
|
|
|
#include <pthread.h>
|
|
#include "../Objects.h"
|
|
#include "../Building/Building.h"
|
|
|
|
#define MUTEX_NB 3
|
|
|
|
enum {mutex_1, mutex_2, mutex_3};
|
|
|
|
typedef struct o_SharedData {
|
|
PRIVATE int threads_nb;
|
|
PRIVATE pthread_t *threads;
|
|
PRIVATE pthread_mutex_t mutex_array[MUTEX_NB];
|
|
|
|
PRIVATE Building * main_building;
|
|
PRIVATE CommunicationBox * box;
|
|
|
|
PUBLIC void (*set_main_building)(_THIS(SharedData), Building * building);
|
|
PUBLIC Building * (*get_main_building)(_THIS(SharedData));
|
|
PUBLIC CommunicationBox * (*get_box)(_THIS(SharedData));
|
|
PUBLIC void (*wait_threads)(_THIS(SharedData));
|
|
PUBLIC int (*call_elevator)(_THIS(SharedData), int starting_floor, int destination_floor);
|
|
|
|
DESTRUCTOR(SharedData);
|
|
} SharedData;
|
|
|
|
SharedData *_get_instance_SharedData();
|
|
|
|
#endif //LO41_SHAREDDATA_H
|