|
11 | 11 | #include <time.h> |
12 | 12 | #include "rmutil/rm_assert.h" |
13 | 13 | #include <err.h> |
| 14 | +#include "rs_wall_clock.h" |
14 | 15 |
|
15 | 16 | #define Cursor_IsIdle(cur) ((cur)->pos != -1) |
16 | 17 |
|
17 | 18 | // coord cursors will have odd ids and regular cursors will have even ids |
18 | 19 | CursorList g_CursorsList; |
19 | 20 | CursorList g_CursorsListCoord; |
20 | 21 |
|
21 | | -static uint64_t curTimeNs() { |
22 | | - struct timespec tv; |
23 | | - clock_gettime(CLOCK_MONOTONIC, &tv); |
24 | | - return tv.tv_nsec + (tv.tv_sec * 1000000000); |
25 | | -} |
26 | | - |
27 | 22 | static void CursorList_Lock(CursorList *cl) { |
28 | 23 | pthread_mutex_lock(&cl->lock); |
29 | 24 | } |
@@ -140,7 +135,7 @@ static void cursorGcCb(CursorList *cl, Cursor *cur, void *arg) { |
140 | 135 | * |
141 | 136 | */ |
142 | 137 | static int Cursors_GCInternal(CursorList *cl, int force) { |
143 | | - uint64_t now = curTimeNs(); |
| 138 | + rs_wall_clock_ns_t now = rs_wall_clock_now_ns(); |
144 | 139 | if ((cl->nextIdleTimeoutNs && cl->nextIdleTimeoutNs > now) || |
145 | 140 | (!force && now - cl->lastCollect < RSCURSORS_SWEEP_THROTTLE)) { |
146 | 141 | return -1; |
@@ -253,7 +248,7 @@ int Cursor_Pause(Cursor *cur) { |
253 | 248 | // Cursor is not marked for deletion, we need to pause it. |
254 | 249 |
|
255 | 250 | // Set the next timeout to be the current time + timeout interval |
256 | | - cur->nextTimeoutNs = curTimeNs() + ((uint64_t)cur->timeoutIntervalMs * 1000000); |
| 251 | + cur->nextTimeoutNs = rs_wall_clock_now_ns() + ((uint64_t)cur->timeoutIntervalMs * 1000000); |
257 | 252 | if (cur->nextTimeoutNs < cl->nextIdleTimeoutNs || cl->nextIdleTimeoutNs == 0) { |
258 | 253 | cl->nextIdleTimeoutNs = cur->nextTimeoutNs; |
259 | 254 | } |
|
0 commit comments