AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
callout.h File Reference
#include <core/system.h>

Go to the source code of this file.

Data Structures

struct  callout
 A function to call later, with its argument. More...
struct  callout_list
 A list of callouts called from one context: the timer's interrupt (callout_set()), or a thread that runs its own list (the network's). More...

Functions

void callout_set (struct callout *c, uint64_t ns, void(*fn)(void *), void *arg)
 Sets a callout on the timer's list: fn(arg) will be called from the timer interrupt once ns ns have passed.
void callout_set_on (struct callout_list *list, struct callout *c, uint64_t ns, void(*fn)(void *), void *arg)
 Sets a callout on a list: fn(arg) will be called once ns ns have passed, by whoever runs the list.
void callout_stop (struct callout *c)
 Cancels a callout, if it is pending.
void callout_list_run (struct callout_list *list, uint64_t now)
 Calls the callouts of a list that are due, taking each off the list first.
uint64_t callout_list_next (struct callout_list *list)
 Finds when the first callout of a list is due.
void callout_run (uint64_t now)
 Calls the timer's callouts that are due, from the timer interrupt.

Function Documentation

◆ callout_list_next()

uint64_t callout_list_next ( struct callout_list * list)

Finds when the first callout of a list is due.

Parameters
listthe list
Returns
the time, in arch_rtime_ns() time, or 0 if the list is empty

Definition at line 115 of file callout.c.

References callout_list_next(), list::head, callout::next, and callout::when.

Referenced by callout_list_next(), and net_main().

◆ callout_list_run()

void callout_list_run ( struct callout_list * list,
uint64_t now )

Calls the callouts of a list that are due, taking each off the list first.

Parameters
listthe list
nowthe time, in arch_rtime_ns() time

Definition at line 86 of file callout.c.

References callout::arg, callout_list_run(), callout::fn, list::head, callout::list, callout::next, NULL, callout::pending, and callout::when.

Referenced by callout_list_run(), callout_run(), and net_main().

◆ callout_run()

void callout_run ( uint64_t now)

Calls the timer's callouts that are due, from the timer interrupt.

Parameters
nowthe time, in arch_rtime_ns() time

Definition at line 131 of file callout.c.

References callout_list_run(), callout_run(), and timer_callouts.

Referenced by callout_run(), and sched_timer_tick().

◆ callout_set()

void callout_set ( struct callout * c,
uint64_t ns,
void(* fn )(void *),
void * arg )

Sets a callout on the timer's list: fn(arg) will be called from the timer interrupt once ns ns have passed.

Parameters
cthe callout
nsthe delay, in ns
fnthe function to call
argits argument

Definition at line 74 of file callout.c.

References callout_set(), callout_set_on(), and timer_callouts.

Referenced by callout_set().

◆ callout_set_on()

void callout_set_on ( struct callout_list * list,
struct callout * c,
uint64_t ns,
void(* fn )(void *),
void * arg )

Sets a callout on a list: fn(arg) will be called once ns ns have passed, by whoever runs the list.

A callout that was pending is cancelled first.

Parameters
listthe list it goes on
cthe callout
nsthe delay, in ns
fnthe function to call
argits argument

Definition at line 50 of file callout.c.

References arch_rtime_ns(), callout::arg, callout_set_on(), callout_stop(), callout::fn, list::head, callout::list, callout::next, callout::pending, and callout::when.

Referenced by callout_set(), callout_set_on(), and net_callout_set().

◆ callout_stop()

void callout_stop ( struct callout * c)