TwiceAsNice  2019-02-18
Typedefs | Functions
eventloop.h File Reference

Typedefs

typedef void() CBF(int fd, void *)
 Signature of a callback function. More...
 
typedef void() WPF(void *)
 Signature of a work procedure function. More...
 
typedef void() TCF(void *)
 Signature of a timer function. More...
 

Functions

void eventLoop ()
 Main calls this when ready to hand over control. More...
 
int addCallback (int fd, CBF *fp, void *ud)
 Register a new callback, fp, to be called with ud as argument when fd is ready. More...
 
void rmCallback (int cid)
 Remove a callback function. More...
 
int addWorkProc (WPF *fp, void *ud)
 Add a new work procedure, fp, to be called with ud when nothing else to do. More...
 
void rmWorkProc (int wid)
 Remove the work procedure with the given id, as returned from addWorkProc(). More...
 
int addTimer (int ms, TCF *fp, void *ud)
 Register a new timer function, fp, to be called with ud as argument after ms. More...
 
void rmTimer (int tid)
 Remove the timer with the given id, as returned from addTimer(). More...
 
int deferLoop (int maxms, int *flagp)
 
int deferLoop0 (int maxms, int *flagp)
 

Typedef Documentation

◆ CBF

CBF

Signature of a callback function.

◆ TCF

TCF

Signature of a timer function.

◆ WPF

WPF

Signature of a work procedure function.

Function Documentation

◆ addCallback()

int addCallback ( int  fd,
CBF fp,
void *  ud 
)

Register a new callback, fp, to be called with ud as argument when fd is ready.

Parameters
fdfile descriptor.
fpa pointer to the callback function.
uda pointer to be passed to the callback function when called.
Returns
a unique callback id for use with rmCallback().

◆ addTimer()

int addTimer ( int  ms,
TCF fp,
void *  ud 
)

Register a new timer function, fp, to be called with ud as argument after ms.

Add to list in order of decreasing time from epoch, ie, last entry runs soonest. The timer will only invoke the callback function once. You need to call addTimer again if you want to repeat the process.

Parameters
mstimer period in milliseconds.
fpa pointer to the callback function.
uda pointer to be passed to the callback function when called.
Returns
a unique id for use with rmTimer().

◆ addWorkProc()

int addWorkProc ( WPF fp,
void *  ud 
)

Add a new work procedure, fp, to be called with ud when nothing else to do.

Parameters
fpa pointer to the work procedure callback function.
uda pointer to be passed to the callback function when called.
Returns
a unique id for use with rmWorkProc().

◆ deferLoop()

int deferLoop ( int  maxms,
int *  flagp 
)

◆ deferLoop0()

int deferLoop0 ( int  maxms,
int *  flagp 
)

◆ eventLoop()

void eventLoop ( )

Main calls this when ready to hand over control.

◆ rmCallback()

void rmCallback ( int  cid)

Remove a callback function.

Parameters
cidthe callback ID returned from addCallback().

◆ rmTimer()

void rmTimer ( int  tid)

Remove the timer with the given id, as returned from addTimer().

Parameters
tidthe timer callback ID returned from addTimer().

◆ rmWorkProc()

void rmWorkProc ( int  wid)

Remove the work procedure with the given id, as returned from addWorkProc().

Parameters
widthe work procedure callback ID returned from addWorkProc().