(bind-func clock_scheduler
(lambda (hz:double)
(let ((evtlist:SchedEvt{double}* null)
(ft:[void,double]* null)
(scheduler:[i64,double]* null)
(running:i64 1)
(time 0.0)
(err 0)
(i (/ 1.0 hz))
(f (lambda ()
(spawn (lambda ()
(set! scheduler (scheduler_init evtlist ft))
(set! time (clock_clock))
(while (> running 0)
(scheduler time)
(while (< (clock_clock) time) (thread_sleep 0 100000))
(set! time (+ time i))
void)
(println "exiting scheduler")))
void)))
(f)
f)))