2009-04-23 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Removed RequestGroupAware
	* src/AbstractCommand.cc
	* src/AbstractCommand.h
	* src/ActivePeerConnectionCommand.cc
	* src/ActivePeerConnectionCommand.h
	* src/DHTGetPeersCommand.cc
	* src/DHTGetPeersCommand.h
	* src/InitiatorMSEHandshakeCommand.cc
	* src/InitiatorMSEHandshakeCommand.h
	* src/Makefile.am
	* src/PeerInitiateConnectionCommand.cc
	* src/PeerInitiateConnectionCommand.h
	* src/PeerInteractionCommand.cc
	* src/PeerInteractionCommand.h
	* src/RealtimeCommand.cc
	* src/RealtimeCommand.h
	* src/RequestGroupAware.cc: Removed
	* src/RequestGroupAware.h: Removed
	* src/SeedCheckCommand.cc
	* src/SeedCheckCommand.h
	* src/SleepCommand.cc
	* src/TrackerWatcherCommand.cc
	* src/TrackerWatcherCommand.h
pull/1/head
Tatsuhiro Tsujikawa 2009-04-23 15:00:09 +00:00
parent 6703097652
commit 3955054837
24 changed files with 120 additions and 174 deletions

View File

@ -1,3 +1,29 @@
2009-04-23 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Removed RequestGroupAware
* src/AbstractCommand.cc
* src/AbstractCommand.h
* src/ActivePeerConnectionCommand.cc
* src/ActivePeerConnectionCommand.h
* src/DHTGetPeersCommand.cc
* src/DHTGetPeersCommand.h
* src/InitiatorMSEHandshakeCommand.cc
* src/InitiatorMSEHandshakeCommand.h
* src/Makefile.am
* src/PeerInitiateConnectionCommand.cc
* src/PeerInitiateConnectionCommand.h
* src/PeerInteractionCommand.cc
* src/PeerInteractionCommand.h
* src/RealtimeCommand.cc
* src/RealtimeCommand.h
* src/RequestGroupAware.cc: Removed
* src/RequestGroupAware.h: Removed
* src/SeedCheckCommand.cc
* src/SeedCheckCommand.h
* src/SleepCommand.cc
* src/TrackerWatcherCommand.cc
* src/TrackerWatcherCommand.h
2009-04-23 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> 2009-04-23 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Rewritten PeerListProcessor Rewritten PeerListProcessor

View File

@ -70,7 +70,7 @@ AbstractCommand::AbstractCommand(int32_t cuid,
RequestGroup* requestGroup, RequestGroup* requestGroup,
DownloadEngine* e, DownloadEngine* e,
const SocketHandle& s): const SocketHandle& s):
Command(cuid), RequestGroupAware(requestGroup), Command(cuid), _requestGroup(requestGroup),
req(req), e(e), socket(s), req(req), e(e), socket(s),
checkSocketIsReadable(false), checkSocketIsWritable(false), checkSocketIsReadable(false), checkSocketIsWritable(false),
nameResolverCheck(false) nameResolverCheck(false)
@ -80,6 +80,7 @@ AbstractCommand::AbstractCommand(int32_t cuid,
} }
timeout = _requestGroup->getTimeout(); timeout = _requestGroup->getTimeout();
_requestGroup->increaseStreamConnection(); _requestGroup->increaseStreamConnection();
_requestGroup->increaseNumCommand();
} }
AbstractCommand::~AbstractCommand() { AbstractCommand::~AbstractCommand() {
@ -88,6 +89,7 @@ AbstractCommand::~AbstractCommand() {
#ifdef ENABLE_ASYNC_DNS #ifdef ENABLE_ASYNC_DNS
disableNameResolverCheck(_asyncNameResolver); disableNameResolverCheck(_asyncNameResolver);
#endif // ENABLE_ASYNC_DNS #endif // ENABLE_ASYNC_DNS
_requestGroup->decreaseNumCommand();
_requestGroup->decreaseStreamConnection(); _requestGroup->decreaseStreamConnection();
} }

View File

@ -38,7 +38,6 @@
#include "Command.h" #include "Command.h"
#include "SharedHandle.h" #include "SharedHandle.h"
#include "TimeA2.h" #include "TimeA2.h"
#include "RequestGroupAware.h"
namespace aria2 { namespace aria2 {
@ -52,11 +51,12 @@ class SocketCore;
class AsyncNameResolver; class AsyncNameResolver;
#endif // ENABLE_ASYNC_DNS #endif // ENABLE_ASYNC_DNS
class AbstractCommand : public Command, public RequestGroupAware { class AbstractCommand : public Command {
private: private:
Time checkPoint; Time checkPoint;
time_t timeout; time_t timeout;
protected: protected:
RequestGroup* _requestGroup;
SharedHandle<Request> req; SharedHandle<Request> req;
DownloadEngine* e; DownloadEngine* e;
SharedHandle<SocketCore> socket; SharedHandle<SocketCore> socket;

View File

@ -59,7 +59,7 @@ ActivePeerConnectionCommand::ActivePeerConnectionCommand
time_t interval) time_t interval)
: :
Command(cuid), Command(cuid),
RequestGroupAware(requestGroup), _requestGroup(requestGroup),
_btContext(btContext), _btContext(btContext),
interval(interval), interval(interval),
e(e), e(e),
@ -71,9 +71,13 @@ ActivePeerConnectionCommand::ActivePeerConnectionCommand
if(maxDownloadSpeed > 0) { if(maxDownloadSpeed > 0) {
_thresholdSpeed = std::min(maxDownloadSpeed, _thresholdSpeed); _thresholdSpeed = std::min(maxDownloadSpeed, _thresholdSpeed);
} }
_requestGroup->increaseNumCommand();
} }
ActivePeerConnectionCommand::~ActivePeerConnectionCommand() {} ActivePeerConnectionCommand::~ActivePeerConnectionCommand()
{
_requestGroup->decreaseNumCommand();
}
bool ActivePeerConnectionCommand::execute() { bool ActivePeerConnectionCommand::execute() {
if(_btRuntime->isHalt()) { if(_btRuntime->isHalt()) {

View File

@ -37,11 +37,11 @@
#include "Command.h" #include "Command.h"
#include "SharedHandle.h" #include "SharedHandle.h"
#include "RequestGroupAware.h"
#include "TimeA2.h" #include "TimeA2.h"
namespace aria2 { namespace aria2 {
class RequestGroup;
class DownloadEngine; class DownloadEngine;
class Peer; class Peer;
class BtContext; class BtContext;
@ -50,10 +50,9 @@ class PieceStorage;
class PeerStorage; class PeerStorage;
class BtAnnounce; class BtAnnounce;
class ActivePeerConnectionCommand : public Command, class ActivePeerConnectionCommand : public Command {
public RequestGroupAware
{
private: private:
RequestGroup* _requestGroup;
SharedHandle<BtContext> _btContext; SharedHandle<BtContext> _btContext;
SharedHandle<BtRuntime> _btRuntime; SharedHandle<BtRuntime> _btRuntime;
SharedHandle<PieceStorage> _pieceStorage; SharedHandle<PieceStorage> _pieceStorage;
@ -72,9 +71,9 @@ public:
DownloadEngine* e, DownloadEngine* e,
const SharedHandle<BtContext>& btContext, const SharedHandle<BtContext>& btContext,
time_t interval); time_t interval);
virtual ~ActivePeerConnectionCommand();
virtual ~ActivePeerConnectionCommand();
virtual bool execute(); virtual bool execute();
void connectToPeer(const SharedHandle<Peer>& peer); void connectToPeer(const SharedHandle<Peer>& peer);

View File

@ -53,14 +53,19 @@ DHTGetPeersCommand::DHTGetPeersCommand(int32_t cuid,
DownloadEngine* e, DownloadEngine* e,
const BtContextHandle& ctx): const BtContextHandle& ctx):
Command(cuid), Command(cuid),
RequestGroupAware(requestGroup), _requestGroup(requestGroup),
_btContext(ctx), _btContext(ctx),
_e(e), _e(e),
_numRetry(0), _numRetry(0),
_lastGetPeerTime(0) _lastGetPeerTime(0)
{} {
_requestGroup->increaseNumCommand();
}
DHTGetPeersCommand::~DHTGetPeersCommand() {} DHTGetPeersCommand::~DHTGetPeersCommand()
{
_requestGroup->decreaseNumCommand();
}
bool DHTGetPeersCommand::execute() bool DHTGetPeersCommand::execute()
{ {

View File

@ -36,12 +36,12 @@
#define _D_DHT_GET_PEERS_COMMAND_H_ #define _D_DHT_GET_PEERS_COMMAND_H_
#include "Command.h" #include "Command.h"
#include "RequestGroupAware.h"
#include "SharedHandle.h" #include "SharedHandle.h"
#include "TimeA2.h" #include "TimeA2.h"
namespace aria2 { namespace aria2 {
class RequestGroup;
class DHTTaskQueue; class DHTTaskQueue;
class DHTTaskFactory; class DHTTaskFactory;
class DHTTask; class DHTTask;
@ -51,9 +51,7 @@ class BtContext;
class BtRuntime; class BtRuntime;
class PeerStorage; class PeerStorage;
class DHTGetPeersCommand:public Command, class DHTGetPeersCommand:public Command {
public RequestGroupAware
{
private: private:
static const time_t GET_PEER_INTERVAL = (15*60); static const time_t GET_PEER_INTERVAL = (15*60);
@ -61,6 +59,8 @@ private:
static const size_t MAX_RETRIES = 10; static const size_t MAX_RETRIES = 10;
RequestGroup* _requestGroup;
SharedHandle<BtContext> _btContext; SharedHandle<BtContext> _btContext;
SharedHandle<BtRuntime> _btRuntime; SharedHandle<BtRuntime> _btRuntime;

View File

@ -51,6 +51,7 @@
#include "MSEHandshake.h" #include "MSEHandshake.h"
#include "ARC4Encryptor.h" #include "ARC4Encryptor.h"
#include "ARC4Decryptor.h" #include "ARC4Decryptor.h"
#include "RequestGroup.h"
namespace aria2 { namespace aria2 {
@ -64,7 +65,7 @@ InitiatorMSEHandshakeCommand::InitiatorMSEHandshakeCommand
const SharedHandle<SocketCore>& s): const SharedHandle<SocketCore>& s):
PeerAbstractCommand(cuid, p, e, s), PeerAbstractCommand(cuid, p, e, s),
RequestGroupAware(requestGroup), _requestGroup(requestGroup),
_btContext(btContext), _btContext(btContext),
_btRuntime(btRuntime), _btRuntime(btRuntime),
_sequence(INITIATOR_SEND_KEY), _sequence(INITIATOR_SEND_KEY),
@ -75,10 +76,12 @@ InitiatorMSEHandshakeCommand::InitiatorMSEHandshakeCommand
setTimeout(e->option->getAsInt(PREF_PEER_CONNECTION_TIMEOUT)); setTimeout(e->option->getAsInt(PREF_PEER_CONNECTION_TIMEOUT));
_btRuntime->increaseConnections(); _btRuntime->increaseConnections();
_requestGroup->increaseNumCommand();
} }
InitiatorMSEHandshakeCommand::~InitiatorMSEHandshakeCommand() InitiatorMSEHandshakeCommand::~InitiatorMSEHandshakeCommand()
{ {
_requestGroup->decreaseNumCommand();
_btRuntime->decreaseConnections(); _btRuntime->decreaseConnections();
delete _mseHandshake; delete _mseHandshake;

View File

@ -36,19 +36,17 @@
#define _D_INITIATOR_MSE_HANDSHAKE_COMMAND_H_ #define _D_INITIATOR_MSE_HANDSHAKE_COMMAND_H_
#include "PeerAbstractCommand.h" #include "PeerAbstractCommand.h"
#include "RequestGroupAware.h"
namespace aria2 { namespace aria2 {
class RequestGroup;
class BtContext; class BtContext;
class PeerStorage; class PeerStorage;
class PieceStorage; class PieceStorage;
class BtRuntime; class BtRuntime;
class MSEHandshake; class MSEHandshake;
class InitiatorMSEHandshakeCommand : public PeerAbstractCommand, class InitiatorMSEHandshakeCommand : public PeerAbstractCommand {
public RequestGroupAware
{
public: public:
enum Seq { enum Seq {
INITIATOR_SEND_KEY, INITIATOR_SEND_KEY,
@ -60,6 +58,8 @@ public:
INITIATOR_RECEIVE_PAD_D, INITIATOR_RECEIVE_PAD_D,
}; };
private: private:
RequestGroup* _requestGroup;
SharedHandle<BtContext> _btContext; SharedHandle<BtContext> _btContext;
SharedHandle<PeerStorage> _peerStorage; SharedHandle<PeerStorage> _peerStorage;

View File

@ -82,7 +82,6 @@ SRCS = Socket.h\
NameMatchOptionHandler.h\ NameMatchOptionHandler.h\
NameResolver.cc NameResolver.h\ NameResolver.cc NameResolver.h\
RequestGroup.cc RequestGroup.h\ RequestGroup.cc RequestGroup.h\
RequestGroupAware.cc RequestGroupAware.h\
RequestGroupMan.cc RequestGroupMan.h\ RequestGroupMan.cc RequestGroupMan.h\
FileAllocationMan.h\ FileAllocationMan.h\
FileAllocationCommand.cc FileAllocationCommand.h\ FileAllocationCommand.cc FileAllocationCommand.h\

View File

@ -333,9 +333,8 @@ am__libaria2c_a_SOURCES_DIST = Socket.h SocketCore.cc SocketCore.h \
OptionHandlerFactory.cc OptionHandlerFactory.h \ OptionHandlerFactory.cc OptionHandlerFactory.h \
OptionHandler.cc OptionHandler.h OptionHandlerImpl.h \ OptionHandler.cc OptionHandler.h OptionHandlerImpl.h \
NameMatchOptionHandler.h NameResolver.cc NameResolver.h \ NameMatchOptionHandler.h NameResolver.cc NameResolver.h \
RequestGroup.cc RequestGroup.h RequestGroupAware.cc \ RequestGroup.cc RequestGroup.h RequestGroupMan.cc \
RequestGroupAware.h RequestGroupMan.cc RequestGroupMan.h \ RequestGroupMan.h FileAllocationMan.h FileAllocationCommand.cc \
FileAllocationMan.h FileAllocationCommand.cc \
FileAllocationCommand.h FillRequestGroupCommand.cc \ FileAllocationCommand.h FillRequestGroupCommand.cc \
FillRequestGroupCommand.h FileAllocationDispatcherCommand.cc \ FillRequestGroupCommand.h FileAllocationDispatcherCommand.cc \
FileAllocationDispatcherCommand.h FileAllocationEntry.cc \ FileAllocationDispatcherCommand.h FileAllocationEntry.cc \
@ -760,8 +759,7 @@ am__objects_23 = SocketCore.$(OBJEXT) Command.$(OBJEXT) \
AuthConfigFactory.$(OBJEXT) OptionParser.$(OBJEXT) \ AuthConfigFactory.$(OBJEXT) OptionParser.$(OBJEXT) \
OptionHandlerFactory.$(OBJEXT) OptionHandler.$(OBJEXT) \ OptionHandlerFactory.$(OBJEXT) OptionHandler.$(OBJEXT) \
NameResolver.$(OBJEXT) RequestGroup.$(OBJEXT) \ NameResolver.$(OBJEXT) RequestGroup.$(OBJEXT) \
RequestGroupAware.$(OBJEXT) RequestGroupMan.$(OBJEXT) \ RequestGroupMan.$(OBJEXT) FileAllocationCommand.$(OBJEXT) \
FileAllocationCommand.$(OBJEXT) \
FillRequestGroupCommand.$(OBJEXT) \ FillRequestGroupCommand.$(OBJEXT) \
FileAllocationDispatcherCommand.$(OBJEXT) \ FileAllocationDispatcherCommand.$(OBJEXT) \
FileAllocationEntry.$(OBJEXT) \ FileAllocationEntry.$(OBJEXT) \
@ -1066,9 +1064,8 @@ SRCS = Socket.h SocketCore.cc SocketCore.h BinaryStream.h Command.cc \
OptionHandlerFactory.cc OptionHandlerFactory.h \ OptionHandlerFactory.cc OptionHandlerFactory.h \
OptionHandler.cc OptionHandler.h OptionHandlerImpl.h \ OptionHandler.cc OptionHandler.h OptionHandlerImpl.h \
NameMatchOptionHandler.h NameResolver.cc NameResolver.h \ NameMatchOptionHandler.h NameResolver.cc NameResolver.h \
RequestGroup.cc RequestGroup.h RequestGroupAware.cc \ RequestGroup.cc RequestGroup.h RequestGroupMan.cc \
RequestGroupAware.h RequestGroupMan.cc RequestGroupMan.h \ RequestGroupMan.h FileAllocationMan.h FileAllocationCommand.cc \
FileAllocationMan.h FileAllocationCommand.cc \
FileAllocationCommand.h FillRequestGroupCommand.cc \ FileAllocationCommand.h FillRequestGroupCommand.cc \
FillRequestGroupCommand.h FileAllocationDispatcherCommand.cc \ FillRequestGroupCommand.h FileAllocationDispatcherCommand.cc \
FileAllocationDispatcherCommand.h FileAllocationEntry.cc \ FileAllocationDispatcherCommand.h FileAllocationEntry.cc \
@ -1481,7 +1478,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ReceiverMSEHandshakeCommand.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ReceiverMSEHandshakeCommand.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Request.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Request.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestGroup.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestGroup.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestGroupAware.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestGroupEntry.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestGroupEntry.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestGroupMan.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestGroupMan.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestSlot.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestSlot.Po@am__quote@

View File

@ -47,6 +47,7 @@
#include "PeerStorage.h" #include "PeerStorage.h"
#include "PieceStorage.h" #include "PieceStorage.h"
#include "PeerConnection.h" #include "PeerConnection.h"
#include "RequestGroup.h"
namespace aria2 { namespace aria2 {
@ -60,16 +61,18 @@ PeerInitiateConnectionCommand::PeerInitiateConnectionCommand
bool mseHandshakeEnabled) bool mseHandshakeEnabled)
: :
PeerAbstractCommand(cuid, peer, e), PeerAbstractCommand(cuid, peer, e),
RequestGroupAware(requestGroup), _requestGroup(requestGroup),
_btContext(btContext), _btContext(btContext),
_btRuntime(btRuntime), _btRuntime(btRuntime),
_mseHandshakeEnabled(mseHandshakeEnabled) _mseHandshakeEnabled(mseHandshakeEnabled)
{ {
_btRuntime->increaseConnections(); _btRuntime->increaseConnections();
_requestGroup->increaseNumCommand();
} }
PeerInitiateConnectionCommand::~PeerInitiateConnectionCommand() PeerInitiateConnectionCommand::~PeerInitiateConnectionCommand()
{ {
_requestGroup->decreaseNumCommand();
_btRuntime->decreaseConnections(); _btRuntime->decreaseConnections();
} }

View File

@ -36,19 +36,19 @@
#define _D_PEER_INITIATE_CONNECTION_H_ #define _D_PEER_INITIATE_CONNECTION_H_
#include "PeerAbstractCommand.h" #include "PeerAbstractCommand.h"
#include "RequestGroupAware.h"
namespace aria2 { namespace aria2 {
class RequestGroup;
class BtContext; class BtContext;
class BtRuntime; class BtRuntime;
class PeerStorage; class PeerStorage;
class PieceStorage; class PieceStorage;
class PeerInitiateConnectionCommand : public PeerAbstractCommand, class PeerInitiateConnectionCommand : public PeerAbstractCommand {
public RequestGroupAware
{
private: private:
RequestGroup* _requestGroup;
SharedHandle<BtContext> _btContext; SharedHandle<BtContext> _btContext;
SharedHandle<BtRuntime> _btRuntime; SharedHandle<BtRuntime> _btRuntime;

View File

@ -84,7 +84,7 @@ PeerInteractionCommand::PeerInteractionCommand
Seq sequence, Seq sequence,
const PeerConnectionHandle& passedPeerConnection) const PeerConnectionHandle& passedPeerConnection)
:PeerAbstractCommand(cuid, p, e, s), :PeerAbstractCommand(cuid, p, e, s),
RequestGroupAware(requestGroup), _requestGroup(requestGroup),
_btContext(btContext), _btContext(btContext),
_btRuntime(btRuntime), _btRuntime(btRuntime),
_pieceStorage(pieceStorage), _pieceStorage(pieceStorage),
@ -193,6 +193,7 @@ PeerInteractionCommand::PeerInteractionCommand
maxDownloadSpeedLimit = e->option->getAsInt(PREF_MAX_DOWNLOAD_LIMIT); maxDownloadSpeedLimit = e->option->getAsInt(PREF_MAX_DOWNLOAD_LIMIT);
_btRuntime->increaseConnections(); _btRuntime->increaseConnections();
_requestGroup->increaseNumCommand();
} }
PeerInteractionCommand::~PeerInteractionCommand() { PeerInteractionCommand::~PeerInteractionCommand() {
@ -201,7 +202,8 @@ PeerInteractionCommand::~PeerInteractionCommand() {
peer->getBitfieldLength()); peer->getBitfieldLength());
} }
peer->releaseSessionResource(); peer->releaseSessionResource();
_requestGroup->decreaseNumCommand();
_btRuntime->decreaseConnections(); _btRuntime->decreaseConnections();
//logger->debug("CUID#%d - unregistered message factory using ID:%s", //logger->debug("CUID#%d - unregistered message factory using ID:%s",
//cuid, peer->getId().c_str()); //cuid, peer->getId().c_str());

View File

@ -36,10 +36,10 @@
#define _D_PEER_INTERACTION_COMMAND_H_ #define _D_PEER_INTERACTION_COMMAND_H_
#include "PeerAbstractCommand.h" #include "PeerAbstractCommand.h"
#include "RequestGroupAware.h"
namespace aria2 { namespace aria2 {
class RequestGroup;
class BtContext; class BtContext;
class BtInteractive; class BtInteractive;
class PeerConnection; class PeerConnection;
@ -47,9 +47,7 @@ class BtRuntime;
class PeerStorage; class PeerStorage;
class PieceStorage; class PieceStorage;
class PeerInteractionCommand : public PeerAbstractCommand, class PeerInteractionCommand : public PeerAbstractCommand {
public RequestGroupAware
{
public: public:
enum Seq { enum Seq {
INITIATOR_SEND_HANDSHAKE, INITIATOR_SEND_HANDSHAKE,
@ -57,6 +55,8 @@ public:
RECEIVER_WAIT_HANDSHAKE, RECEIVER_WAIT_HANDSHAKE,
WIRED}; WIRED};
private: private:
RequestGroup* _requestGroup;
SharedHandle<BtContext> _btContext; SharedHandle<BtContext> _btContext;
SharedHandle<BtRuntime> _btRuntime; SharedHandle<BtRuntime> _btRuntime;

View File

@ -35,16 +35,24 @@
#include "RealtimeCommand.h" #include "RealtimeCommand.h"
#include "DownloadEngine.h" #include "DownloadEngine.h"
#include "Exception.h" #include "Exception.h"
#include "RequestGroup.h"
namespace aria2 { namespace aria2 {
RealtimeCommand::RealtimeCommand(int cuid, RequestGroup* requestGroup, RealtimeCommand::RealtimeCommand(int cuid, RequestGroup* requestGroup,
DownloadEngine* e): DownloadEngine* e):
Command(cuid), Command(cuid),
RequestGroupAware(requestGroup), _requestGroup(requestGroup),
_e(e) _e(e)
{ {
setStatusRealtime(); setStatusRealtime();
_requestGroup->increaseNumCommand();
}
RealtimeCommand::~RealtimeCommand()
{
_requestGroup->decreaseNumCommand();
} }
bool RealtimeCommand::execute() bool RealtimeCommand::execute()

View File

@ -36,20 +36,21 @@
#define _D_REALTIME_COMMAND_H_ #define _D_REALTIME_COMMAND_H_
#include "Command.h" #include "Command.h"
#include "RequestGroupAware.h"
namespace aria2 { namespace aria2 {
class RequestGroup;
class DownloadEngine; class DownloadEngine;
class Exception; class Exception;
class RealtimeCommand : public Command, public RequestGroupAware { class RealtimeCommand : public Command {
protected: protected:
RequestGroup* _requestGroup;
DownloadEngine* _e; DownloadEngine* _e;
public: public:
RealtimeCommand(int cuid, RequestGroup* requestGroup, DownloadEngine* e); RealtimeCommand(int cuid, RequestGroup* requestGroup, DownloadEngine* e);
virtual ~RealtimeCommand() {} virtual ~RealtimeCommand();
virtual bool execute(); virtual bool execute();

View File

@ -1,56 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#include "RequestGroupAware.h"
#include "RequestGroup.h"
namespace aria2 {
RequestGroupAware::RequestGroupAware(RequestGroup* requestGroup):
_requestGroup(requestGroup)
{
_requestGroup->increaseNumCommand();
}
RequestGroupAware::~RequestGroupAware()
{
_requestGroup->decreaseNumCommand();
}
RequestGroup* RequestGroupAware::getRequestGroup() const
{
return _requestGroup;
}
} // namespace aria2

View File

@ -1,57 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#ifndef _D_REQUEST_GROUP_AWARE_H_
#define _D_REQUEST_GROUP_AWARE_H_
#include "common.h"
namespace aria2 {
class RequestGroup;
class RequestGroupAware {
protected:
RequestGroup* _requestGroup;
public:
RequestGroupAware(RequestGroup* requestGroup);
~RequestGroupAware();
RequestGroup* getRequestGroup() const;
};
} // namespace aria2
#endif // _D_REQUEST_GROUP_AWARE_H_

View File

@ -40,6 +40,7 @@
#include "Logger.h" #include "Logger.h"
#include "SeedCriteria.h" #include "SeedCriteria.h"
#include "message.h" #include "message.h"
#include "RequestGroup.h"
namespace aria2 { namespace aria2 {
@ -49,13 +50,19 @@ SeedCheckCommand::SeedCheckCommand(int cuid,
const SharedHandle<BtContext>& btContext, const SharedHandle<BtContext>& btContext,
const SeedCriteriaHandle& seedCriteria) const SeedCriteriaHandle& seedCriteria)
:Command(cuid), :Command(cuid),
RequestGroupAware(requestGroup), _requestGroup(requestGroup),
e(e), e(e),
_btContext(btContext), _btContext(btContext),
seedCriteria(seedCriteria), seedCriteria(seedCriteria),
checkStarted(false) checkStarted(false)
{ {
setStatusRealtime(); setStatusRealtime();
_requestGroup->increaseNumCommand();
}
SeedCheckCommand::~SeedCheckCommand()
{
_requestGroup->decreaseNumCommand();
} }
bool SeedCheckCommand::execute() { bool SeedCheckCommand::execute() {

View File

@ -37,20 +37,20 @@
#include "Command.h" #include "Command.h"
#include "SharedHandle.h" #include "SharedHandle.h"
#include "RequestGroupAware.h"
namespace aria2 { namespace aria2 {
class RequestGroup;
class DownloadEngine; class DownloadEngine;
class SeedCriteria; class SeedCriteria;
class BtContext; class BtContext;
class BtRuntime; class BtRuntime;
class PieceStorage; class PieceStorage;
class SeedCheckCommand : public Command, class SeedCheckCommand : public Command
public RequestGroupAware
{ {
private: private:
RequestGroup* _requestGroup;
DownloadEngine* e; DownloadEngine* e;
SharedHandle<BtContext> _btContext; SharedHandle<BtContext> _btContext;
SharedHandle<PieceStorage> _pieceStorage; SharedHandle<PieceStorage> _pieceStorage;
@ -64,7 +64,7 @@ public:
const SharedHandle<BtContext>& btContext, const SharedHandle<BtContext>& btContext,
const SharedHandle<SeedCriteria>& seedCriteria); const SharedHandle<SeedCriteria>& seedCriteria);
virtual ~SeedCheckCommand() {} virtual ~SeedCheckCommand();
virtual bool execute(); virtual bool execute();

View File

@ -33,7 +33,6 @@
*/ */
/* copyright --> */ /* copyright --> */
#include "SleepCommand.h" #include "SleepCommand.h"
#include "RequestGroupAware.h"
#include "RequestGroup.h" #include "RequestGroup.h"
#include "DownloadEngine.h" #include "DownloadEngine.h"

View File

@ -67,12 +67,17 @@ TrackerWatcherCommand::TrackerWatcherCommand(int32_t cuid,
DownloadEngine* e, DownloadEngine* e,
const BtContextHandle& btContext): const BtContextHandle& btContext):
Command(cuid), Command(cuid),
RequestGroupAware(requestGroup), _requestGroup(requestGroup),
e(e), e(e),
_btContext(btContext) {} _btContext(btContext)
{
TrackerWatcherCommand::~TrackerWatcherCommand() {} _requestGroup->increaseNumCommand();
}
TrackerWatcherCommand::~TrackerWatcherCommand()
{
_requestGroup->decreaseNumCommand();
}
bool TrackerWatcherCommand::execute() { bool TrackerWatcherCommand::execute() {
if(_requestGroup->isForceHaltRequested()) { if(_requestGroup->isForceHaltRequested()) {

View File

@ -37,7 +37,6 @@
#include "Command.h" #include "Command.h"
#include "SharedHandle.h" #include "SharedHandle.h"
#include "RequestGroupAware.h"
namespace aria2 { namespace aria2 {
@ -49,10 +48,11 @@ class PieceStorage;
class BtRuntime; class BtRuntime;
class BtAnnounce; class BtAnnounce;
class TrackerWatcherCommand : public Command, class TrackerWatcherCommand : public Command
public RequestGroupAware
{ {
private: private:
RequestGroup* _requestGroup;
DownloadEngine* e; DownloadEngine* e;
SharedHandle<BtContext> _btContext; SharedHandle<BtContext> _btContext;