1
0
mirror of https://gitlab.com/klmp200/LO41.git synced 2024-12-22 15:51:11 +00:00

Petit commit du dodo

This commit is contained in:
Antoine Bartuccio 2018-06-08 00:49:20 +02:00
parent 048017a1ba
commit bc92d6decf
Signed by: klmp200
GPG Key ID: E7245548C53F904B
2 changed files with 14 additions and 1 deletions

View File

@ -4,7 +4,13 @@
#include "SharedData.h"
SETTER(SharedData, Building *, main_building)
GETTER(SharedData, Building *, main_building)
GETTER(SharedData, CommunicationBox *, box)
void set_main_building_SharedData(THIS(SharedData), Building * building){
this->main_building = building;
this->box = (building != NULL ) ? building->box : NULL;
}
void wait_threads_SharedData(THIS(SharedData)){
int i;
@ -44,11 +50,14 @@ SharedData *_get_instance_SharedData(){
new_shared_data->threads = NULL;
new_shared_data->main_building = NULL; /* Should be set to NULL if freed */
new_shared_data->box = NULL; /* freed inside main_building */
new_shared_data->threads_nb = 0;
LINK_ALL(SharedData, new_shared_data,
wait_threads,
set_main_building,
get_main_building,
get_box,
call_elevator
);
}

View File

@ -17,9 +17,13 @@ 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);