Skip to content

Commit c70f82c

Browse files
committed
use rs_wall_clock in cursor.c
1 parent a4c2886 commit c70f82c

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

src/cursor.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,14 @@
1111
#include <time.h>
1212
#include "rmutil/rm_assert.h"
1313
#include <err.h>
14+
#include "rs_wall_clock.h"
1415

1516
#define Cursor_IsIdle(cur) ((cur)->pos != -1)
1617

1718
// coord cursors will have odd ids and regular cursors will have even ids
1819
CursorList g_CursorsList;
1920
CursorList g_CursorsListCoord;
2021

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-
2722
static void CursorList_Lock(CursorList *cl) {
2823
pthread_mutex_lock(&cl->lock);
2924
}
@@ -140,7 +135,7 @@ static void cursorGcCb(CursorList *cl, Cursor *cur, void *arg) {
140135
*
141136
*/
142137
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();
144139
if ((cl->nextIdleTimeoutNs && cl->nextIdleTimeoutNs > now) ||
145140
(!force && now - cl->lastCollect < RSCURSORS_SWEEP_THROTTLE)) {
146141
return -1;
@@ -253,7 +248,7 @@ int Cursor_Pause(Cursor *cur) {
253248
// Cursor is not marked for deletion, we need to pause it.
254249

255250
// 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);
257252
if (cur->nextTimeoutNs < cl->nextIdleTimeoutNs || cl->nextIdleTimeoutNs == 0) {
258253
cl->nextIdleTimeoutNs = cur->nextTimeoutNs;
259254
}

0 commit comments

Comments
 (0)