1
0
mirror of https://gitlab.com/klmp200/LO41.git synced 2024-11-21 16:23:22 +00:00

Et voilà, c'est propre comme ça :D

This commit is contained in:
Antoine Bartuccio 2018-06-18 15:56:22 +02:00
parent b001cb1a91
commit e820bd7a58
Signed by: klmp200
GPG Key ID: E7245548C53F904B
3 changed files with 5 additions and 5 deletions

View File

@ -144,7 +144,7 @@ int get_inside_elevator_Building(THIS(Building), int current_floor, ElevatorPass
if (this->elevators[i]->can_get_inside(this->elevators[i], current_floor)){
/* pour faire taire le compilateur le temps que je revienne sur cette fonction */
if (elevator_passenger.type == VISITOR)
this->elevators[i]->add_passenger(this->elevators[i], elevator_passenger.passenger.visitor->get_id(elevator_passenger.passenger.visitor));
this->elevators[i]->add_passenger(this->elevators[i], elevator_passenger);
/* Il faut faire des trucs ici */
pthread_mutex_unlock(this->mutex_func_get_inside_elevator);
return i;

View File

@ -28,11 +28,11 @@ void _free__Elevator(THIS(Elevator)){
free(this);
}
void add_passenger_Elevator(THIS(Elevator), int passenger_id){
void add_passenger_Elevator(THIS(Elevator), ElevatorPassenger passenger){
pthread_mutex_lock(&this->mutex_passenger);
this->passengers->insert_tail(this->passengers, ((void *)&passenger_id), sizeof(int));
this->passengers->insert_tail(this->passengers, ((void *)&passenger), sizeof(ElevatorPassenger));
printf("Le passager avec l'id %d est entre dans l'ascenseur %s\nIl y a maintenant %d passagers dans l'ascenseur %s\n",
passenger_id, this->name, this->passengers->get_size(this->passengers), this->name);
passenger.passenger.visitor->get_id(passenger.passenger.visitor), this->name, this->passengers->get_size(this->passengers), this->name);
if (this->passengers->get_size(this->passengers) >= MAX_ELEVATOR_CAPACITY)
this->set_state(this, SLEEPING);
pthread_mutex_unlock(&this->mutex_passenger);

View File

@ -31,7 +31,7 @@ typedef struct o_Elevator {
SYNCHRONIZE PUBLIC void (*repair)(_THIS(Elevator));
SYNCHRONIZE PUBLIC int (*get_number_of_passengers)(_THIS(Elevator));
SYNCHRONIZE PUBLIC void (*add_passenger)(_THIS(Elevator), int passenger_id);
SYNCHRONIZE PUBLIC void (*add_passenger)(_THIS(Elevator), ElevatorPassenger passenger);
SYNCHRONIZE PUBLIC ELEVATOR_STATE (*get_state)(_THIS(Elevator));
SYNCHRONIZE PUBLIC int (*get_floor)(_THIS(Elevator));
SYNCHRONIZE PUBLIC int (*can_get_inside)(_THIS(Elevator), int floor);