22#include <proto/exec.h>
23#include <proto/timer.h>
24#include <proto/utility.h>
47struct TimerIFace *ITimer;
66 if(CheckIO((
struct IORequest *)nscb)==NULL)
67 AbortIO((
struct IORequest *)nscb);
69 WaitIO((
struct IORequest *)nscb);
84 ULONG time_us = t * 1000;
89 GetSysTime(&nscb->
tv);
90 AddTime(&nscb->
tv, &tv);
95 SendIO((
struct IORequest *)nscb);
113 PblIterator *iterator;
115 bool found_cb =
false;
123 while ((nscb = pblIteratorNext(iterator)) != (
void *)-1) {
125 if (remove ==
true) pblIteratorRemove(iterator);
131 pblIteratorFree(iterator);
133 if (found_cb ==
true)
return nscb;
187 PblIterator *iterator;
194 while ((nscb = pblIteratorNext(iterator)) != (
void *)-1) {
196 pblIteratorRemove(iterator);
204 pblIteratorFree(iterator);
213 return CmpTime(&nscb1->
tv, &nscb2->
tv);
219 PblIterator *iterator;
221 struct ClockData clockdata;
227 Amiga2Date(tv.
Seconds, &clockdata);
229 NSLOG(netsurf, INFO,
"Current time = %d-%d-%d %d:%d:%d.%lu",
230 clockdata.mday, clockdata.month, clockdata.year,
231 clockdata.hour, clockdata.min, clockdata.sec, tv.
Microseconds);
232 NSLOG(netsurf, INFO,
"Events remaining in queue:");
236 while ((nscb = pblIteratorNext(iterator)) != (
void *)-1) {
237 Amiga2Date(nscb->
tv.
Seconds, &clockdata);
239 "nscb: %p, at %d-%d-%d %d:%d:%d.%lu, callback: %p, %p",
240 nscb, clockdata.mday, clockdata.month, clockdata.year,
241 clockdata.hour, clockdata.min, clockdata.sec,
243 if(CheckIO((
struct IORequest *)nscb) == NULL) {
244 NSLOG(netsurf, INFO,
"-> ACTIVE");
246 NSLOG(netsurf, INFO,
"-> COMPLETE");
250 pblIteratorFree(iterator);
260 void (*callback)(
void *p);
277 ASOIOR_ReplyPort, msgport,
284 OpenDevice(
"timer.device", UNIT_VBLANK, (
struct IORequest *)
tioreq, 0);
288 ITimer = (
struct TimerIFace *)GetInterface((
struct Library *)
TimerBase,
"main", 1, NULL);
295 if(ITimer) DropInterface((
struct Interface *)ITimer);
297 CloseDevice((
struct IORequest *)
tioreq);
351 nscb = AllocVec(
sizeof(
struct nscallback), MEMF_PUBLIC | MEMF_CLEAR);
376 while((timermsg = (
struct nscallback *)GetMsg(nsmsgport))) {
static nserror ami_schedule_reschedule(struct nscallback *nscb, int t)
Reschedule a callback.
void ami_schedule_free(void)
Finalise amiga scheduler.
static void ami_schedule_dump(void)
static struct nscallback * tioreq
static void ami_schedule_open_timer(struct MsgPort *msgport)
static nserror schedule_remove(void(*callback)(void *p), void *p, bool abort)
Unschedule a callback.
static void schedule_remove_all(void)
static int ami_schedule_compare(const void *prev, const void *next)
static bool ami_scheduler_run(struct nscallback *nscb)
Process signalled event.
static void ami_schedule_remove_timer_event(struct nscallback *nscb)
Remove timer event.
nserror ami_schedule(int t, void(*callback)(void *p), void *p)
Schedule a callback.
struct Device * TimerBase
static nserror ami_schedule_add_timer_event(struct nscallback *nscb, int t)
Add timer event.
static PblHeap * schedule_list
void ami_schedule_handle(struct MsgPort *nsmsgport)
Handle a message received from the scheduler process.
static struct MsgPort * schedule_msgport
static void ami_schedule_close_timer(void)
static struct nscallback * ami_schedule_locate(void(*callback)(void *p), void *p, bool remove)
Locate a scheduled callback.
nserror ami_schedule_create(struct MsgPort *msgport)
Initialise amiga scheduler.
nserror
Enumeration of error codes.
@ NSERROR_INIT_FAILED
Initialisation failed.
@ NSERROR_NOMEM
Memory exhaustion.
#define NSLOG(catname, level, logmsg, args...)
void FreeSysObject(ULONG type, APTR obj)
Minimal compatibility header for AmigaOS 3.
#define AllocSysObjectTags(A, B, C, D)
struct TimeRequest timereq