aboutsummaryrefslogtreecommitdiff
path: root/philo_one/src/philo.c
diff options
context:
space:
mode:
Diffstat (limited to 'philo_one/src/philo.c')
-rw-r--r--philo_one/src/philo.c14
1 files changed, 3 insertions, 11 deletions
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 <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}
}