diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-02-10 00:34:47 +0100 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-02-10 01:30:53 +0100 |
| commit | 1a7c6c5a0ed9a5aae1fe45c3af335c120c2dc642 (patch) | |
| tree | 965aa21be5411d2a9e1156013efc1980bca29f90 /common/common.h | |
| parent | dfbafce6506fe5c47b0e60289a9d4629e502c9ac (diff) | |
| download | philosophers-1a7c6c5a0ed9a5aae1fe45c3af335c120c2dc642.tar.gz philosophers-1a7c6c5a0ed9a5aae1fe45c3af335c120c2dc642.tar.bz2 philosophers-1a7c6c5a0ed9a5aae1fe45c3af335c120c2dc642.zip | |
WIP: philo one
Diffstat (limited to 'common/common.h')
| -rw-r--r-- | common/common.h | 31 |
1 files changed, 8 insertions, 23 deletions
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 <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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 <unistd.h> # include <stdlib.h> +# include <pthread.h> # include <sys/time.h> # define FALSE 0 @@ -40,13 +42,6 @@ typedef enum typedef struct { - int id; - t_philo_state state; - pthread_t thread; -} t_philo; - -typedef struct -{ int philo_num; int timeout_death; int timeout_eat; @@ -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 |
