Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(410)

Side by Side Diff: net/third_party/udt/src/cache.h

Issue 6708091: Remove UDT. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/third_party/udt/src/buffer.cpp ('k') | net/third_party/udt/src/cache.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*****************************************************************************
2 Copyright (c) 2001 - 2011, The Board of Trustees of the University of Illinois.
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are
7 met:
8
9 * Redistributions of source code must retain the above
10 copyright notice, this list of conditions and the
11 following disclaimer.
12
13 * Redistributions in binary form must reproduce the
14 above copyright notice, this list of conditions
15 and the following disclaimer in the documentation
16 and/or other materials provided with the distribution.
17
18 * Neither the name of the University of Illinois
19 nor the names of its contributors may be used to
20 endorse or promote products derived from this
21 software without specific prior written permission.
22
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
24 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
25 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
27 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 *****************************************************************************/
35
36 /*****************************************************************************
37 written by
38 Yunhong Gu, last updated 01/27/2011
39 *****************************************************************************/
40
41 #ifndef __UDT_CACHE_H__
42 #define __UDT_CACHE_H__
43
44 #include "udt.h"
45 #include "common.h"
46 #include <list>
47 #include <vector>
48
49
50 class CCacheItem
51 {
52 public:
53 virtual ~CCacheItem() {}
54
55 public:
56 virtual CCacheItem& operator=(CCacheItem&) {return *this;}
57 virtual bool operator==(CCacheItem&) {return false;}
58
59 // Functionality:
60 // get a deep copy clone of the current item
61 // Parameters:
62 // None.
63 // Returned value:
64 // Pointer to the new item, or NULL if failed.
65
66 virtual CCacheItem* clone() {return NULL;}
67
68 // Functionality:
69 // get a random key value between 0 and MAX_INT to be used for the hash in cache
70 // Parameters:
71 // None.
72 // Returned value:
73 // A random hash key.
74
75 virtual int getKey() {return 0;}
76 };
77
78 class CCache
79 {
80 public:
81 CCache(const int& size = 1024);
82 ~CCache();
83
84 public:
85
86 // Functionality:
87 // find the matching item in the cache.
88 // Parameters:
89 // 0) [in/out] data: storage for the retrieved item; initially it must carry the key information
90 // Returned value:
91 // 0 if found a match, otherwise -1.
92
93 int lookup(CCacheItem* data);
94
95 // Functionality:
96 // update an item in the cache, or insert on if it doesn't exist; oldes t item may be removed
97 // Parameters:
98 // 0) [in] data: the new item to updated/inserted to the cache
99 // Returned value:
100 // 0 if success, otherwise -1.
101
102 int update(CCacheItem* data);
103
104 private:
105 std::list<CCacheItem*> m_StorageList;
106 std::vector< std::list<std::list<CCacheItem*>::iterator> > m_vHashPtr;
107
108 int m_iMaxSize;
109 int m_iHashSize;
110 int m_iCurrSize;
111
112 pthread_mutex_t m_Lock;
113
114 private:
115 CCache(const CCache&);
116 CCache& operator=(const CCache&);
117 };
118
119
120 class CInfoBlock: public CCacheItem
121 {
122 public:
123 uint32_t m_piIP[4]; // IP address, machine read only, not human read able format
124 int m_iIPversion; // IP version
125 uint64_t m_ullTimeStamp; // last update time
126 int m_iRTT; // RTT
127 int m_iBandwidth; // estimated bandwidth
128 int m_iLossRate; // average loss rate
129 int m_iReorderDistance; // packet reordering distance
130 double m_dInterval; // inter-packet time, congestion control
131 double m_dCWnd; // congestion window size, congestion control
132
133 public:
134 virtual CInfoBlock& operator=(CCacheItem& obj);
135 virtual bool operator==(CCacheItem& obj);
136 virtual CInfoBlock* clone();
137 virtual int getKey();
138
139 public:
140
141 // Functionality:
142 // convert sockaddr structure to an integer array
143 // Parameters:
144 // 0) [in] addr: network address
145 // 1) [in] ver: IP version
146 // 2) [out] ip: the result machine readable IP address in integer array
147 // Returned value:
148 // None.
149
150 static void convert(const sockaddr* addr, const int& ver, uint32_t ip[]);
151 };
152
153
154 #endif
OLDNEW
« no previous file with comments | « net/third_party/udt/src/buffer.cpp ('k') | net/third_party/udt/src/cache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698