23#define SH_TIME_MAX_TICK_COUNT 1024
115 uint64_t* p_return_value
134#define shOnTick(time, seconds_d, tick_idx, expression)\
135 if ((time).ticks_status[tick_idx] == SH_TICK_UNDEFINED) {\
136 (time).ticks_status[tick_idx] = SH_TICK_INITIALIZED;\
140 ((time).now - (time).ticks_last_time[tick_idx]) >= (double)(seconds_d)\
142 (tick_idx < SH_TIME_MAX_TICK_COUNT) &&\
144 (time).ticks_status[tick_idx] != SH_TICK_UNDEFINED &&\
145 (time).ticks_status[tick_idx] != SH_TICK_EXECUTING\
148 (time).ticks_status[tick_idx] = SH_TICK_EXECUTING;\
150 (time).ticks_last_time[tick_idx] = (time).now;\
151 (time).ticks_status[tick_idx] = SH_TICK_FINISHED_EXECUTING;\
154 (time).ticks_status[tick_idx] = SH_TICK_WAITING;\
uint8_t shCallOnTick(ShTime *p_time, double seconds, uint32_t tick_idx, ShTimeFunc *p_func, void *p_arg, uint64_t *p_return_value)
Calls a function on a tick in the shengine framework.
Definition shTime.c:46
uint8_t shGetTime(ShTime *p_time)
Gets the current time in the shengine framework.
Definition shTime.c:19
ShTickStatus
Enumerates possible tick statuses.
Definition shTime.h:45
@ SH_TICK_UNDEFINED
Definition shTime.h:46
@ SH_TICK_WAITING
Definition shTime.h:48
@ SH_TICK_FINISHED_EXECUTING
Definition shTime.h:50
@ SH_TICK_INITIALIZED
Definition shTime.h:47
@ SH_TICK_EXECUTING
Definition shTime.h:49
@ SH_TICK_STATUS_MAX_ENUM
Definition shTime.h:51
uint64_t ShTimeFunc(void *)
Function type for time-related callbacks.
Definition shTime.h:34
#define SH_TIME_MAX_TICK_COUNT
Maximum number of ticks in the time structure.
Definition shTime.h:23
void shSleep(uint32_t ms)
Sleeps for a specified number of milliseconds.
Definition shTime.c:93
uint8_t shSetTime(double now, ShTime *p_time)
Sets the time in the shengine framework.
Definition shTime.c:31
Structure representing time in the shengine framework.
Definition shTime.h:63
ShTickStatus ticks_status[SH_TIME_MAX_TICK_COUNT]
Definition shTime.h:70
double delta_time
Definition shTime.h:65
double ticks_last_time[SH_TIME_MAX_TICK_COUNT]
Definition shTime.h:69
ShTimeFunc * p_ticks_funcs[SH_TIME_MAX_TICK_COUNT]
Definition shTime.h:71
double now
Definition shTime.h:64
uint32_t tick_count
Definition shTime.h:68
double last_time
Definition shTime.h:66