#include "philo.h"

void	launch_threads(t_philo *philo, pthread_t *id)
{
	int	i;

	i = 0;
	while (i < philo->params->n_phi)
	{
		pthread_create(&id[i], NULL, &philo_exec, philo);
		philo = philo->next;
		i++;
	}
}

int	is_dead(t_philo *philo)
{
	(void)philo;
	return (0);
}

void	watch_threads(t_philo *philo, pthread_t *id)
{
	int			i;

	i = 0;
	while (1)
	{
		if (is_dead(philo) == 1)
			break ;
	}
	while (i < philo->params->n_phi)
	{
		pthread_join(id[i], NULL);
		i++;
	}
}

int	main(int ac, char **av)
{
	pthread_t	*id;
	t_philo		*philo;

	philo = init(ac, av, &id);
	if (philo == NULL)
    	return (0);
	launch_threads(philo, id);
	watch_threads(philo, id);
write(1, "main function\n", 14);
    return (0);
}
