diff options
author | Simon Ser <contact@emersion.fr> | 2022-11-23 16:01:54 +0100 |
---|---|---|
committer | Simon Zeni <simon@bl4ckb0ne.ca> | 2022-11-25 16:15:29 +0000 |
commit | 21254737bf97e5be44071063c14fce5a403a9a22 (patch) | |
tree | 84c077b5123c35fd5228935fc5728c827b56b5cf /backend/backend.c | |
parent | 769cabbadf295fbe26cd2c3eb6efd5233c4d14e8 (diff) |
backend: use time helpers to implement timeouts
Instead of hand-rolling get_current_time_msec(), let's just re-use
the helper we already have in "util/time.h".
Diffstat (limited to 'backend/backend.c')
-rw-r--r-- | backend/backend.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/backend/backend.c b/backend/backend.c index 899e6f37..de25f347 100644 --- a/backend/backend.c +++ b/backend/backend.c @@ -18,6 +18,7 @@ #include "backend/multi.h" #include "render/allocator/allocator.h" #include "util/env.h" +#include "util/time.h" #if WLR_HAS_DRM_BACKEND #include <wlr/backend/drm.h> @@ -66,12 +67,6 @@ void wlr_backend_destroy(struct wlr_backend *backend) { } } -static uint64_t get_current_time_ms(void) { - struct timespec ts = {0}; - clock_gettime(CLOCK_MONOTONIC, &ts); - return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; -} - static struct wlr_session *session_create_and_wait(struct wl_display *disp) { struct wlr_session *session = wlr_session_create(disp); @@ -83,8 +78,8 @@ static struct wlr_session *session_create_and_wait(struct wl_display *disp) { if (!session->active) { wlr_log(WLR_INFO, "Waiting for a session to become active"); - uint64_t started_at = get_current_time_ms(); - uint64_t timeout = WAIT_SESSION_TIMEOUT; + int64_t started_at = get_current_time_msec(); + int64_t timeout = WAIT_SESSION_TIMEOUT; struct wl_event_loop *event_loop = wl_display_get_event_loop(session->display); @@ -96,7 +91,7 @@ static struct wlr_session *session_create_and_wait(struct wl_display *disp) { return NULL; } - uint64_t now = get_current_time_ms(); + int64_t now = get_current_time_msec(); if (now >= started_at + WAIT_SESSION_TIMEOUT) { break; } |