![]() |
SolarCapture C Bindings User Guide
SF-115721-CD
Issue 3
|
Functions for managing time. More...
Functions | |
void | sc_timer_expire_at (struct sc_callback *cb, const struct timespec *time) |
Request a callback at a given time. More... | |
void | sc_timer_expire_after_ns (struct sc_callback *cb, int64_t delta_ns) |
Request a callback in the future. More... | |
void | sc_timer_push_back_ns (struct sc_callback *cb, int64_t delta_ns) |
Push the expiry time further into the future. More... | |
int | sc_timer_get_expiry_time (const struct sc_callback *cb, struct timespec *ts_out) |
Return the expiry time of a timer callback. More... | |
static uint64_t | sc_ns_from_ts (const struct timespec *ts) |
Convert a timespec struct to nanoseconds. More... | |
static uint64_t | sc_ns_from_tv (const struct timeval *tv) |
Convert a timeval struct to nanoseconds. More... | |
static uint64_t | sc_ns_from_ms (uint64_t ms) |
Convert milliseconds to nanoseconds. More... | |
static uint64_t | sc_ns_from_us (uint64_t us) |
Convert microseconds to nanoseconds. More... | |
Functions for managing time.
|
inlinestatic |
Convert milliseconds to nanoseconds.
ms | The time in milliseconds to convert |
|
inlinestatic |
Convert a timespec struct to nanoseconds.
ts | The timespec struct to convert |
|
inlinestatic |
Convert a timeval struct to nanoseconds.
tv | The timeval struct to convert |
|
inlinestatic |
Convert microseconds to nanoseconds.
us | The time in microseconds to convert |
void sc_timer_expire_after_ns | ( | struct sc_callback * | cb, |
int64_t | delta_ns | ||
) |
Request a callback in the future.
cb | A callback object |
delta_ns | How far in the future in nanoseconds. |
The callback will be invoked at or after the specified time delta in nanoseconds. If delta_ns
is zero or negative then the handler function will be invoked as soon as possible.
void sc_timer_expire_at | ( | struct sc_callback * | cb, |
const struct timespec * | time | ||
) |
Request a callback at a given time.
cb | A callback object |
time | Time at which callback is requested |
The callback cb
will be invoked at or after the specified time. If the time is in the past, then the handler function will be invoked as soon as possible.
The time is relative to the system realtime clock (CLOCK_REALTIME), which is the same clock returned by sc_thread_get_time().
int sc_timer_get_expiry_time | ( | const struct sc_callback * | cb, |
struct timespec * | ts_out | ||
) |
Return the expiry time of a timer callback.
cb | A callback object |
ts_out | The expiry time is returned here |
cb
is a timer else -1 void sc_timer_push_back_ns | ( | struct sc_callback * | cb, |
int64_t | delta_ns | ||
) |
Push the expiry time further into the future.
cb | A callback object |
delta_ns | How far in the future in nanoseconds. |
This function pushes the expiry time of a timer callback further into the future.
The callback cb
must either be a currently active timer registered with sc_timer_expire_at() or sc_timer_expire_after_ns(), or it must be an inactive timer. ie. The most recent use of cb
must have been as a timer callback.
If cb
is active, then it is rescheduled at its current expiry time plus delta_ns
. If it is not active then it is scheduled at its previous expiry time plus delta_ns
.