Instrument Neutral Distributed Interface INDI
2.0.2
|
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/time.h>
#include "eventloop.h"
Go to the source code of this file.
Classes | |
struct | CB |
struct | TF |
struct | WP |
struct | Immediate |
Macros | |
#define | EPOCHDT(tp) /* ms from epoch to timeval *tp */ (((tp)->tv_usec) / 1000.0 + ((tp)->tv_sec) * 1000.0) |
Typedefs | |
typedef struct TF | TF |
typedef struct Immediate | Immediate |
typedef void() | IE_CBF(int readfiledes, void *userpointer) |
Signature of a callback. More... | |
typedef void() | IE_TCF(void *userpointer) |
Signature of a timeout caller. More... | |
typedef void() | IE_WPF(void *userpointer) |
Signature of a work procedure function. More... | |
Functions | |
void | eventLoop () |
Main calls this when ready to hand over control. More... | |
int | deferLoop (int maxms, int *flagp) |
int | deferLoop0 (int maxms, int *flagp) |
int | addCallback (int fd, CBF *fp, void *ud) |
void | rmCallback (int cid) |
int | addTimer (int ms, TCF *fp, void *ud) |
int | addPeriodicTimer (int ms, TCF *fp, void *ud) |
void | rmTimer (int timer_id) |
int | remainingTimer (int timer_id) |
int64_t | nsecsRemainingTimer (int timer_id) |
int | addWorkProc (WPF *fp, void *ud) |
void | rmWorkProc (int wid) |
void | addImmediateWork (TCF *fp, void *ud) |
int | IEAddCallback (int readfiledes, IE_CBF *fp, void *p) |
Register a new callback, fp, to be called with userpointer as argument when readfiledes is ready. More... | |
void | IERmCallback (int callbackid) |
Remove a callback function. More... | |
int | IEAddTimer (int millisecs, IE_TCF *fp, void *p) |
Register a new single-shot timer function, fp, to be called with ud as argument after ms. More... | |
int | IEAddPeriodicTimer (int millisecs, IE_TCF *fp, void *p) |
Register a new periodic timer function, fp, to be called with ud as argument after ms. More... | |
int | IERemainingTimer (int timerid) |
Returns the timer's remaining value in milliseconds left until the timeout. More... | |
int64_t | IENSecsRemainingTimer (int timerid) |
void | IERmTimer (int timerid) |
Remove the timer with the given timerid, as returned from IEAddTimer() or IEAddPeriodicTimer(). More... | |
int | IEAddWorkProc (IE_WPF *fp, void *p) |
Add a new work procedure, fp, to be called with ud when nothing else to do. More... | |
void | IERmWorkProc (int workprocid) |
Remove a work procedure. More... | |
int | IEDeferLoop (int maxms, int *flagp) |
wait in-line for a flag to set, presumably by another event function More... | |
int | IEDeferLoop0 (int maxms, int *flagp) |
#define EPOCHDT | ( | tp | ) | /* ms from epoch to timeval *tp */ (((tp)->tv_usec) / 1000.0 + ((tp)->tv_sec) * 1000.0) |
Definition at line 78 of file eventloop.c.
IE_CBF |
Signature of a callback.
Definition at line 568 of file eventloop.c.
IE_TCF |
Signature of a timeout caller.
Definition at line 569 of file eventloop.c.
IE_WPF |
Signature of a work procedure function.
Definition at line 570 of file eventloop.c.
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. |
Definition at line 161 of file eventloop.c.
void addImmediateWork | ( | TCF * | fp, |
void * | ud | ||
) |
Register a given function to be called once after the current loop
fp | a pointer to the callback function. |
ud | a pointer to be passed to the callback function when called. |
Definition at line 524 of file eventloop.c.
int addPeriodicTimer | ( | int | ms, |
TCF * | fp, | ||
void * | ud | ||
) |
Register a new periodic timer function, fp, to be called with ud as argument after ms.
ms | timer period in milliseconds. |
fp | a pointer to the callback function. |
ud | a pointer to be passed to the callback function when called. |
Definition at line 253 of file eventloop.c.
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.
ms | timer period in milliseconds. |
fp | a pointer to the callback function. |
ud | a pointer to be passed to the callback function when called. |
Definition at line 248 of file eventloop.c.
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. |
Definition at line 329 of file eventloop.c.
int deferLoop | ( | int | maxms, |
int * | flagp | ||
) |
Definition at line 118 of file eventloop.c.
int deferLoop0 | ( | int | maxms, |
int * | flagp | ||
) |
Definition at line 141 of file eventloop.c.
void eventLoop | ( | ) |
Main calls this when ready to hand over control.
Definition at line 105 of file eventloop.c.
int IEAddCallback | ( | int | readfiledes, |
IE_CBF * | fp, | ||
void * | userpointer | ||
) |
Register a new callback, fp, to be called with userpointer as argument when readfiledes is ready.
readfiledes | file descriptor. |
fp | a pointer to the callback function. |
userpointer | a pointer to be passed to the callback function when called. |
Definition at line 572 of file eventloop.c.
int IEAddPeriodicTimer | ( | int | millisecs, |
IE_TCF * | fp, | ||
void * | userpointer | ||
) |
Register a new periodic timer function, fp, to be called with ud as argument after ms.
millisecs | timer period in milliseconds. |
fp | a pointer to the callback function. |
userpointer | a pointer to be passed to the callback function when called. |
Definition at line 587 of file eventloop.c.
int IEAddTimer | ( | int | millisecs, |
IE_TCF * | fp, | ||
void * | userpointer | ||
) |
Register a new single-shot timer function, fp, to be called with ud as argument after ms.
millisecs | timer period in milliseconds. |
fp | a pointer to the callback function. |
userpointer | a pointer to be passed to the callback function when called. |
Definition at line 582 of file eventloop.c.
int IEAddWorkProc | ( | IE_WPF * | fp, |
void * | userpointer | ||
) |
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. |
userpointer | a pointer to be passed to the callback function when called. |
Definition at line 607 of file eventloop.c.
int IEDeferLoop | ( | int | maxms, |
int * | flagp | ||
) |
wait in-line for a flag to set, presumably by another event function
Definition at line 617 of file eventloop.c.
int IEDeferLoop0 | ( | int | maxms, |
int * | flagp | ||
) |
Definition at line 622 of file eventloop.c.
int64_t IENSecsRemainingTimer | ( | int | timerid | ) |
Definition at line 597 of file eventloop.c.
int IERemainingTimer | ( | int | timerid | ) |
Returns the timer's remaining value in milliseconds left until the timeout.
timerid | the timer callback ID returned from IEAddTimer() or IEAddPeriodicTimer() |
Definition at line 592 of file eventloop.c.
void IERmCallback | ( | int | callbackid | ) |
Remove a callback function.
callbackid | the callback ID returned from IEAddCallback() |
Definition at line 577 of file eventloop.c.
void IERmTimer | ( | int | timerid | ) |
Remove the timer with the given timerid, as returned from IEAddTimer() or IEAddPeriodicTimer().
timerid | the timer callback ID returned from IEAddTimer() or IEAddPeriodicTimer(). |
Definition at line 602 of file eventloop.c.
void IERmWorkProc | ( | int | workprocid | ) |
Remove a work procedure.
workprocid | The unique ID for the work procedure to be removed. |
Definition at line 612 of file eventloop.c.
int64_t nsecsRemainingTimer | ( | int | timer_id | ) |
Definition at line 320 of file eventloop.c.
int remainingTimer | ( | int | tid | ) |
Returns the timer's remaining value in milliseconds left until the timeout.
tid | the timer callback ID returned from addTimer() or addPeriodicTimer() |
Definition at line 311 of file eventloop.c.
void rmCallback | ( | int | cid | ) |
Remove a callback function.
cid | the callback ID returned from addCallback(). |
Definition at line 189 of file eventloop.c.
void rmTimer | ( | int | tid | ) |
Remove the timer with the given id, as returned from addTimer() or addPeriodicTimer().
tid | the timer callback ID returned from addTimer() or addPeriodicTimer(). |
Definition at line 286 of file eventloop.c.
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(). |
Definition at line 356 of file eventloop.c.