30#define MS_NOW() ((clock() * 1000) / CLOCKS_PER_SEC)
74 while (cur_nscb != NULL) {
78 NSLOG(schedule, DEBUG,
79 "callback entry %p removing %p(%p)", cur_nscb,
83 unlnk_nscb = cur_nscb;
84 cur_nscb = unlnk_nscb->
next;
86 if (prev_nscb == NULL) {
89 prev_nscb->
next = cur_nscb;
96 cur_nscb = prev_nscb->
next;
118 NSLOG(schedule, DEBUG,
"adding callback %p for %p(%p) at %d ms", nscb,
139 unsigned long nexttime;
143 unsigned long now =
MS_NOW();
153 while (cur_nscb != NULL) {
158 unlnk_nscb = cur_nscb;
159 if (prev_nscb == NULL) {
165 NSLOG(schedule, DEBUG,
166 "callback entry %p running %p(%p)", unlnk_nscb,
176 NSLOG(schedule, DEBUG,
"schedule_list == NULL");
189 if (nexttime > cur_nscb->
timeout) {
193 prev_nscb = cur_nscb;
194 cur_nscb = prev_nscb->
next;
199 nexttime = nexttime - now;
201 NSLOG(schedule, DEBUG,
"returning time to next event as %ldms",
214 NSLOG(schedule, DEBUG,
"schedule list at ms clock %ld",
MS_NOW());
217 while (cur_nscb != NULL) {
218 NSLOG(schedule, DEBUG,
"Schedule %p at %ld", cur_nscb,
220 cur_nscb = cur_nscb->
next;
static struct nscallback * schedule_list
void list_schedule(void)
LOG all current scheduled events.
int schedule_run(void)
Process events up to current time.
nserror atari_schedule(int ival, void(*callback)(void *p), void *p)
Schedule a callback.
static nserror schedule_remove(void(*callback)(void *p), void *p)
Unschedule a callback.
nserror
Enumeration of error codes.
#define NSLOG(catname, level, logmsg, args...)
Interface to utility string handling.
BSD style timeval macros.
Interface to time operations.