mirror of
https://gitlab.com/klmp200/LO41.git
synced 2025-07-11 04:09:24 +00:00
Début de synchronisation stylée
This commit is contained in:
@ -7,6 +7,8 @@
|
||||
|
||||
SYNCHRONIZED_GETTER(Elevator, ELEVATOR_STATE, state)
|
||||
SYNCHRONIZED_SETTER(Elevator, ELEVATOR_STATE, state)
|
||||
SYNCHRONIZED_GETTER(Elevator, ELEVATOR_STATE, floor)
|
||||
SYNCHRONIZED_SETTER(Elevator, ELEVATOR_STATE, floor)
|
||||
|
||||
void _free__Elevator(THIS(Elevator)){
|
||||
DELETE(this->passenger_ids);
|
||||
@ -19,6 +21,9 @@ void _free__Elevator(THIS(Elevator)){
|
||||
pthread_mutex_unlock(&this->mutex_state);
|
||||
pthread_mutex_destroy(&this->mutex_state);
|
||||
|
||||
pthread_mutex_unlock(&this->mutex_floor);
|
||||
pthread_mutex_destroy(&this->mutex_floor);
|
||||
|
||||
free(this);
|
||||
}
|
||||
|
||||
@ -52,6 +57,7 @@ Elevator *_init_Elevator(char * name){
|
||||
new_elevator->passenger_ids = NEW(List);
|
||||
pthread_mutex_init(&new_elevator->mutex_passenger, NULL);
|
||||
pthread_mutex_init(&new_elevator->mutex_state, NULL);
|
||||
pthread_mutex_init(&new_elevator->mutex_floor, NULL);
|
||||
|
||||
LINK_ALL(Elevator, new_elevator,
|
||||
runnable,
|
||||
@ -59,6 +65,8 @@ Elevator *_init_Elevator(char * name){
|
||||
can_get_more_passengers,
|
||||
get_state,
|
||||
set_state,
|
||||
get_floor,
|
||||
set_floor,
|
||||
repair
|
||||
);
|
||||
|
||||
|
@ -17,16 +17,20 @@ typedef struct o_Elevator {
|
||||
PRIVATE ELEVATOR_STATE state;
|
||||
PRIVATE List * passenger_ids;
|
||||
PRIVATE char * name;
|
||||
PRIVATE int floor;
|
||||
PRIVATE pthread_mutex_t mutex_passenger;
|
||||
PRIVATE pthread_mutex_t mutex_state;
|
||||
PRIVATE pthread_mutex_t mutex_floor;
|
||||
|
||||
PUBLIC void * (*runnable)(void * void_this);
|
||||
|
||||
SYNCHRONIZE PRIVATE void (*set_state)(_THIS(Elevator), ELEVATOR_STATE var);
|
||||
SYNCHRONIZE PRIVATE int (*set_floor)(_THIS(Elevator));
|
||||
|
||||
SYNCHRONIZE PUBLIC void (*repair)(_THIS(Elevator));
|
||||
SYNCHRONIZE PUBLIC int (*get_number_of_passengers)(_THIS(Elevator));
|
||||
SYNCHRONIZE PUBLIC ELEVATOR_STATE (*get_state)(_THIS(Elevator));
|
||||
SYNCHRONIZE PUBLIC int (*get_floor)(_THIS(Elevator));
|
||||
SYNCHRONIZE PUBLIC int (*can_get_more_passengers)(_THIS(Elevator));
|
||||
DESTRUCTOR(Elevator);
|
||||
|
||||
|
Reference in New Issue
Block a user