Annotation of libwww/Library/src/HTTimer.html, revision 2.12
2.1 frystyk 1: <HTML>
2: <HEAD>
2.6 frystyk 3: <TITLE>W3C Sample Code Library libwww Timer Class</TITLE>
2.1 frystyk 4: </HEAD>
5: <BODY>
6: <H1>
2.2 frystyk 7: The Timer Class
2.1 frystyk 8: </H1>
9: <PRE>
10: /*
11: ** (c) COPYRIGHT MIT 1995.
12: ** Please first read the full copyright statement in the file COPYRIGH.
13: */
2.2 frystyk 14: </PRE>
15: <P>
2.11 frystyk 16: The Timer class handles timers for libwww and the application. This works
2.2 frystyk 17: exactly as in X where you create a timer object with a callback function
18: and a timeout. The callback will be called every time the timer expires.
2.11 frystyk 19: There are several timeouts that can be set in libwww:
20: <OL>
21: <LI>
22: The time we keep an idle persistent connection open. Here there are in fact
23: two mechanisms depending on whether you use blocking or non-blocking sockets.
24: The default is 60 secs. The timers can be accessed using the functions defined
25: in the <A HREF="HTHost.html#Persistent">HTHost object</A>
26: <LI>
27: The idle time we want to wait when receiving a response from a server, that
28: is, if it doesn't send anything in a number of secs. The default here is
29: no timeout. It can be accessed in the
30: <A HREF="HTHost.html#RequestTimeout">HTHost object</A> as well.
31: <LI>
32: The timeout before we flush pending requests in a pipeline, the default here
33: is 30 ms. It is also accessed in the <A HREF="HTHost.html#Delayed">HTHost
34: object</A>
35: <LI>
36: The timeout before we start sending the body of a <TT>PUT</TT> or
37: <TT>POST</TT> request. Normally we send the <TT>Expect: 100-continue</TT>
38: header field but if the server doesn't send back a <TT>100 Continue</TT>
39: code then we upload the body anyway. The default is 2 secs and can be accessed
40: in the <A HREF="HTTP.html">HTTP module</A>.
41: </OL>
2.2 frystyk 42: <PRE>
43: #ifndef HTTIMER_H
44: #define HTTIMER_H
2.1 frystyk 45:
2.7 frystyk 46: #include "wwwsys.h"
2.1 frystyk 47: #include "HTReq.h"
48:
2.12 ! vbancrof 49: #ifdef __cplusplus
! 50: extern "C" {
! 51: #endif
! 52:
2.1 frystyk 53: typedef struct _HTTimer HTTimer;
2.3 eric 54:
55: typedef int HTTimerCallback (HTTimer *, void *, HTEventType type);
2.2 frystyk 56: </PRE>
2.9 frystyk 57: <H2>
2.2 frystyk 58: Create and Delete Timers
2.9 frystyk 59: </H2>
60: <P>
61: The callback function is the function that is to be called when timer expires.
2.2 frystyk 62: <PRE>
2.1 frystyk 63: extern HTTimer * HTTimer_new (HTTimer *, HTTimerCallback *,
2.8 frystyk 64: void *, ms_t millis,
65: BOOL relative, BOOL repetitive);
2.1 frystyk 66: extern BOOL HTTimer_delete (HTTimer * timer);
67: extern BOOL HTTimer_deleteAll (void);
2.10 kahan 68: extern BOOL HTTimer_expireAll (void);
2.9 frystyk 69: </PRE>
70: <H2>
71: Dispatch Timer
72: </H2>
73: <P>
74: Just do it
75: <PRE>
2.4 frystyk 76: extern int HTTimer_dispatch (HTTimer * timer);
2.9 frystyk 77: </PRE>
78: <H3>
79: Get the next timer in line
80: </H3>
81: <P>
82: Dispatches all expired timers and optionally returns the time till the next
83: one.
84: <PRE>
85: extern int HTTimer_next (ms_t * pSoonest);
2.2 frystyk 86: </PRE>
87: <H3>
2.8 frystyk 88: Reset an already existing Repetitive Timer
89: </H3>
90: <PRE>
91: extern BOOL HTTimer_refresh(HTTimer * timer, ms_t now);
92: </PRE>
2.9 frystyk 93: <H2>
94: Get Information about a Timer Object
95: </H2>
96: <H3>
97: Absolute Time when This Timer Expires
98: </H3>
99: <P>
100: Absolute time in millies when this timer will expire
101: <PRE>
102: extern ms_t HTTimer_expiresAbsolute (HTTimer * timer);
103: </PRE>
104: <H3>
105: Relative Time this Timer is running
106: </H3>
107: <P>
108: Gived the relative time in millies that this timer was registered with. For
109: example, a relative timer set to expire in 20ms will return 20.
110: <PRE>
111: #define HTTimer_getTime(t) HTTimer_expiresRelative(t)
112: extern ms_t HTTimer_expiresRelative (HTTimer * timer);
113: </PRE>
2.8 frystyk 114: <H3>
2.9 frystyk 115: Has this Timer Expired?
2.8 frystyk 116: </H3>
117: <P>
118: If so then it's time to call the dispatcher!
119: <PRE>
120: extern BOOL HTTimer_hasTimerExpired (HTTimer * timer);
121: </PRE>
122: <H3>
2.9 frystyk 123: What callback is this Timer Registered with?
124: </H3>
125: <PRE>
126: extern HTTimerCallback * HTTimer_callback (HTTimer * timer);
127: </PRE>
128: <H3>
129: Is this Time relative or Absolute?
130: </H3>
131: <PRE>
132: extern BOOL HTTimer_isRelative (HTTimer * timer);
133: </PRE>
134: <H2>
2.8 frystyk 135: Platform Specific Timers
2.9 frystyk 136: </H2>
2.8 frystyk 137: <P>
2.4 frystyk 138: On some platform, timers are supported via events or other OS specific
2.8 frystyk 139: mechanisms. You can make libwww can support these by registering a platform
140: specific timer add and timer delete method.
2.4 frystyk 141: <PRE>
142: typedef BOOL HTTimerSetCallback (HTTimer * timer);
143:
144: extern BOOL HTTimer_registerSetTimerCallback (HTTimerSetCallback * cbf);
145: extern BOOL HTTimer_registerDeleteTimerCallback (HTTimerSetCallback * cbf);
146: </PRE>
2.2 frystyk 147: <PRE>
2.12 ! vbancrof 148: #ifdef __cplusplus
! 149: }
! 150: #endif
! 151:
2.2 frystyk 152: #endif /* HTTIMER_H */
2.1 frystyk 153: </PRE>
154: <P>
155: <HR>
156: <ADDRESS>
2.12 ! vbancrof 157: @(#) $Id: HTTimer.html,v 2.11 1999/06/30 21:05:13 frystyk Exp $
2.1 frystyk 158: </ADDRESS>
159: </BODY></HTML>
Webmaster