/[resiprocate]/branches/b-directory-reorg/sip/resiprocate/TimerQueue.hxx
ViewVC logotype

Contents of /branches/b-directory-reorg/sip/resiprocate/TimerQueue.hxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5271 - (show annotations) (download)
Thu Aug 18 23:43:07 2005 UTC (14 years, 3 months ago) by jason
File size: 5340 byte(s)
new directory reorg proposal
1 #if !defined(RESIP_TIMERQUEUE_HXX)
2 #define RESIP_TIMERQUEUE_HXX
3
4 #include <set>
5 #include <iosfwd>
6 #include "resiprocate/TransactionMessage.hxx"
7 #include "resiprocate/DtlsMessage.hxx"
8 #include "resiprocate/os/Fifo.hxx"
9 #include "resiprocate/os/TimeLimitFifo.hxx"
10 #include "resiprocate/os/Timer.hxx"
11
12 // .dlb.
13 // to do: timer wheel for transaction-bound timers and a heap for
14 // everything longer.
15
16 namespace resip
17 {
18
19 class Message;
20 class TransactionMessage;
21 class TuSelector;
22
23 /**
24 * This class takes a fifo as a place to where you can write your stuff.
25 * In the main loop when using this you need to call process() on this.
26 * During Transaction processing, TimerMessages and SIP messages get generated.
27 **/
28
29 class BaseTimerQueue
30 {
31 public:
32 /// deletes the message associated with the timer as well.
33 virtual ~BaseTimerQueue()=0;
34
35 /// gets the set of timers that have fired and inserts TimerMsg into the state
36 /// machine fifo and application messages into the TU fifo
37 virtual void process()=0;
38
39 int size() const;
40 bool empty() const;
41
42 /** Give me the time before the next timer will fire in milliseconds
43 * @retval milliseconds (time until the next timer will fire)
44 * @retval 0 (implies that timers occur in the past)
45 * @retval INT_MAX (implies that there are no timers)
46 **/
47 unsigned int msTillNextTimer();
48
49 protected:
50 friend std::ostream& operator<<(std::ostream&, const BaseTimerQueue&);
51 std::multiset<Timer> mTimers;
52 };
53
54 class BaseTimeLimitTimerQueue : public BaseTimerQueue
55 {
56 public:
57 void add(const Timer& timer);
58 virtual void process();
59 protected:
60 virtual void addToFifo(Message*, TimeLimitFifo<Message>::DepthUsage)=0;
61 };
62
63
64 class TimeLimitTimerQueue : public BaseTimeLimitTimerQueue
65 {
66 public:
67 TimeLimitTimerQueue(TimeLimitFifo<Message>& fifo);
68 protected:
69 virtual void addToFifo(Message*, TimeLimitFifo<Message>::DepthUsage);
70 private:
71 TimeLimitFifo<Message>& mFifo;
72 };
73
74
75 class TuSelectorTimerQueue : public BaseTimeLimitTimerQueue
76 {
77 public:
78 TuSelectorTimerQueue(TuSelector& sel);
79 protected:
80 virtual void addToFifo(Message*, TimeLimitFifo<Message>::DepthUsage);
81 private:
82 TuSelector& mFifoSelector;
83 };
84
85
86 class TimerQueue : public BaseTimerQueue
87 {
88 public:
89 TimerQueue(Fifo<TransactionMessage>& fifo);
90 Timer::Id add(Timer::Type type, const Data& transactionId, unsigned long msOffset);
91 virtual void process();
92 private:
93 Fifo<TransactionMessage>& mFifo;
94 };
95
96 #ifdef USE_DTLS
97
98 #include <openssl/ssl.h>
99
100 class DtlsTimerQueue : public BaseTimerQueue
101 {
102 public:
103 DtlsTimerQueue( Fifo<DtlsMessage>& fifo ) ;
104 void add( SSL *, unsigned long msOffset ) ;
105 virtual void process() ;
106
107 private:
108 Fifo<DtlsMessage>& mFifo ;
109 };
110
111 #endif
112
113 std::ostream& operator<<(std::ostream&, const BaseTimerQueue&);
114
115 }
116
117 #endif
118
119 /* ====================================================================
120 * The Vovida Software License, Version 1.0
121 *
122 * Copyright (c) 2004 Vovida Networks, Inc. All rights reserved.
123 *
124 * Redistribution and use in source and binary forms, with or without
125 * modification, are permitted provided that the following conditions
126 * are met:
127 *
128 * 1. Redistributions of source code must retain the above copyright
129 * notice, this list of conditions and the following disclaimer.
130 *
131 * 2. Redistributions in binary form must reproduce the above copyright
132 * notice, this list of conditions and the following disclaimer in
133 * the documentation and/or other materials provided with the
134 * distribution.
135 *
136 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
137 * and "Vovida Open Communication Application Library (VOCAL)" must
138 * not be used to endorse or promote products derived from this
139 * software without prior written permission. For written
140 * permission, please contact vocal@vovida.org.
141 *
142 * 4. Products derived from this software may not be called "VOCAL", nor
143 * may "VOCAL" appear in their name, without prior written
144 * permission of Vovida Networks, Inc.
145 *
146 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
147 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
148 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
149 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
150 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
151 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
152 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
153 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
154 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
155 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
156 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
157 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
158 * DAMAGE.
159 *
160 * ====================================================================
161 *
162 * This software consists of voluntary contributions made by Vovida
163 * Networks, Inc. and many individuals on behalf of Vovida Networks,
164 * Inc. For more information on Vovida Networks, Inc., please see
165 * <http://www.vovida.org/>.
166 *
167 */

Properties

Name Value
svn:eol-style LF

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27