Instrument Neutral Distributed Interface INDI 2.2.5
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.
 
typedef void() WPF(void *)
 Signature of a work procedure function.
 
typedef void() TCF(void *)
 Signature of a timer function.
 

Functions

void eventLoop ()
 Main calls this when ready to hand over control.
 
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)
 
void addImmediateWork (TCF *fp, void *ud)
 
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 38 of file eventloop.h.

◆ TCF

TCF

Signature of a timer function.

Definition at line 48 of file eventloop.h.

◆ WPF

WPF

Signature of a work procedure function.

Definition at line 43 of file eventloop.h.

Function Documentation

◆ addCallback()

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

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 165 of file eventloop.c.

◆ addImmediateWork()

void addImmediateWork ( TCF *  fp,
void *  ud 
)
extern

Register a given function to be called once after the current loop

Parameters
fpa pointer to the callback function.
uda pointer to be passed to the callback function when called.

Definition at line 528 of file eventloop.c.

◆ addPeriodicTimer()

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

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 257 of file eventloop.c.

◆ addTimer()

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

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 252 of file eventloop.c.

◆ addWorkProc()

int addWorkProc ( WPF *  fp,
void *  ud 
)
extern

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 333 of file eventloop.c.

◆ deferLoop()

int deferLoop ( int  maxms,
int *  flagp 
)
extern

Definition at line 122 of file eventloop.c.

◆ deferLoop0()

int deferLoop0 ( int  maxms,
int *  flagp 
)
extern

Definition at line 145 of file eventloop.c.

◆ eventLoop()

void eventLoop ( )
extern

Main calls this when ready to hand over control.

Definition at line 109 of file eventloop.c.

◆ nsecRemainingTimer()

int nsecRemainingTimer ( int  tid)
extern

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)
extern

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 315 of file eventloop.c.

◆ rmCallback()

void rmCallback ( int  cid)
extern

Remove a callback function.

Parameters
cidthe callback ID returned from addCallback().

Definition at line 193 of file eventloop.c.

◆ rmTimer()

void rmTimer ( int  tid)
extern

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 290 of file eventloop.c.

◆ rmWorkProc()

void rmWorkProc ( int  wid)
extern

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

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

Definition at line 360 of file eventloop.c.