diff options
Diffstat (limited to 'philo_one/src/event.c')
| -rw-r--r-- | philo_one/src/event.c | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/philo_one/src/event.c b/philo_one/src/event.c index 5261f4c..ef3d7a5 100644 --- a/philo_one/src/event.c +++ b/philo_one/src/event.c @@ -6,7 +6,7 @@ /* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/14 21:37:50 by cacharle #+# #+# */ -/* Updated: 2020/10/05 14:27:39 by cacharle ### ########.fr */ +/* Updated: 2020/12/30 13:39:56 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -24,19 +24,12 @@ void event_take_fork(t_philo *arg, pthread_mutex_t *fork) void event_eat(t_philo *arg) { - int eat_counter; - - eat_counter = 0; - while (eat_counter < arg->conf->meal_num) - { - pthread_mutex_lock(&arg->conf->mutex_stdout); - if (!arg->conf->all_alive) - return ; - philo_put(arg->id, EVENT_EAT); - pthread_mutex_unlock(&arg->conf->mutex_stdout); - usleep(arg->conf->timeout_eat * 1000); - eat_counter++; - } + pthread_mutex_lock(&arg->conf->mutex_stdout); + if (!arg->conf->all_alive) + return ; + philo_put(arg->id, EVENT_EAT); + pthread_mutex_unlock(&arg->conf->mutex_stdout); + usleep(arg->conf->timeout_eat * 1000); } void event_think(t_philo *arg) |
