libktorrent  2.1.1
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
net::NetworkThread Class Referenceabstract

#include <networkthread.h>

Inheritance diagram for net::NetworkThread:
Inheritance graph
[legend]

Public Member Functions

 NetworkThread (SocketMonitor *sm)
 
void addGroup (Uint32 gid, Uint32 limit, Uint32 assured_rate)
 
virtual bool doGroup (SocketGroup *g, Uint32 &allowance, bt::TimeStamp now)=0
 
bool isRunning () const
 Is the thread running.
 
void removeGroup (Uint32 gid)
 
void run () override
 
void setGroupAssuredRate (Uint32 gid, Uint32 as)
 
void setGroupLimit (Uint32 gid, Uint32 limit)
 
void stop ()
 Stop before the next update.
 
virtual void update ()=0
 
- Public Member Functions inherited from net::Poll
int add (int fd, Mode mode)
 Add a file descriptor to the poll (returns the index of it)
 
int add (PollClient::Ptr pc)
 Add a poll client.
 
int poll (int timeout=-1)
 Poll all sockets.
 
bool ready (int index, Mode mode) const
 Check if a socket at an index is read.
 
void reset ()
 Reset the poll.
 

Protected Member Functions

void doGroups (Uint32 num_ready, bt::TimeStamp now, bt::Uint32 limit)
 

Protected Attributes

bt::PtrMap< Uint32, SocketGroupgroups
 
bt::TimeStamp prev_run_time
 
bool running
 
SocketMonitorsm
 

Additional Inherited Members

- Public Types inherited from net::Poll
enum  Mode { INPUT, OUTPUT }
 

Detailed Description

Author
Joris Guisson joris.nosp@m..gui.nosp@m.sson@.nosp@m.gmai.nosp@m.l.com

Base class for the 2 networking threads. Handles the socket groups.

Definition at line 40 of file networkthread.h.

Member Function Documentation

◆ addGroup()

void net::NetworkThread::addGroup ( Uint32  gid,
Uint32  limit,
Uint32  assured_rate 
)

Add a new group with a given limit

Parameters
gidThe group ID (cannot be 0, 0 is the default group)
limitThe limit in bytes per sec
assured_rateThe assured rate for this group in bytes per second

◆ doGroup()

virtual bool net::NetworkThread::doGroup ( SocketGroup g,
Uint32 &  allowance,
bt::TimeStamp  now 
)
pure virtual

Do one SocketGroup

Parameters
gThe group
allowanceThe groups allowance
nowThe current time
Returns
true if the group can go again

◆ doGroups()

void net::NetworkThread::doGroups ( Uint32  num_ready,
bt::TimeStamp  now,
bt::Uint32  limit 
)
protected

Go over all groups and do them

Parameters
num_readyThe number of ready sockets
nowThe current time
limitThe global limit in bytes per sec

◆ removeGroup()

void net::NetworkThread::removeGroup ( Uint32  gid)

Remove a group

Parameters
gidThe group ID

◆ run()

void net::NetworkThread::run ( )
override

The main function of the thread

◆ setGroupAssuredRate()

void net::NetworkThread::setGroupAssuredRate ( Uint32  gid,
Uint32  as 
)

Set the assured rate for a group

Parameters
gidThe group ID
asThe assured rate

◆ setGroupLimit()

void net::NetworkThread::setGroupLimit ( Uint32  gid,
Uint32  limit 
)

Set the limit for a group

Parameters
gidThe group ID
limitThe limit

◆ update()

virtual void net::NetworkThread::update ( )
pure virtual

Subclasses must implement this function


The documentation for this class was generated from the following file: