source: BAORadio/libindi/v1/eventloop.h @ 612

Last change on this file since 612 was 490, checked in by campagne, 14 years ago

import libindi (JEC)

File size: 3.4 KB
Line 
1#if 0
2    INDI
3    Copyright (C) 2003 Elwood C. Downey
4
5    This library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9
10    This library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public
16    License along with this library; if not, write to the Free Software
17    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18
19#endif
20
21#ifndef EVENT_LOOP_H
22#define EVENT_LOOP_H
23
24/** \file eventloop.h
25    \brief Public interface to INDI's eventloop mechanism.
26    \author Elwood C. Downey
27*/
28
29/* signature of a callback, workproc and timer function */
30
31/** \typedef CBF
32    \brief Signature of a callback function.
33*/
34typedef void (CBF) (int fd, void *);
35
36/** \typedef WPF
37    \brief Signature of a work procedure function.
38*/
39typedef void (WPF) (void *);
40
41/** \typedef TCF
42    \brief Signature of a timer function.
43*/
44typedef void (TCF) (void *);
45
46#ifdef __cplusplus
47extern "C" {
48#endif
49
50/** \fn void eventLoop(void)
51    \brief Main calls this when ready to hand over control.
52*/
53extern void eventLoop(void);
54
55/** Register a new callback, \e fp, to be called with \e ud as argument when \e fd is ready.
56*
57* \param fd file descriptor.
58* \param fp a pointer to the callback function.
59* \param ud a pointer to be passed to the callback function when called.
60* \return a unique callback id for use with rmCallback().
61*/
62extern int addCallback (int fd, CBF *fp, void *ud);
63
64/** Remove a callback function.
65*
66* \param cid the callback ID returned from addCallback().
67*/
68extern void rmCallback (int cid);
69
70/** Add a new work procedure, fp, to be called with ud when nothing else to do.
71*
72* \param fp a pointer to the work procedure callback function.
73* \param ud a pointer to be passed to the callback function when called.
74* \return a unique id for use with rmWorkProc().
75*/
76extern int addWorkProc (WPF *fp, void *ud);
77
78/** Remove the work procedure with the given \e id, as returned from addWorkProc().
79*
80* \param wid the work procedure callback ID returned from addWorkProc().
81*/
82extern void rmWorkProc (int wid);
83
84/** Register a new timer function, \e fp, to be called with \e ud as argument after \e ms. Add to list in order of decreasing time from epoch, ie, last entry runs soonest. The timer will only invoke the callback function \b once. You need to call addTimer again if you want to repeat the process.
85*
86* \param ms timer period in milliseconds.
87* \param fp a pointer to the callback function.
88* \param ud a pointer to be passed to the callback function when called.
89* \return a unique id for use with rmTimer().
90*/
91extern int addTimer (int ms, TCF *fp, void *ud);
92
93/** Remove the timer with the given \e id, as returned from addTimer().
94*
95* \param tid the timer callback ID returned from addTimer().
96*/
97extern void rmTimer (int tid);
98
99/* utility functions */
100extern int deferLoop (int maxms, int *flagp);
101extern int deferLoop0 (int maxms, int *flagp);
102
103#ifdef __cplusplus
104}
105#endif
106
107#endif
Note: See TracBrowser for help on using the repository browser.