/[resiprocate]/branches/b-identity-0505/ConnectionManager.hxx
ViewVC logotype

Contents of /branches/b-identity-0505/ConnectionManager.hxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4598 - (show annotations) (download)
Wed May 11 22:53:07 2005 UTC (14 years, 6 months ago) by derek
File size: 4338 byte(s)
set svn:eol-style to LF
1 #if !defined(RESIP_ConnectionMgr_hxx)
2 #define RESIP_ConnectionMgr_hxx
3
4 #include <map>
5 #include "resiprocate/os/HashMap.hxx"
6 #include "resiprocate/Connection.hxx"
7
8 namespace resip
9 {
10
11 class ConnectionManager
12 {
13 friend class Connection;
14 public:
15 // smallest time to reuse
16 static const UInt64 MinLastUsed;
17 // largest unused time to reclaim
18 static const UInt64 MaxLastUsed;
19
20 ConnectionManager();
21 ~ConnectionManager();
22
23 Connection* findConnection(const Tuple& tuple);
24
25 // Return 0 if nothing to do
26 Connection* getNextRead(FdSet &fdset);
27 Connection* getNextWrite();
28 void buildFdSet(FdSet& fdset);
29
30 private:
31 void addToWritable(Connection* conn); // add the specified conn to end
32 void removeFromWritable(); // remove the current mWriteMark
33
34 // release excessively old connections (free up file descriptors)
35 void gc(UInt64 threshhold = ConnectionManager::MaxLastUsed);
36
37 typedef std::map<Tuple, Connection*> AddrMap;
38 typedef std::map<ConnectionId, Connection*> IdMap;
39
40 void addConnection(Connection* connection);
41 void removeConnection(Connection* connection);
42
43 // move to youngest
44 // !jf! I think it would be reasonable to look for oldest when time comes
45 // to delete rather than touch each time
46 void touch(Connection* connection);
47
48 AddrMap mAddrMap;
49 IdMap mIdMap;
50
51 //>>---------------------------------
52 // intrusive list management
53 Connection mHead;
54
55 ConnectionWriteList* mWriteHead;
56 ConnectionWriteList::iterator mWriteIter;
57
58 ConnectionReadList* mReadHead;
59 ConnectionReadList::iterator mReadIter;
60
61 ConnectionLruList* mLRUHead;
62
63 // reset iterators if they've been invalidated
64 void checkIterators();
65 //<<---------------------------------
66
67 ConnectionId mConnectionIdGenerator;
68
69 friend class TcpBaseTransport;
70 };
71
72 }
73
74 #endif
75
76 /* ====================================================================
77 * The Vovida Software License, Version 1.0
78 *
79 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
80 *
81 * Redistribution and use in source and binary forms, with or without
82 * modification, are permitted provided that the following conditions
83 * are met:
84 *
85 * 1. Redistributions of source code must retain the above copyright
86 * notice, this list of conditions and the following disclaimer.
87 *
88 * 2. Redistributions in binary form must reproduce the above copyright
89 * notice, this list of conditions and the following disclaimer in
90 * the documentation and/or other materials provided with the
91 * distribution.
92 *
93 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
94 * and "Vovida Open Communication Application Library (VOCAL)" must
95 * not be used to endorse or promote products derived from this
96 * software without prior written permission. For written
97 * permission, please contact vocal@vovida.org.
98 *
99 * 4. Products derived from this software may not be called "VOCAL", nor
100 * may "VOCAL" appear in their name, without prior written
101 * permission of Vovida Networks, Inc.
102 *
103 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
104 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
105 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
106 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
107 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
108 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
109 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
110 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
111 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
112 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
113 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
114 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
115 * DAMAGE.
116 *
117 * ====================================================================
118 *
119 * This software consists of voluntary contributions made by Vovida
120 * Networks, Inc. and many individuals on behalf of Vovida Networks,
121 * Inc. For more information on Vovida Networks, Inc., please see
122 * <http://www.vovida.org/>.
123 *
124 */

Properties

Name Value
svn:eol-style LF

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27