aboutsummaryrefslogtreecommitdiff
path: root/philo_one/philo_one.h
diff options
context:
space:
mode:
Diffstat (limited to 'philo_one/philo_one.h')
-rw-r--r--philo_one/philo_one.h88
1 files changed, 35 insertions, 53 deletions
diff --git a/philo_one/philo_one.h b/philo_one/philo_one.h
index d7c1aef..498cd49 100644
--- a/philo_one/philo_one.h
+++ b/philo_one/philo_one.h
@@ -6,12 +6,12 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/24 06:11:16 by cacharle #+# #+# */
-/* Updated: 2020/02/14 21:37:45 by cacharle ### ########.fr */
+/* Updated: 2020/02/15 01:25:40 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
-#ifndef PHILO_ONE
-# define PHILO_ONE
+#ifndef PHILO_ONE_H
+# define PHILO_ONE_H
# include <unistd.h>
# include <sys/time.h>
@@ -19,78 +19,60 @@
# include <pthread.h>
# include "common.h"
-typedef struct
-{
- t_bool used;
- pthread_mutex_t mutex;
-} t_fork;
-
-// typedef struct
-// {
-// t_philo *philos;
-// t_fork *forks;
-// } t_table;
-
-typedef struct s_philo t_philo;
+typedef pthread_mutex_t t_fork;
-typedef struct
+typedef struct s_philo
{
- t_philo *watched;
- pthread_t thread;
-} t_watchdog;
-
-struct s_philo
-{
- int id;
- t_bool alive;
- t_watchdog watchdog;
- t_time time_last_eat;
- t_philo_state state;
- pthread_t thread;
-};
-
-typedef struct
+ int id;
+ t_bool alive;
+ t_time time_last_eat;
+ t_philo_state state;
+ pthread_t thread;
+} t_philo;
+
+typedef struct s_routine_arg
{
- t_philo_args *args;
- t_philo *philo;
- t_fork *fork_left;
- t_fork *fork_right;
- pthread_mutex_t *mutex_stdout;
-} t_routine_arg;
+ t_philo_args *args;
+ t_philo *philo;
+ t_fork *fork_left;
+ t_fork *fork_right;
+ pthread_mutex_t *mutex_stdout;
+} t_routine_arg;
/*
** fork.c
*/
-t_fork *forks_new(int num);
-void forks_destroy(t_fork *forks, int num);
-t_routine_arg *forks_dispatch(t_philo *philos, t_fork *forks, t_philo_args *args);
-void fork_switch(t_fork *fork);
+t_fork *forks_new(int num);
+void forks_destroy(t_fork *forks, int num);
+t_routine_arg *forks_dispatch(t_philo *philos,
+ t_fork *forks, t_philo_args *args);
/*
** philo.c
*/
-t_philo *philos_new(int num);
-void philos_destroy(t_philo *philos, int num);
-t_bool philos_start(t_philo *philos, t_routine_arg *routine_args, int num);
-void philos_join(t_philo *philos, int num);
-t_bool philos_starved(t_philo *philos, int num);
+t_philo *philos_new(int num);
+void philos_destroy(t_philo *philos, int num);
+t_bool philos_start(t_philo *philos,
+ t_routine_arg *routine_args, int num);
+void philos_join(t_philo *philos, int num);
+t_bool philos_starved(t_philo *philos, int num);
/*
** routine.c
*/
-void *routine_philo(void *void_arg);
-void *routine_death(void *void_arg);
+void *routine_philo(void *void_arg);
+void *routine_death(void *void_arg);
/*
** io.c
*/
-void io_eat(t_routine_arg *arg);
-void io_think(t_routine_arg *arg);
-void io_sleep(t_routine_arg *arg);
-void io_die(t_routine_arg *arg);
+void io_eat(t_routine_arg *arg);
+void io_think(t_routine_arg *arg);
+void io_sleep(t_routine_arg *arg);
+void io_die(t_routine_arg *arg);
#endif