diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2021-01-03 16:58:00 +0100 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2021-01-03 16:58:00 +0100 |
| commit | 7e971b3fa805c40d02ac3e996ab1d181f9584866 (patch) | |
| tree | f904b6f96e0080b86aadd4d9047f7dfb855c3a3d /common/helper.c | |
| parent | e874ad94a31a8259b8eb7ad2865767c081bcd279 (diff) | |
| download | philosophers-7e971b3fa805c40d02ac3e996ab1d181f9584866.tar.gz philosophers-7e971b3fa805c40d02ac3e996ab1d181f9584866.tar.bz2 philosophers-7e971b3fa805c40d02ac3e996ab1d181f9584866.zip | |
Added h_sleep instead of usleep for better precision
Diffstat (limited to 'common/helper.c')
| -rw-r--r-- | common/helper.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/common/helper.c b/common/helper.c index e1cc1e2..a9d0652 100644 --- a/common/helper.c +++ b/common/helper.c @@ -6,7 +6,7 @@ /* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/08 23:22:49 by cacharle #+# #+# */ -/* Updated: 2021/01/02 12:07:49 by cacharle ### ########.fr */ +/* Updated: 2021/01/03 16:55:42 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -48,3 +48,12 @@ t_time h_time_now(void) gettimeofday(&tv, NULL); return (tv.tv_sec * 1000 + tv.tv_usec / 1000); } + +void h_sleep(t_time sleep_time) +{ + t_time start; + + start = h_time_now(); + while (h_time_now() - start < sleep_time) + usleep(500); +} |
