📄 control.h.svn-base
字号:
/*****************************************************************************Copyright (c) 2001 - 2007, The Board of Trustees of the University of Illinois.All rights reserved.Redistribution and use in source and binary forms, with or withoutmodification, are permitted provided that the following conditions aremet:* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.* Neither the name of the University of Illinois nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "ASIS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULARPURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER ORCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, ORPROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OFLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDINGNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THISSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*****************************************************************************//*****************************************************************************written by Yunhong Gu, last updated 07/22/2007*****************************************************************************/#ifndef _UDT_CONTROL_H_#define _UDT_CONTROL_H_#include "udt.h"#include "common.h"#ifdef USING_USTL#include <ustl.h>using namespace ustl;#elseusing namespace std;#endif// !nash! have to use std version of STL as uSTL's set/map doesn't provide comparator#include <set>#include <map>class CUDT;struct CHistoryBlock{ uint32_t m_IP[4]; int m_iIPversion; uint64_t m_ullTimeStamp; int m_iRTT; int m_iBandwidth; int m_iLossRate; int m_iReorderDistance; CHistoryBlock() throw() { ::memset(this, 0, sizeof(CHistoryBlock)); }};struct CIPComp{ bool operator()(const CHistoryBlock* hb1, const CHistoryBlock* hb2) const;};struct CTSComp{ bool operator()(const CHistoryBlock* hb1, const CHistoryBlock* hb2) const;};class CHistory{public: CHistory() throw(); CHistory(const unsigned int& size) throw(); ~CHistory();public: bool construct() throw(); void update(const sockaddr* addr, const int ver, const int rtt, const int bw); void update(const CHistoryBlock* hb); int lookup(const sockaddr* addr, const int ver, CHistoryBlock* hb);private: void convert(const sockaddr* addr, const int ver, uint32_t* ip);private: unsigned int m_uiSize; std::set<CHistoryBlock*, CIPComp> m_sIPIndex; std::set<CHistoryBlock*, CTSComp> m_sTSIndex; pthread_mutex_t m_Lock;};struct CUDTComp{ bool operator()(const CUDT* u1, const CUDT* u2) const;};class CControl{public: CControl() throw(); ~CControl();public: bool construct() throw(); int join(CUDT* udt, const sockaddr* addr, const int ver, int& rtt, int& bw); void leave(CUDT* udt, const int rtt, const int bw);private: CHistory* m_pHistoryRecord; std::map<CHistoryBlock*, std::set<CUDT*, CUDTComp>, CIPComp> m_mControlBlock; std::map<CUDT*, CHistoryBlock*, CUDTComp> m_mUDTIndex; pthread_mutex_t m_Lock;};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -