2018-06-06 11:50:11 +00:00
|
|
|
//
|
|
|
|
// Created by Antoine Bartuccio on 06/06/2018.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef LO41_SHAREDDATA_H
|
|
|
|
#define LO41_SHAREDDATA_H
|
|
|
|
|
2018-06-07 20:04:30 +00:00
|
|
|
#include <pthread.h>
|
2018-06-06 11:50:11 +00:00
|
|
|
#include "../Objects.h"
|
2018-06-07 20:04:30 +00:00
|
|
|
#include "../Building/Building.h"
|
|
|
|
|
|
|
|
#define MUTEX_NB 3
|
|
|
|
|
|
|
|
enum {mutex_1, mutex_2, mutex_3};
|
2018-06-06 11:50:11 +00:00
|
|
|
|
|
|
|
typedef struct o_SharedData {
|
2018-06-07 20:04:30 +00:00
|
|
|
PRIVATE int threads_nb;
|
|
|
|
PRIVATE pthread_t *threads;
|
|
|
|
PRIVATE pthread_mutex_t mutex_array[MUTEX_NB];
|
|
|
|
PRIVATE Building * main_building;
|
|
|
|
|
|
|
|
PUBLIC void (*set_main_building)(_THIS(SharedData), Building * building);
|
|
|
|
PUBLIC void (*wait_threads)(_THIS(SharedData));
|
|
|
|
PUBLIC int (*call_elevator)(_THIS(SharedData), int starting_floor, int destination_floor);
|
2018-06-06 11:50:11 +00:00
|
|
|
|
|
|
|
DESTRUCTOR(SharedData);
|
|
|
|
} SharedData;
|
|
|
|
|
|
|
|
SharedData *_get_instance_SharedData();
|
|
|
|
|
|
|
|
#endif //LO41_SHAREDDATA_H
|