1 
2 /***************************************************************************
3  *  speedctrl.h
4  *
5  *  Wed Sep  6 22:19:52 2006
6  *  Copyright  2006  liubin,China
7  *  Email multiget@gmail.com
8  ****************************************************************************/
9 
10 /*
11  *  This program is free software; you can redistribute it and/or modify
12  *  it under the terms of the GNU General Public License as published by
13  *  the Free Software Foundation; either version 2 of the License, or
14  *  (at your option) any later version.
15  *
16  *  This program is distributed in the hope that it will be useful,
17  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  *  GNU General Public License for more details.
20  *
21  *  You should have received a copy of the GNU General Public License
22  *  along with this program; if not, write to the Free Software
23  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24  */
25 
26 #ifndef _SPEED_CTRL_H
27 #define _SPEED_CTRL_H
28 #include "common.h"
29 #include <pthread.h>
30 #ifndef WIN32
31 #include <sys/time.h>
32 #include <unistd.h>
33 #endif
34 
35 #include <list>
36 
37 class CSpeedCtrl
38 {
39 
40     struct _ss
41     {
42         llong bytes;  //data bytes
43 
44         struct timeval tti;  //time
45     };
46 
47 public:
48     CSpeedCtrl();
49     ~CSpeedCtrl();
50     int DataIn( int len );
51     void Init();
52 
53 protected:
54 
55     pthread_mutex_t m_mutex;
56     //	struct timeval last, thistime;
57 #ifndef WIN32
58     struct timezone m_tz;
59 #endif
60     //	int m_packet;
61 
62     std::list<_ss> m_list;
63 };
64 
65 #endif
66 
67