Files
cell/source/timer.h
John Alanbrook c87f85cf6c
Some checks failed
Build and Deploy / build-macos (push) Failing after 29s
Build and Deploy / build-windows (CLANG64) (push) Has been cancelled
Build and Deploy / package-dist (push) Has been cancelled
Build and Deploy / deploy-itch (push) Has been cancelled
Build and Deploy / deploy-gitea (push) Has been cancelled
Build and Deploy / build-linux (push) Has been cancelled
Update files for cross compilation fixes; add dockerfiles for windows/linux/emscripten builds; add commands to makefile to build via dockerfiles
2025-07-12 20:39:25 -05:00

38 lines
965 B
C

#ifndef TIMER_H
#define TIMER_H
#include <stdint.h>
#include <SDL3/SDL.h>
typedef Uint32 (*TimerCallback)(Uint32 timer_id, Uint32 interval, void *param);
typedef struct {
Uint32 id;
uint64_t due_ns;
uint64_t interval_ns;
TimerCallback callback;
void *param;
} cell_timer_t;
/* Initialize timer system - must be called once */
void timer_init(void);
/* Shutdown timer system - must be called before exit */
void timer_quit(void);
/* Schedule a new timer to fire after delay_ns nanoseconds */
Uint32 add_timer_ns(uint64_t delay_ns, TimerCallback callback, void *param);
/* Cancel a pending timer by its ID */
void remove_timer(Uint32 id);
/* Process due timers - call once per main loop iteration */
void process_due_timers(void);
/* Get time until next timer expires (in nanoseconds) */
uint64_t next_timeout_ns(void);
/* Get current monotonic time in nanoseconds */
uint64_t get_time_ns(void);
#endif /* TIMER_H */