TwiceAsNice
2019-02-18
|
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) |
CBF |
Signature of a callback function.
TCF |
Signature of a timer function.
WPF |
Signature of a work procedure function.
int addCallback | ( | int | fd, |
CBF * | fp, | ||
void * | ud | ||
) |
Register a new callback, fp, to be called with ud as argument when fd is ready.
fd | file descriptor. |
fp | a pointer to the callback function. |
ud | a pointer to be passed to the callback function when called. |
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.
ms | timer period in milliseconds. |
fp | a pointer to the callback function. |
ud | a pointer to be passed to the callback function when called. |
int addWorkProc | ( | WPF * | fp, |
void * | ud | ||
) |
Add a new work procedure, fp, to be called with ud when nothing else to do.
fp | a pointer to the work procedure callback function. |
ud | a pointer to be passed to the callback function when called. |
int deferLoop | ( | int | maxms, |
int * | flagp | ||
) |
int deferLoop0 | ( | int | maxms, |
int * | flagp | ||
) |
void eventLoop | ( | ) |
Main calls this when ready to hand over control.
void rmCallback | ( | int | cid | ) |
Remove a callback function.
cid | the callback ID returned from addCallback(). |
void rmTimer | ( | int | tid | ) |
Remove the timer with the given id, as returned from addTimer().
tid | the timer callback ID returned from addTimer(). |
void rmWorkProc | ( | int | wid | ) |
Remove the work procedure with the given id, as returned from addWorkProc().
wid | the work procedure callback ID returned from addWorkProc(). |