Instrument Neutral Distributed Interface INDI  1.9.2
Typedefs | Functions
eventloop.h File Reference

Public interface to INDI's eventloop mechanism. More...

Go to the source code of this file.

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)
 
void rmCallback (int cid)
 
int addWorkProc (WPF *fp, void *ud)
 
void rmWorkProc (int wid)
 
int addTimer (int ms, TCF *fp, void *ud)
 
int addPeriodicTimer (int ms, TCF *fp, void *ud)
 
int remainingTimer (int tid)
 
int nsecRemainingTimer (int tid)
 
void rmTimer (int tid)
 
int deferLoop (int maxms, int *flagp)
 
int deferLoop0 (int maxms, int *flagp)
 

Detailed Description

Public interface to INDI's eventloop mechanism.

Author
Elwood C. Downey

Definition in file eventloop.h.

Typedef Documentation

◆ CBF

CBF

Signature of a callback function.

Definition at line 37 of file eventloop.h.

◆ TCF

TCF

Signature of a timer function.

Definition at line 47 of file eventloop.h.

◆ WPF

WPF

Signature of a work procedure function.

Definition at line 42 of file eventloop.h.

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().

Definition at line 161 of file eventloop.c.

◆ addPeriodicTimer()

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

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

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().

Definition at line 253 of file eventloop.c.

◆ addTimer()

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

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

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().

Definition at line 248 of file eventloop.c.

◆ 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().

Definition at line 329 of file eventloop.c.

◆ deferLoop()

int deferLoop ( int  maxms,
int *  flagp 
)

Definition at line 118 of file eventloop.c.

◆ deferLoop0()

int deferLoop0 ( int  maxms,
int *  flagp 
)

Definition at line 141 of file eventloop.c.

◆ eventLoop()

void eventLoop ( )

Main calls this when ready to hand over control.

Definition at line 105 of file eventloop.c.

◆ nsecRemainingTimer()

int nsecRemainingTimer ( int  tid)

Returns the timer's remaining value in nanoseconds left until the timeout.

Parameters
tidthe timer callback ID returned from addTimer() or addPeriodicTimer()
Returns
If the timer not exists, the returned value will be -1.

◆ remainingTimer()

int remainingTimer ( int  tid)

Returns the timer's remaining value in milliseconds left until the timeout.

Parameters
tidthe timer callback ID returned from addTimer() or addPeriodicTimer()
Returns
If the timer not exists, the returned value will be -1.

Definition at line 311 of file eventloop.c.

◆ rmCallback()

void rmCallback ( int  cid)

Remove a callback function.

Parameters
cidthe callback ID returned from addCallback().

Definition at line 189 of file eventloop.c.

◆ rmTimer()

void rmTimer ( int  tid)

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

Parameters
tidthe timer callback ID returned from addTimer() or addPeriodicTimer().

Definition at line 286 of file eventloop.c.

◆ 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().

Definition at line 356 of file eventloop.c.