Skip to content

Commit

Permalink
Avoid exposing twin_now
Browse files Browse the repository at this point in the history
twin_now() should be used as an internal function for tracking timeout
events.
  • Loading branch information
jserv committed Jul 21, 2024
1 parent 545945c commit 83fb1ee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
4 changes: 0 additions & 4 deletions include/twin.h
Original file line number Diff line number Diff line change
Expand Up @@ -1005,16 +1005,12 @@ void twin_path_curve(twin_path_t *path,
* timeout.c
*/

#define twin_time_compare(a, op, b) (((a) - (b)) op 0)

twin_timeout_t *twin_set_timeout(twin_timeout_proc_t timeout_proc,
twin_time_t delay,
void *closure);

void twin_clear_timeout(twin_timeout_t *timeout);

twin_time_t twin_now(void);

/*
* toplevel.c
*/
Expand Down
21 changes: 11 additions & 10 deletions src/timeout.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,20 @@
*/

#include <stdlib.h>
#include <sys/time.h>
#include <time.h>

#include "twin_private.h"

#define twin_time_compare(a, op, b) (((a) - (b)) op 0)

static twin_time_t twin_now(void)
{
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_sec * 1000 + tv.tv_usec / 1000;
}

static twin_queue_t *head;
static twin_time_t start;

Expand Down Expand Up @@ -82,13 +93,3 @@ twin_time_t _twin_timeout_delay(void)
}
return -1;
}

#include <sys/time.h>
#include <time.h>

twin_time_t twin_now(void)
{
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_sec * 1000 + tv.tv_usec / 1000;
}

0 comments on commit 83fb1ee

Please sign in to comment.