Skip to content

Commit

Permalink
define fdwatcher timeout units and sync implementation, fixes #5
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Eddy committed Aug 29, 2024
1 parent 7a2acda commit 2f77406
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/fdwatcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ fdwatcher_wait(FdWatcher *fdw, void **events, int nevents, int timeout)
struct timespec *tsp = NULL;

if (timeout != -1) {
ts.tv_sec = timeout;
ts.tv_nsec = 0;
// timeout is milleseconds, convert to timespec
ts.tv_sec = timeout / 1000;
ts.tv_nsec = timeout % 1000 * 1000 * 1000;
tsp = &ts;
}

Expand Down
4 changes: 2 additions & 2 deletions src/fdwatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ int fdwatcher_remove(FdWatcher *fdw, int fd);
/*
* Wait for events and return when one or more are seen. `events` and
* `nevents` are an array of pointers (type agnostic) and the number of
* pointers in the array to fill. `timeout` is an optional timeout to wait for
* events, set to -1 to wait indefinitely.
* pointers in the array to fill. `timeout` is an optional timeout (in
* milliseconds) to wait for events, set to -1 to wait indefinitely.
*
* This function will return the number of events that were seen. For each
* event that was seen, its user data pointer (set in `fdwatcher_add`) will be
Expand Down

0 comments on commit 2f77406

Please sign in to comment.