libktorrent  2.2.0
Signals | Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes | List of all members
dht::Task Class Referenceabstract

#include <task.h>

Inheritance diagram for dht::Task:
Inheritance graph
[legend]

Signals

void dataReady (Task *t)
 
void finished (Task *t)
 

Public Member Functions

 Task (RPCServer *rpc, Node *node, QObject *parent)
 
void addDHTNode (const QString &ip, bt::Uint16 port)
 
virtual void callFinished (RPCCall *c, RPCMsg::Ptr rsp)=0
 
virtual void callTimeout (RPCCall *c)=0
 
bool canDoRequest () const
 See if we can do a request.
 
void emitDataReady ()
 
bt::Uint32 getNumOutstandingRequests () const
 Get the number of outstanding requests.
 
bool isFinished () const
 Is the task finished.
 
bool isQueued () const
 
void kill ()
 Kills the task.
 
void onResponse (RPCCall *c, RPCMsg::Ptr rsp) override
 Decrements the outstanding_reqs.
 
void onTimeout (RPCCall *c) override
 Decrements the outstanding_reqs.
 
bool rpcCall (RPCMsg::Ptr req)
 
void start ()
 
void start (const KClosestNodesSearch &kns, bool queued)
 
virtual void update ()=0
 
- Public Member Functions inherited from dht::RPCCallListener
 RPCCallListener (QObject *parent)
 

Protected Slots

void onResolverResults (net::AddressResolver *res)
 

Protected Member Functions

void done ()
 

Protected Attributes

Nodenode
 
dht::KBucketEntrySet todo
 
dht::KBucketEntrySet visited
 

Additional Inherited Members

- Public Slots inherited from dht::RPCCallListener

Detailed Description

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

Performs a task on K nodes provided by a KClosestNodesSearch. This is a base class for all tasks.

Definition at line 46 of file task.h.

Constructor & Destructor Documentation

◆ Task()

dht::Task::Task ( RPCServer rpc,
Node node,
QObject *  parent 
)

Create a task.

Parameters
rpcThe RPC server to do RPC calls
nodeThe node
parentThe parent object

Member Function Documentation

◆ addDHTNode()

void dht::Task::addDHTNode ( const QString &  ip,
bt::Uint16  port 
)

Add a node to the todo list

Parameters
ipThe ip or hostname of the node
portThe port

◆ callFinished()

virtual void dht::Task::callFinished ( RPCCall c,
RPCMsg::Ptr  rsp 
)
pure virtual

A call is finished and a response was received.

Parameters
cThe call
rspThe response

Implemented in dht::NodeLookup, and dht::AnnounceTask.

◆ callTimeout()

virtual void dht::Task::callTimeout ( RPCCall c)
pure virtual

A call timedout

Parameters
cThe call

Implemented in dht::NodeLookup, and dht::AnnounceTask.

◆ dataReady

void dht::Task::dataReady ( Task t)
signal

Called by the task when data is ready. Can be overrided if wanted.

Parameters
tThe Task

◆ emitDataReady()

void dht::Task::emitDataReady ( )

Tell listeners data is ready.

◆ finished

void dht::Task::finished ( Task t)
signal

The task is finsihed.

Parameters
tThe Task

◆ rpcCall()

bool dht::Task::rpcCall ( RPCMsg::Ptr  req)

Do a call to the rpc server, increments the outstanding_reqs variable.

Parameters
reqTHe request to send
Returns
true if call was made, false if not

◆ start() [1/2]

void dht::Task::start ( )

Start the task, to be used when a task is queued.

◆ start() [2/2]

void dht::Task::start ( const KClosestNodesSearch kns,
bool  queued 
)

This will copy the results from the KClosestNodesSearch object into the todo list. And call update if the task is not queued.

Parameters
knsThe KClosestNodesSearch object
queuedIs the task queued

◆ update()

virtual void dht::Task::update ( )
pure virtual

Will continue the task, this will be called every time we have rpc slots available for this task. Should be implemented by derived classes.

Implemented in dht::NodeLookup, and dht::AnnounceTask.


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