reactor-c
C Runtime for Lingua Franca
Loading...
Searching...
No Matches
clock.h File Reference

A higher level API to the clock utilities provided by the platform API. More...

Go to the source code of this file.

Functions

int lf_clock_interruptable_sleep_until_locked (environment_t *env, instant_t wakeup_time)
 
int lf_clock_gettime (instant_t *now)
 
int lf_clock_cond_timedwait (lf_cond_t *cond, instant_t wakeup_time)
 

Detailed Description

A higher level API to the clock utilities provided by the platform API.

Author
Erling Rennemo Jellum

This builds on top of the clocking API of the different platforms and ensures:

  1. Monotonicity
  2. That clock synchronization offsets are applied and removed when necessary.

Function Documentation

◆ lf_clock_cond_timedwait()

int lf_clock_cond_timedwait ( lf_cond_t * cond,
instant_t wakeup_time )

Block the calling thread on the condition variable until it is signaled or until wakeup_time is reached. Before calling the appropriate function in the platform API, the wakeup_time will be translated into the correct timescale by removing any clock synchronization offset.

Returns
0 on success, LF_TIMEOUT on timeout, platform-specific error otherwise.

◆ lf_clock_gettime()

int lf_clock_gettime ( instant_t * now)

Retrieve the current physical time from the platform API. This adds any clock synchronization offset and guarantees monotonicity. Specifically, each returned value will be at least one nanosecond larger than any previously returned time.

Parameters
nowA pointer to the location in which to store the result.
Returns
0 on success, -1 on failure to read the platform clock.

◆ lf_clock_interruptable_sleep_until_locked()

int lf_clock_interruptable_sleep_until_locked ( environment_t * env,
instant_t wakeup_time )

Block the calling thread until wakeup_time is reached or the thread is interrupted by an asynchronous scheduling. This is used by the single-threaded runtime. Before calling the appropriate function in the platform API, the wakeup_time will be translated into the correct timescale by removing any clock synchronization offset.

Returns
0 on success or -1 if interrupted.