|
Instrument Neutral Distributed Interface INDI 2.2.5
|
#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. | |
| typedef void() | IE_TCF(void *userpointer) |
| Signature of a timeout caller. | |
| typedef void() | IE_WPF(void *userpointer) |
| Signature of a work procedure function. | |
Functions | |
| void | eventLoop () |
| Main calls this when ready to hand over control. | |
| 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. | |
| void | IERmCallback (int callbackid) |
| Remove a callback function. | |
| 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. | |
| 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. | |
| int | IERemainingTimer (int timerid) |
| Returns the timer's remaining value in milliseconds left until the timeout. | |
| int64_t | IENSecsRemainingTimer (int timerid) |
| void | IERmTimer (int timerid) |
| Remove the timer with the given timerid, as returned from IEAddTimer() or IEAddPeriodicTimer(). | |
| int | IEAddWorkProc (IE_WPF *fp, void *p) |
| Add a new work procedure, fp, to be called with ud when nothing else to do. | |
| void | IERmWorkProc (int workprocid) |
| Remove a work procedure. | |
| int | IEDeferLoop (int maxms, int *flagp) |
| wait in-line for a flag to set, presumably by another event function | |
| 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 82 of file eventloop.c.
| IE_CBF |
Signature of a callback.
Definition at line 572 of file eventloop.c.
| IE_TCF |
Signature of a timeout caller.
Definition at line 573 of file eventloop.c.
| IE_WPF |
Signature of a work procedure function.
Definition at line 574 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 165 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 528 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 257 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 252 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 333 of file eventloop.c.
| int deferLoop | ( | int | maxms, |
| int * | flagp | ||
| ) |
Definition at line 122 of file eventloop.c.
| int deferLoop0 | ( | int | maxms, |
| int * | flagp | ||
| ) |
Definition at line 145 of file eventloop.c.
| void eventLoop | ( | ) |
Main calls this when ready to hand over control.
Definition at line 109 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 576 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 591 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 586 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 611 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 621 of file eventloop.c.
| int IEDeferLoop0 | ( | int | maxms, |
| int * | flagp | ||
| ) |
Definition at line 626 of file eventloop.c.
| int64_t IENSecsRemainingTimer | ( | int | timerid | ) |
Definition at line 601 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 596 of file eventloop.c.
| void IERmCallback | ( | int | callbackid | ) |
Remove a callback function.
| callbackid | the callback ID returned from IEAddCallback() |
Definition at line 581 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 606 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 616 of file eventloop.c.
| int64_t nsecsRemainingTimer | ( | int | timer_id | ) |
Definition at line 324 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 315 of file eventloop.c.
| void rmCallback | ( | int | cid | ) |
Remove a callback function.
| cid | the callback ID returned from addCallback(). |
Definition at line 193 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 290 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 360 of file eventloop.c.