reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
TimerQueue.cxx
Go to the documentation of this file.
1
2#if defined(HAVE_CONFIG_H)
3#include "config.h"
4#endif
5
6#include "rutil/ResipAssert.h"
7#include <limits.h>
8
13#include "rutil/Logger.hxx"
14#include "rutil/Inserter.hxx"
16
17using namespace resip;
18using namespace std;
19
20#define RESIPROCATE_SUBSYSTEM Subsystem::TRANSACTION
21
26
27#ifdef USE_DTLS
28
30 : mFifo( fifo )
31{
32}
33
35{
36 while(!mTimers.empty())
37 {
38 delete mTimers.top().getMessage();
39 mTimers.pop();
40 }
41}
42
43#endif
44
46TransactionTimerQueue::add(Timer::Type type, const Data& transactionId, unsigned long msOffset)
47{
48 TransactionTimer t(msOffset, type, transactionId);
49 mTimers.push(t);
50 DebugLog (<< "Adding timer: " << Timer::toData(type) << " tid=" << transactionId << " ms=" << msOffset);
51 return mTimers.top().getWhen();
52}
53
54#ifdef USE_DTLS
55
57DtlsTimerQueue::add( SSL *ssl, unsigned long msOffset )
58{
59 TimerWithPayload t( msOffset, new DtlsMessage( ssl ) ) ;
60 mTimers.push( t ) ;
61 return mTimers.top().getWhen();
62}
63
64#endif
65
67{
68 while(!mTimers.empty())
69 {
70 delete mTimers.top().getMessage();
71 mTimers.pop();
72 }
73}
74
76BaseTimeLimitTimerQueue::add(unsigned int timeMs,Message* payload)
77{
78 resip_assert(payload);
79 DebugLog(<< "Adding application timer: " << payload->brief() << " ms=" << timeMs);
80 mTimers.push(TimerWithPayload(timeMs,payload));
81 return mTimers.top().getWhen();
82}
83
84void
90
91void
93{
94 mFifo.add(new TimerMessage(timer.getTransactionId(),
95 timer.getType(),
96 timer.getDuration()));
97}
98
101
102void
107
110
112{
113 while(!mTimers.empty())
114 {
115 delete mTimers.top().getMessage();
116 mTimers.pop();
117 }
118}
119
121TuSelectorTimerQueue::add(unsigned int timeMs,Message* payload)
122{
123 resip_assert(payload);
124 DebugLog(<< "Adding application timer: " << payload->brief() << " ms=" << timeMs);
125 mTimers.push(TimerWithPayload(timeMs,payload));
126 return mTimers.top().getWhen();
127}
128
129void
135
136#ifdef USE_DTLS
137
138void
140{
141 mFifo.add( (DtlsMessage *)timer.getMessage() ) ;
142}
143
144#endif
145
146/* ====================================================================
147 * The Vovida Software License, Version 1.0
148 *
149 * Copyright (c) 2004 Vovida Networks, Inc. All rights reserved.
150 *
151 * Redistribution and use in source and binary forms, with or without
152 * modification, are permitted provided that the following conditions
153 * are met:
154 *
155 * 1. Redistributions of source code must retain the above copyright
156 * notice, this list of conditions and the following disclaimer.
157 *
158 * 2. Redistributions in binary form must reproduce the above copyright
159 * notice, this list of conditions and the following disclaimer in
160 * the documentation and/or other materials provided with the
161 * distribution.
162 *
163 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
164 * and "Vovida Open Communication Application Library (VOCAL)" must
165 * not be used to endorse or promote products derived from this
166 * software without prior written permission. For written
167 * permission, please contact vocal@vovida.org.
168 *
169 * 4. Products derived from this software may not be called "VOCAL", nor
170 * may "VOCAL" appear in their name, without prior written
171 * permission of Vovida Networks, Inc.
172 *
173 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
174 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
175 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
176 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
177 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
178 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
179 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
180 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
181 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
182 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
183 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
184 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
185 * DAMAGE.
186 *
187 * ====================================================================
188 *
189 * This software consists of voluntary contributions made by Vovida
190 * Networks, Inc. and many individuals on behalf of Vovida Networks,
191 * Inc. For more information on Vovida Networks, Inc., please see
192 * <http://www.vovida.org/>.
193 *
194 */
struct ssl_st SSL
#define DebugLog(args_)
Definition Logger.hxx:128
#define resip_assert(x)
This file needs to work for both C and C++ code.
uint64_t add(unsigned int timeMs, Message *payload)
virtual void addToFifo(Message *, TimeLimitFifo< Message >::DepthUsage)=0
virtual void processTimer(const TimerWithPayload &timer)
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
DtlsTimerQueue(Fifo< DtlsMessage > &fifo)
uint64_t add(SSL *, unsigned long msOffset)
virtual void processTimer(const TimerWithPayload &timer)
A templated, threadsafe message-queue class.
Definition Fifo.hxx:16
The base-class used for message-passing.
Definition Message.hxx:21
virtual Brief brief() const
return a facet for brief encoding of message
Definition Message.cxx:16
TimeLimitTimerQueue(TimeLimitFifo< Message > &fifo)
virtual void addToFifo(Message *, TimeLimitFifo< Message >::DepthUsage)
std::priority_queue< TimerWithPayload, TimerVector, std::greater< TimerWithPayload > > mTimers
Message * getMessage() const
Definition Timer.hxx:192
static Data toData(Type timer)
Definition Timer.cxx:71
uint64_t add(Timer::Type type, const Data &transactionId, unsigned long msOffset)
TransactionTimerQueue(Fifo< TimerMessage > &fifo)
virtual void processTimer(const TransactionTimer &timer)
unsigned long getDuration() const
Definition Timer.hxx:154
Timer::Type getType() const
Definition Timer.hxx:153
const Data & getTransactionId() const
Definition Timer.hxx:152
TuSelectorTimerQueue(TuSelector &sel)
virtual void processTimer(const TimerWithPayload &timer)
uint64_t add(unsigned int timeMs, Message *payload)
void add(Message *msg, TimeLimitFifo< Message >::DepthUsage usage)
dcm! – add UnusedChecking(_enum) below;
unsigned long long uint64_t
Definition Stun.hxx:39