NetSurf
Data Structures | Functions | Variables
schedule.c File Reference
#include <time.h>
#include <stdlib.h>
#include "utils/sys_time.h"
#include "utils/log.h"
#include "monkey/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 nserror schedule_remove (void(*callback)(void *p), void *p)
 Unschedule a callback. More...
 
nserror monkey_schedule (int tival, void(*callback)(void *p), void *p)
 Schedule a callback. More...
 
int monkey_schedule_run (void)
 Process scheduled callbacks up to current time. More...
 
void monkey_schedule_list (void)
 Log a list of all scheduled callbacks. More...
 

Variables

static struct nscallbackschedule_list = NULL
 

Function Documentation

◆ monkey_schedule()

nserror monkey_schedule ( int  tival,
void(*)(void *p)  callback,
void *  p 
)

Schedule a callback.

Parameters
tivalinterval 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 100 of file schedule.c.

References nscallback::callback, nscallback::next, NSERROR_OK, NSLOG, nscallback::p, schedule_list, schedule_remove(), timeradd, and nscallback::tv.

Here is the call graph for this function:

◆ monkey_schedule_list()

void monkey_schedule_list ( void  )

Log a list of all scheduled callbacks.

Definition at line 200 of file schedule.c.

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

◆ monkey_schedule_run()

int monkey_schedule_run ( void  )

Process scheduled callbacks up to current time.

Returns
The number of milliseconds untill the next scheduled event or -1 for no event.

Definition at line 133 of file schedule.c.

References nscallback::callback, nscallback::next, NSLOG, nscallback::p, schedule_list, timercmp, timersub, and nscallback::tv.

Referenced by monkey_run().

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
Returns
NSERROR_OK if callback found and removed else NSERROR_NOT_FOUND

All scheduled callbacks matching both callback and p are removed.

Definition at line 50 of file schedule.c.

References nscallback::callback, nscallback::next, NSERROR_NOT_FOUND, NSERROR_OK, NSLOG, nscallback::p, and schedule_list.

Referenced by monkey_schedule().

Here is the caller graph for this function:

Variable Documentation

◆ schedule_list

struct nscallback* schedule_list = NULL
static