libktorrent  2.2.0
downloadthread.h
1 /***************************************************************************
2  * Copyright (C) 2005 by Joris Guisson *
3  * joris.guisson@gmail.com *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 #ifndef NETDOWNLOADTHREAD_H
21 #define NETDOWNLOADTHREAD_H
22 
23 #include <vector>
24 #include <net/networkthread.h>
25 #include <net/wakeuppipe.h>
26 
27 namespace net
28 {
29 
35  class DownloadThread : public NetworkThread
36  {
37  public:
38  DownloadThread(SocketMonitor* sm);
39  ~DownloadThread() override;
40 
42  void wakeUp();
43 
45  static void setCap(bt::Uint32 cap) {dcap = cap;}
46 
48  static Uint32 cap() {return dcap;}
49 
51  static void setSleepTime(bt::Uint32 stime);
52  private:
53  void update() override;
54  bool doGroup(SocketGroup* g,Uint32 & allowance,bt::TimeStamp now) override;
55  int waitForSocketReady();
56 
57  private:
58  WakeUpPipe::Ptr wake_up;
59 
60  static bt::Uint32 dcap;
61  static bt::Uint32 sleep_time;
62  };
63 
64 }
65 
66 #endif
net::DownloadThread::setCap
static void setCap(bt::Uint32 cap)
Set the download cap.
Definition: downloadthread.h:81
net::DownloadThread::wakeUp
void wakeUp()
Wake up the download thread.
net::SocketGroup
Definition: socketgroup.h:54
net::DownloadThread::cap
static Uint32 cap()
Get the download cap.
Definition: downloadthread.h:84
net::DownloadThread::setSleepTime
static void setSleepTime(bt::Uint32 stime)
Set the sleep time when using download caps.