/[resiprocate]/main/sip/resiprocate/TimerQueue.cxx
ViewVC logotype

Annotation of /main/sip/resiprocate/TimerQueue.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 871 - (hide annotations) (download)
Tue Dec 10 18:36:21 2002 UTC (17 years, 1 month ago) by jason
File size: 3844 byte(s)
added some new subsystems for debugging purposes

1 fluffy 236
2 jason 537 #include "sip2/util/Socket.hxx"
3 fluffy 236
4 jason 537 #include "sip2/sipstack/TimerQueue.hxx"
5     #include "sip2/sipstack/TimerMessage.hxx"
6     #include "sip2/util/Logger.hxx"
7     //#include "sip2/util/Inserter.hxx"
8 jason 69
9     using namespace Vocal2;
10 jason 301 using namespace std;
11 jason 69
12 jason 871 #define VOCAL_SUBSYSTEM Subsystem::TRANSACTION
13 dabryan 139
14 jason 69 TimerQueue::TimerQueue(Fifo<Message>& fifo) : mFifo(fifo)
15     {
16     }
17    
18     Timer::Id
19     TimerQueue::add(Timer::Type type, const Data& transactionId, unsigned long msOffset)
20     {
21     Timer t(msOffset, type, transactionId);
22     mTimers.insert(t);
23 jason 404 DebugLog (<< "Adding timer: " << Timer::toData(type) << " tid=" << transactionId << " ms=" << msOffset);
24 dabryan 139
25 jason 69 return t.getId();
26     }
27    
28     void
29     TimerQueue::process()
30     {
31     // get the set of timers that have fired and insert TimerMsg into the fifo
32    
33 jason 301 Timer now(0);
34     for (std::multiset<Timer>::iterator i = mTimers.begin();
35     i != mTimers.upper_bound(now);)
36 jason 69 {
37 dabryan 150 TimerMessage* t = new TimerMessage(i->mTransactionId, i->mType, i->mDuration);
38 jason 404 DebugLog (<< "Adding timer to fifo: " << " tid=" << i->mTransactionId << " type=" << Timer::toData(i->mType));
39 jason 69 mFifo.add(t);
40 jason 301 mTimers.erase(i++);
41 jason 69 }
42     }
43    
44     void
45     TimerQueue::run()
46     {
47     assert(0);
48     // for the thread
49     }
50    
51 jason 301 ostream&
52     Vocal2::operator<<(ostream& str, const TimerQueue& tq)
53     {
54 fluffy 305 str << "TimerQueue[" ;
55    
56     for (std::multiset<Timer>::const_iterator i = tq.mTimers.begin();
57     i != tq.mTimers.end();
58     i++)
59     {
60     str << *i << " " ;
61     }
62    
63     str << "]" << endl;
64 jason 301 return str;
65     }
66 fluffy 278
67    
68     /* ====================================================================
69     * The Vovida Software License, Version 1.0
70     *
71     * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
72     *
73     * Redistribution and use in source and binary forms, with or without
74     * modification, are permitted provided that the following conditions
75     * are met:
76     *
77     * 1. Redistributions of source code must retain the above copyright
78     * notice, this list of conditions and the following disclaimer.
79     *
80     * 2. Redistributions in binary form must reproduce the above copyright
81     * notice, this list of conditions and the following disclaimer in
82     * the documentation and/or other materials provided with the
83     * distribution.
84     *
85     * 3. The names "VOCAL", "Vovida Open Communication Application Library",
86     * and "Vovida Open Communication Application Library (VOCAL)" must
87     * not be used to endorse or promote products derived from this
88     * software without prior written permission. For written
89     * permission, please contact vocal@vovida.org.
90     *
91     * 4. Products derived from this software may not be called "VOCAL", nor
92     * may "VOCAL" appear in their name, without prior written
93     * permission of Vovida Networks, Inc.
94     *
95     * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
96     * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
97     * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
98     * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
99     * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
100     * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
101     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
102     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
103     * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
104     * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
105     * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
106     * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
107     * DAMAGE.
108     *
109     * ====================================================================
110     *
111     * This software consists of voluntary contributions made by Vovida
112     * Networks, Inc. and many individuals on behalf of Vovida Networks,
113     * Inc. For more information on Vovida Networks, Inc., please see
114     * <http://www.vovida.org/>.
115     *
116     */

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27