From 42360f381cebd6376c261b16038a7f12971f925e Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Wed, 30 Sep 2020 08:18:29 +0200 Subject: Added 'has taken fork' log, Refactoring philo_one to work with new common lib --- philo_one/src/philo.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'philo_one/src/philo.c') diff --git a/philo_one/src/philo.c b/philo_one/src/philo.c index e0ecfec..3e21490 100644 --- a/philo_one/src/philo.c +++ b/philo_one/src/philo.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/09 23:47:14 by cacharle #+# #+# */ -/* Updated: 2020/09/29 13:29:49 by cacharle ### ########.fr */ +/* Updated: 2020/09/30 08:10:55 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -23,10 +23,7 @@ t_philo *philos_new(int num) return (NULL); i = -1; while (++i < num) - { philos[i].id = i + 1; - philos[i].alive = false; - } return (philos); } @@ -37,7 +34,6 @@ bool philos_start(t_philo *philos, t_routine_arg *routine_args, int num) i = -1; while (++i < num) { - philos[i].alive = true; if (pthread_create(&philos[i].thread, NULL, (void *(*)(void*))routine_philo, (void*)(routine_args + i)) == -1) return (false); @@ -45,17 +41,13 @@ bool philos_start(t_philo *philos, t_routine_arg *routine_args, int num) return (true); } -void philos_join(t_philo *philos, int num) +void philos_detach(t_philo *philos, int num) { int i; i = -1; while (++i < num) { - if (philos[i].alive) - { - philos[i].alive = false; - pthread_detach(philos[i].thread); - } + pthread_detach(philos[i].thread); } } -- cgit