mirror of
https://gitlab.com/klmp200/LO41.git
synced 2024-11-21 16:23:22 +00:00
Petit commit du dodo
This commit is contained in:
parent
048017a1ba
commit
bc92d6decf
@ -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
|
||||
);
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user