NetSurf
Data Structures | Functions | Variables
schedule.c File Reference
#include "amiga/os3support.h"
#include <proto/dos.h>
#include <proto/exec.h>
#include <proto/timer.h>
#include <proto/utility.h>
#include <stdio.h>
#include <stdbool.h>
#include <pbl.h>
#include "utils/errors.h"
#include "utils/log.h"
#include "amiga/memory.h"
#include "amiga/schedule.h"
Include dependency graph for schedule.c:

Go to the source code of this file.

Data Structures

struct  nscallback
 scheduled callback. More...
 

Functions

static void ami_schedule_remove_timer_event (struct nscallback *nscb)
 Remove timer event. More...
 
static nserror ami_schedule_add_timer_event (struct nscallback *nscb, int t)
 Add timer event. More...
 
static struct nscallbackami_schedule_locate (void(*callback)(void *p), void *p, bool remove)
 Locate a scheduled callback. More...
 
static nserror ami_schedule_reschedule (struct nscallback *nscb, int t)
 Reschedule a callback. More...
 
static nserror schedule_remove (void(*callback)(void *p), void *p, bool abort)
 Unschedule a callback. More...
 
static void schedule_remove_all (void)
 
static int ami_schedule_compare (const void *prev, const void *next)
 
static void ami_schedule_dump (void)
 
static bool ami_scheduler_run (struct nscallback *nscb)
 Process signalled event. More...
 
static void ami_schedule_open_timer (struct MsgPort *msgport)
 
static void ami_schedule_close_timer (void)
 
nserror ami_schedule_create (struct MsgPort *msgport)
 Initialise amiga scheduler. More...
 
void ami_schedule_free (void)
 Finalise amiga scheduler. More...
 
nserror ami_schedule (int t, void(*callback)(void *p), void *p)
 Schedule a callback. More...
 
void ami_schedule_handle (struct MsgPort *nsmsgport)
 Handle a message received from the scheduler process. More...
 

Variables

static struct nscallbacktioreq
 
struct Device * TimerBase
 
static struct MsgPort * schedule_msgport = NULL
 
static PblHeap * schedule_list
 

Function Documentation

◆ ami_schedule()

nserror ami_schedule ( int  t,
void(*)(void *p)  callback,
void *  p 
)

Schedule a callback.

Parameters
tinterval before the callback should be made / ms
callbackcallback function
puser parameter, passed to callback function
Returns
NSERROR_OK on sucess or appropriate error on faliure

The callback function will be called as soon as possible after t ms have passed.

Definition at line 331 of file schedule.c.

References AllocSysObjectTags, ami_schedule_add_timer_event(), ami_schedule_locate(), ami_schedule_reschedule(), ASOT_IOREQUEST, nscallback::callback, NSERROR_INIT_FAILED, NSERROR_NOMEM, NSERROR_OK, nscallback::p, schedule_list, schedule_msgport, schedule_remove(), and tioreq.

Referenced by ami_corewindow_fini(), ami_cw_redraw(), ami_font_cache_cleanup(), ami_font_cache_fini(), ami_font_cache_init(), ami_gui_event(), ami_memory_handler(), ami_pageinfo_event(), ami_pageinfo_mouse(), ami_schedule_redraw(), ami_schedule_redraw_remove(), ami_throbber_redraw_schedule(), amiga_bitmap_destroy(), amiga_bitmap_get_buffer(), amiga_bitmap_modified(), gui_window_create(), gui_window_destroy(), and HOOKF().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_schedule_add_timer_event()

static nserror ami_schedule_add_timer_event ( struct nscallback nscb,
int  t 
)
static

Add timer event.

Parameters
nscbcallback
ttime in ms

NetSurf will be signalled in t ms for this event.

Definition at line 81 of file schedule.c.

References TimeVal::Microseconds, NSERROR_OK, TimeRequest::Request, TimeVal::Seconds, TimeRequest::Time, nscallback::timereq, and nscallback::tv.

Referenced by ami_schedule(), and ami_schedule_reschedule().

Here is the caller graph for this function:

◆ ami_schedule_close_timer()

static void ami_schedule_close_timer ( void  )
static

Definition at line 292 of file schedule.c.

References ASOT_IOREQUEST, FreeSysObject(), and tioreq.

Referenced by ami_schedule_free().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_schedule_compare()

static int ami_schedule_compare ( const void *  prev,
const void *  next 
)
static
Todo:
a heap probably isn't the best idea now

Definition at line 207 of file schedule.c.

References nscallback::next, and nscallback::tv.

Referenced by ami_schedule_create().

Here is the caller graph for this function:

◆ ami_schedule_create()

nserror ami_schedule_create ( struct MsgPort *  msgport)

Initialise amiga scheduler.

Parameters
msgportopened message port
Returns
error.

Definition at line 302 of file schedule.c.

References ami_schedule_compare(), ami_schedule_open_timer(), NSERROR_NOMEM, NSERROR_OK, schedule_list, and schedule_msgport.

Referenced by ami_gui_resources_open().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_schedule_dump()

static void ami_schedule_dump ( void  )
static

Definition at line 217 of file schedule.c.

References nscallback::callback, TimeVal::Microseconds, NSLOG, nscallback::p, schedule_list, TimeVal::Seconds, and nscallback::tv.

Referenced by ami_schedule_free().

Here is the caller graph for this function:

◆ ami_schedule_free()

void ami_schedule_free ( void  )

Finalise amiga scheduler.

Definition at line 320 of file schedule.c.

References ami_schedule_close_timer(), ami_schedule_dump(), schedule_list, and schedule_remove_all().

Referenced by ami_gui_resources_free().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_schedule_handle()

void ami_schedule_handle ( struct MsgPort *  nsmsgport)

Handle a message received from the scheduler process.

Parameters
nsmsgportMessage port to process.

Definition at line 369 of file schedule.c.

References ami_scheduler_run().

Referenced by ami_get_msg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_schedule_locate()

static struct nscallback * ami_schedule_locate ( void(*)(void *p)  callback,
void *  p,
bool  remove 
)
static

Locate a scheduled callback.

Parameters
callbackcallback function
puser parameter, passed to callback function
removeremove callback from the heap

A scheduled callback matching both callback and p is returned, or NULL if none present.

Definition at line 111 of file schedule.c.

References nscallback::callback, nscallback::p, and schedule_list.

Referenced by ami_schedule(), and schedule_remove().

Here is the caller graph for this function:

◆ ami_schedule_open_timer()

static void ami_schedule_open_timer ( struct MsgPort *  msgport)
static

Definition at line 272 of file schedule.c.

References AllocSysObjectTags, ASO_NoTrack, ASOT_IOREQUEST, TimeRequest::Request, TimerBase, nscallback::timereq, and tioreq.

Referenced by ami_schedule_create().

Here is the caller graph for this function:

◆ ami_schedule_remove_timer_event()

static void ami_schedule_remove_timer_event ( struct nscallback nscb)
static

Remove timer event.

Parameters
nscbcallback

The timer event for the callback is aborted

Definition at line 62 of file schedule.c.

Referenced by ami_schedule_reschedule(), schedule_remove(), and schedule_remove_all().

Here is the caller graph for this function:

◆ ami_schedule_reschedule()

static nserror ami_schedule_reschedule ( struct nscallback nscb,
int  t 
)
static

Reschedule a callback.

Parameters
nscbcallback
ttime in ms

The nscallback will be rescheduled for t ms.

Definition at line 146 of file schedule.c.

References ami_schedule_add_timer_event(), ami_schedule_remove_timer_event(), NSERROR_NOMEM, NSERROR_OK, and schedule_list.

Referenced by ami_schedule().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_scheduler_run()

static bool ami_scheduler_run ( struct nscallback nscb)
static

Process signalled event.

This implementation only processes the callback that arrives in the message from timer.device.

Definition at line 258 of file schedule.c.

References nscallback::callback, nscallback::p, and schedule_remove().

Referenced by ami_schedule_handle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ schedule_remove()

static nserror schedule_remove ( void(*)(void *p)  callback,
void *  p,
bool  abort 
)
static

Unschedule a callback.

Parameters
callbackcallback function
puser parameter, passed to callback function
abortabort pending timer

All scheduled callbacks matching both callback and p are removed.

Definition at line 166 of file schedule.c.

References ami_schedule_locate(), ami_schedule_remove_timer_event(), ASOT_IOREQUEST, nscallback::callback, FreeSysObject(), NSERROR_OK, nscallback::p, and schedule_list.

Referenced by ami_schedule(), and ami_scheduler_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ schedule_remove_all()

static void schedule_remove_all ( void  )
static

Definition at line 185 of file schedule.c.

References ami_schedule_remove_timer_event(), ASOT_IOREQUEST, FreeSysObject(), and schedule_list.

Referenced by ami_schedule_free().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ schedule_list

PblHeap* schedule_list
static

◆ schedule_msgport

struct MsgPort* schedule_msgport = NULL
static

Definition at line 49 of file schedule.c.

Referenced by ami_schedule(), and ami_schedule_create().

◆ TimerBase

struct Device* TimerBase

Definition at line 45 of file schedule.c.

Referenced by ami_schedule_open_timer().

◆ tioreq

struct nscallback* tioreq
static

Definition at line 44 of file schedule.c.

Referenced by ami_schedule(), ami_schedule_close_timer(), and ami_schedule_open_timer().