NetSurf
Data Structures | Functions | Variables
schedule.c File Reference

Scheduled callback queue (implementation). More...

#include <stdbool.h>
#include <stdlib.h>
#include "oslib/os.h"
#include "utils/log.h"
#include "riscos/gui.h"
Include dependency graph for schedule.c:

Go to the source code of this file.

Data Structures

struct  sched_entry
 Entry in the queue of scheduled callbacks. More...
 

Functions

static nserror schedule_remove (void(*callback)(void *p), void *p)
 Unschedule a callback. More...
 
nserror riscos_schedule (int t, void(*callback)(void *p), void *p)
 Schedule a callback. More...
 
bool schedule_run (void)
 Process events up to current time. More...
 

Variables

static struct sched_entry sched_queue = { 0, 0, 0, 0 }
 Queue of scheduled callbacks (sentinel at head). More...
 
bool sched_active = false
 Items have been scheduled. More...
 
os_t sched_time
 Time of soonest scheduled event (valid only if sched_active is true). More...
 

Detailed Description

Scheduled callback queue (implementation).

The queue is simply implemented as a linked list.

Definition in file schedule.c.

Function Documentation

◆ riscos_schedule()

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

Schedule a callback.

Parameters
tinterval before the callback should be made in ms
callbackcallback function
puser parameter, passed to callback function

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

Definition at line 93 of file schedule.c.

References sched_entry::callback, sched_entry::next, NSERROR_NOMEM, NSERROR_OK, NSLOG, sched_entry::p, sched_active, sched_queue, sched_time, schedule_remove(), and sched_entry::time.

Referenced by gui_download_window_done(), gui_download_window_error(), ro_gui_download_datasave_ack(), ro_gui_download_keypress(), ro_gui_download_overwrite_confirmed(), ro_gui_download_send_dataload(), ro_gui_download_update_status(), ro_gui_download_window_destroy(), ro_gui_hotlist_add_page(), ro_gui_hotlist_addurl_bounce(), ro_gui_progress_bar_animate(), ro_gui_progress_bar_destroy(), ro_gui_progress_bar_update(), ro_gui_status_bar_destroy(), and ro_gui_status_bar_set_text().

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 
)
static

Unschedule a callback.

Parameters
callbackcallback function
puser parameter, passed to callback function

All scheduled callbacks matching both callback and p are removed.

Definition at line 63 of file schedule.c.

References sched_entry::callback, sched_entry::next, NSERROR_OK, sched_entry::p, sched_active, sched_queue, sched_time, and sched_entry::time.

Referenced by riscos_schedule().

Here is the caller graph for this function:

◆ schedule_run()

bool schedule_run ( void  )

Process events up to current time.

Process scheduled callbacks up to current time.

Returns
The number of miliseconds until the next scheduled event.

Definition at line 134 of file schedule.c.

References sched_entry::callback, sched_entry::next, sched_entry::p, sched_active, sched_queue, sched_time, and sched_entry::time.

Variable Documentation

◆ sched_active

bool sched_active = false

Items have been scheduled.

Definition at line 50 of file schedule.c.

Referenced by riscos_poll(), riscos_schedule(), schedule_remove(), and schedule_run().

◆ sched_queue

struct sched_entry sched_queue = { 0, 0, 0, 0 }
static

Queue of scheduled callbacks (sentinel at head).

Definition at line 47 of file schedule.c.

Referenced by riscos_schedule(), schedule_remove(), and schedule_run().

◆ sched_time

os_t sched_time

Time of soonest scheduled event (valid only if sched_active is true).

Definition at line 52 of file schedule.c.

Referenced by riscos_poll(), riscos_schedule(), schedule_remove(), and schedule_run().