mirror of https://github.com/aria2/aria2
2009-01-24 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Rewritten FileAllocationDispatcherCommand using brand new SequentialDispatcherCommand. * src/DownloadEngineFactory.cc * src/FileAllocationCommand.cc * src/FileAllocationDispatcherCommand.cc * src/FileAllocationDispatcherCommand.h * src/Makefile.am * src/SequentialDispatcherCommand.hpull/1/head
parent
8ca9db9f3e
commit
a20aa3c7e5
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2009-01-24 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Rewritten FileAllocationDispatcherCommand using brand new
|
||||
SequentialDispatcherCommand.
|
||||
* src/DownloadEngineFactory.cc
|
||||
* src/FileAllocationCommand.cc
|
||||
* src/FileAllocationDispatcherCommand.cc
|
||||
* src/FileAllocationDispatcherCommand.h
|
||||
* src/Makefile.am
|
||||
* src/SequentialDispatcherCommand.h
|
||||
|
||||
2009-01-24 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Replaced FileAllocationMan with
|
||||
|
|
|
@ -116,8 +116,8 @@ DownloadEngineFactory::newDownloadEngine(Option* op,
|
|||
e->_checkIntegrityMan.reset(new CheckIntegrityMan());
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
e->addRoutineCommand(new FillRequestGroupCommand(e->newCUID(), e.get(), 1));
|
||||
e->addRoutineCommand(new FileAllocationDispatcherCommand(e->newCUID(),
|
||||
e.get()));
|
||||
e->addRoutineCommand(new FileAllocationDispatcherCommand
|
||||
(e->newCUID(), e->_fileAllocationMan, e.get()));
|
||||
if(op->getAsInt(PREF_AUTO_SAVE_INTERVAL) > 0) {
|
||||
e->addRoutineCommand
|
||||
(new AutoSaveCommand(e->newCUID(), e.get(),
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "message.h"
|
||||
#include "prefs.h"
|
||||
#include "Util.h"
|
||||
#include "DownloadEngine.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
|
|
@ -33,9 +33,6 @@
|
|||
*/
|
||||
/* copyright --> */
|
||||
#include "FileAllocationDispatcherCommand.h"
|
||||
#include "DownloadEngine.h"
|
||||
#include "RequestGroupMan.h"
|
||||
#include "FileAllocationMan.h"
|
||||
#include "FileAllocationEntry.h"
|
||||
#include "FileAllocationCommand.h"
|
||||
#include "message.h"
|
||||
|
@ -43,35 +40,23 @@
|
|||
|
||||
namespace aria2 {
|
||||
|
||||
FileAllocationDispatcherCommand::FileAllocationDispatcherCommand(int32_t cuid, DownloadEngine* e):
|
||||
Command(cuid), _e(e)
|
||||
FileAllocationDispatcherCommand::FileAllocationDispatcherCommand
|
||||
(int32_t cuid,
|
||||
const SharedHandle<FileAllocationMan>& fileAllocMan,
|
||||
DownloadEngine* e):SequentialDispatcherCommand<FileAllocationEntry>
|
||||
(cuid, fileAllocMan, e)
|
||||
{
|
||||
setStatusRealtime();
|
||||
}
|
||||
|
||||
FileAllocationDispatcherCommand::~FileAllocationDispatcherCommand() {}
|
||||
|
||||
bool FileAllocationDispatcherCommand::execute()
|
||||
Command* FileAllocationDispatcherCommand::createCommand
|
||||
(const SharedHandle<FileAllocationEntry>& entry)
|
||||
{
|
||||
if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) {
|
||||
return true;
|
||||
}
|
||||
if(_e->_fileAllocationMan->hasNext() && !_e->_fileAllocationMan->isPicked()) {
|
||||
FileAllocationEntryHandle entry = _e->_fileAllocationMan->pickNext();
|
||||
int32_t newCUID = _e->newCUID();
|
||||
logger->info(MSG_FILE_ALLOCATION_DISPATCH, newCUID);
|
||||
FileAllocationCommand* command =
|
||||
new FileAllocationCommand(newCUID,
|
||||
entry->getRequestGroup(),
|
||||
_e,
|
||||
entry);
|
||||
_e->commands.push_back(command);
|
||||
_e->setNoWait(true);
|
||||
}
|
||||
|
||||
_e->addRoutineCommand(this);
|
||||
|
||||
return false;
|
||||
int32_t newCUID = _e->newCUID();
|
||||
logger->info(MSG_FILE_ALLOCATION_DISPATCH, newCUID);
|
||||
FileAllocationCommand* command =
|
||||
new FileAllocationCommand(newCUID, entry->getRequestGroup(), _e, entry);
|
||||
return command;
|
||||
}
|
||||
|
||||
} // namespace aria2
|
||||
|
|
|
@ -35,21 +35,23 @@
|
|||
#ifndef _D_FILE_ALLOCATION_DISPATCHER_COMMAND_H_
|
||||
#define _D_FILE_ALLOCATION_DISPATCHER_COMMAND_H_
|
||||
|
||||
#include "Command.h"
|
||||
#include "SequentialDispatcherCommand.h"
|
||||
#include "FileAllocationMan.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
class DownloadEngine;
|
||||
class FileAllocationEntry;
|
||||
|
||||
class FileAllocationDispatcherCommand : public Command {
|
||||
private:
|
||||
DownloadEngine* _e;
|
||||
class FileAllocationDispatcherCommand :
|
||||
public SequentialDispatcherCommand<FileAllocationEntry> {
|
||||
public:
|
||||
FileAllocationDispatcherCommand(int32_t cuid, DownloadEngine* e);
|
||||
|
||||
virtual ~FileAllocationDispatcherCommand();
|
||||
|
||||
virtual bool execute();
|
||||
FileAllocationDispatcherCommand
|
||||
(int32_t cuid,
|
||||
const SharedHandle<FileAllocationMan>& fileAllocMan,
|
||||
DownloadEngine* e);
|
||||
protected:
|
||||
virtual Command* createCommand
|
||||
(const SharedHandle<FileAllocationEntry>& entry);
|
||||
};
|
||||
|
||||
} // namespace aria2
|
||||
|
|
|
@ -199,7 +199,8 @@ SRCS = Socket.h\
|
|||
URIResult.cc URIResult.h\
|
||||
EventPoll.h\
|
||||
SelectEventPoll.cc SelectEventPoll.h\
|
||||
SequentialPicker.h
|
||||
SequentialPicker.h\
|
||||
SequentialDispatcherCommand.h
|
||||
|
||||
if HAVE_EPOLL
|
||||
SRCS += EpollEventPoll.cc EpollEventPoll.h
|
||||
|
|
|
@ -413,8 +413,9 @@ am__libaria2c_a_SOURCES_DIST = Socket.h SocketCore.cc SocketCore.h \
|
|||
SocketBuffer.h OptionHandlerException.cc \
|
||||
OptionHandlerException.h bencode.cc bencode.h URIResult.cc \
|
||||
URIResult.h EventPoll.h SelectEventPoll.cc SelectEventPoll.h \
|
||||
SequentialPicker.h EpollEventPoll.cc EpollEventPoll.h \
|
||||
TLSContext.h LibgnutlsTLSContext.cc LibgnutlsTLSContext.h \
|
||||
SequentialPicker.h SequentialDispatcherCommand.h \
|
||||
EpollEventPoll.cc EpollEventPoll.h TLSContext.h \
|
||||
LibgnutlsTLSContext.cc LibgnutlsTLSContext.h \
|
||||
LibsslTLSContext.cc LibsslTLSContext.h GZipDecoder.cc \
|
||||
GZipDecoder.h Sqlite3MozCookieParser.cc \
|
||||
Sqlite3MozCookieParser.h AsyncNameResolver.cc \
|
||||
|
@ -1139,14 +1140,14 @@ SRCS = Socket.h SocketCore.cc SocketCore.h BinaryStream.h Command.cc \
|
|||
SocketBuffer.h OptionHandlerException.cc \
|
||||
OptionHandlerException.h bencode.cc bencode.h URIResult.cc \
|
||||
URIResult.h EventPoll.h SelectEventPoll.cc SelectEventPoll.h \
|
||||
SequentialPicker.h $(am__append_1) $(am__append_2) \
|
||||
$(am__append_3) $(am__append_4) $(am__append_5) \
|
||||
$(am__append_6) $(am__append_7) $(am__append_8) \
|
||||
$(am__append_9) $(am__append_10) $(am__append_11) \
|
||||
$(am__append_12) $(am__append_13) $(am__append_14) \
|
||||
$(am__append_15) $(am__append_16) $(am__append_17) \
|
||||
$(am__append_18) $(am__append_19) $(am__append_20) \
|
||||
$(am__append_21)
|
||||
SequentialPicker.h SequentialDispatcherCommand.h \
|
||||
$(am__append_1) $(am__append_2) $(am__append_3) \
|
||||
$(am__append_4) $(am__append_5) $(am__append_6) \
|
||||
$(am__append_7) $(am__append_8) $(am__append_9) \
|
||||
$(am__append_10) $(am__append_11) $(am__append_12) \
|
||||
$(am__append_13) $(am__append_14) $(am__append_15) \
|
||||
$(am__append_16) $(am__append_17) $(am__append_18) \
|
||||
$(am__append_19) $(am__append_20) $(am__append_21)
|
||||
noinst_LIBRARIES = libaria2c.a
|
||||
libaria2c_a_SOURCES = $(SRCS)
|
||||
aria2c_LDADD = libaria2c.a @LIBINTL@ @ALLOCA@ @LIBGNUTLS_LIBS@\
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
/* <!-- copyright */
|
||||
/*
|
||||
* aria2 - The high speed download utility
|
||||
*
|
||||
* Copyright (C) 2009 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_SEQUENTIAL_DISPATCHER_COMMAND_H_
|
||||
#define _D_SEQUENTIAL_DISPATCHER_COMMAND_H_
|
||||
|
||||
#include "Command.h"
|
||||
#include "SharedHandle.h"
|
||||
#include "SequentialPicker.h"
|
||||
#include "DownloadEngine.h"
|
||||
#include "RequestGroupMan.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
class DownloadEngine;
|
||||
|
||||
template<typename T>
|
||||
class SequentialDispatcherCommand : public Command {
|
||||
protected:
|
||||
SharedHandle<SequentialPicker<T> > _picker;
|
||||
|
||||
DownloadEngine* _e;
|
||||
public:
|
||||
SequentialDispatcherCommand(int32_t cuid,
|
||||
const SharedHandle<SequentialPicker<T> >& picker,
|
||||
DownloadEngine* e):
|
||||
Command(cuid), _picker(picker), _e(e) {}
|
||||
|
||||
virtual bool execute()
|
||||
{
|
||||
if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) {
|
||||
return true;
|
||||
}
|
||||
if(_picker->hasNext() && !_picker->isPicked()) {
|
||||
_e->commands.push_back(createCommand(_picker->pickNext()));
|
||||
|
||||
_e->setNoWait(true);
|
||||
}
|
||||
|
||||
_e->addRoutineCommand(this);
|
||||
return false;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual Command* createCommand(const SharedHandle<T>& entry) = 0;
|
||||
};
|
||||
|
||||
} // namespace aria2
|
||||
|
||||
#endif // _D_SEQUENTIAL_DISPATCHER_COMMAND_H_
|
Loading…
Reference in New Issue