Debian Codegraph @

addons/ooh323c/src/ooTimer.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2004-2005 by Objective Systems, Inc.
3 *
4 * This software is furnished under an open source license and may be
5 * used and copied only in accordance with the terms of this license.
6 * The text of the license may generally be found in the root
7 * directory of this installation in the LICENSE.txt file. It
8 * can also be viewed online at the following URL:
9 *
10 * http://www.obj-sys.com/open/license.html
11 *
12 * Any redistributions of this file including modified versions must
13 * maintain this copyright notice.
14 *
15 *****************************************************************************/
16 /**
17 * @file ooTimer.h
18 * Timer structures and functions.
19 */
20 #ifndef _OOTIMER_H_
21 #define _OOTIMER_H_
22
23 #include "ooasn1.h"
24 #include "ooSocket.h" /* needed for timeval */
25
26 struct _OOTimer;
27
28 typedef int (*OOTimerCbFunc)(void *data);
29
30 typedef struct _OOTimer {
31 struct timeval expireTime, timeout;
32 void* cbData;
33 OOBOOL reRegister;
34
35 /* Callback functions */
36 OOTimerCbFunc timeoutCB;
37 } OOTimer;
38
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42
43 /**
44 * This function computes the relative expiration time from the current
45 * time for the given timer object.
46 *
47 * @param pTimer Pointer to timer object.
48 */
49 EXTERN void ooTimerComputeExpireTime (OOTimer* pTimer);
50
51 /**
52 * This function creates and initializes a new timer object.
53 * @param pctxt OOCTXT structure used for timer memory allocation.
54 * @param pList Pointer to timer list in which newly created timer will
55 * be inserted.
56 * @param cb Timer callback function.
57 * @param deltaSecs Time in seconds to timer expiration.
58 * @param data Callback user data argument.
59 * @param reRegister Should timer be re-registered after it expires?
60 * @return Pointer to created timer object.
61 */
62 EXTERN OOTimer* ooTimerCreate
63 (OOCTXT* pctxt, DList *pList, OOTimerCbFunc cb, OOUINT32 deltaSecs, void *data,
64 OOBOOL reRegister);
65
66 /**
67 * This function deletes the given timer object.
68 * @param pctxt Handle to OOCTXT structure used for timer memory.
69 * @param pList timer list to operate on
70 * @param pTimer Pointer to timer object.
71 */
72 EXTERN void ooTimerDelete (OOCTXT* pctxt, DList* pList, OOTimer* pTimer);
73
74 /**
75 * This function checks a timer to determine if it is expired.
76 *
77 * @param pTimer Pointer to timer object.
78 * @return True if timer expired, false if not.
79 */
80 EXTERN OOBOOL ooTimerExpired (OOTimer* pTimer);
81
82 /**
83 * This function loops through the global timer list and fires all
84 * expired timers by calling the registered callback functions.
85 */
86 EXTERN void ooTimerFireExpired (OOCTXT* pctxt, DList* pList);
87
88 /**
89 * This function inserts the given timer object into the correct
90 * chronological position in the global timer list.
91 * @param pctxt Pointer to OOCTXT structure used for memory allocation.
92 * @param pList List in which timer has to be inserted.
93 * @param pTimer Pointer to timer object.
94 * @return Index to position where inserted in list.
95 */
96 EXTERN int ooTimerInsertEntry (OOCTXT* pctxt, DList* pList, OOTimer* pTimer);
97
98 /**
99 * This function calculates the relative time from the current time
100 * that the first timer in global timer list will expire.
101 * @param pList Handle to timer list
102 * @param ptimeout timeval structure to receive timeout value.
103 * @return ptimeout
104 */
105 EXTERN struct timeval* ooTimerNextTimeout (DList* pList, struct timeval* ptimeout);
106
107 /**
108 * This function resets the given timer object if its reregister flag
109 * is set. Otherwise, it is deleted.
110 * @param pctxt Pointer to OOCTXT structre used for memory allocation.
111 * @param pList Pointer to timer list.
112 * @param pTimer Pointer to timer object.
113 */
114 EXTERN void ooTimerReset (OOCTXT* pctxt, DList* pList, OOTimer* pTimer);
115
116
117 /**
118 * This function is used to compare two timeout values.
119 * @param to1 First timeout value.
120 * @param to2 Second timeout value.
121 *
122 * @return 1, if to1 > to2; 0, if to1 == to2; -1, if to1 < to2
123 */
124 int ooCompareTimeouts(struct timeval *to1, struct timeval *to2);
125 #ifdef __cplusplus
126 }
127 #endif
128 #endif