From 1a7c6c5a0ed9a5aae1fe45c3af335c120c2dc642 Mon Sep 17 00:00:00 2001 From: Charles Date: Mon, 10 Feb 2020 00:34:47 +0100 Subject: WIP: philo one --- common/common.h | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) (limited to 'common/common.h') diff --git a/common/common.h b/common/common.h index ff371a9..def49cf 100644 --- a/common/common.h +++ b/common/common.h @@ -6,14 +6,16 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/08 22:58:35 by cacharle #+# #+# */ -/* Updated: 2020/02/09 03:22:56 by cacharle ### ########.fr */ +/* Updated: 2020/02/09 23:56:48 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef COMMON_H # define COMMON_H +# include # include +# include # include # define FALSE 0 @@ -38,13 +40,6 @@ typedef enum EVENT_DIED } t_philo_event; -typedef struct -{ - int id; - t_philo_state state; - pthread_t thread; -} t_philo; - typedef struct { int philo_num; @@ -56,30 +51,21 @@ typedef struct typedef void (*t_philo_routine)(void *arg); -typedef struct -{ - t_bool used; - t_philo *left; - t_philo *right; -} t_fork; - /* ** common.c */ t_bool parse_args(t_philo_args *philo_args, int argc, char **argv); -void philo_put_state_change(t_philo *philo, t_philo_event event); +void philo_put_state_change(int id, t_philo_event event); /* ** philo.c */ -t_philo *philos_new(int num); -void philos_destroy(t_philo *philo); - -void philo_eat(t_philo *philo); -void philo_sleep(t_philo *philo); -void philo_think(t_philo *philo); +void philo_eat(int id, int timeout); +void philo_sleep(int id, int timeout); +void philo_think(int id); +void philo_die(int id); /* ** helper.c @@ -92,5 +78,4 @@ void h_putchar(char c); void h_putstr(char *s); void *h_calloc(int count, int size); - #endif -- cgit