mirror of https://github.com/aria2/aria2
Move RequestGroup vector from Context to RequestGroupMan
parent
28c84148e4
commit
bb5b7eeedb
|
@ -280,7 +280,8 @@ Context::Context(bool standalone,
|
||||||
!uriListParser) {
|
!uriListParser) {
|
||||||
global::cout()->printf("%s\n", MSG_NO_FILES_TO_DOWNLOAD);
|
global::cout()->printf("%s\n", MSG_NO_FILES_TO_DOWNLOAD);
|
||||||
} else {
|
} else {
|
||||||
reqinfo.reset(new MultiUrlRequestInfo(requestGroups, op, getStatCalc(op),
|
reqinfo.reset(new MultiUrlRequestInfo(std::move(requestGroups),
|
||||||
|
op, getStatCalc(op),
|
||||||
getSummaryOut(op),
|
getSummaryOut(op),
|
||||||
uriListParser));
|
uriListParser));
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ DownloadEngineFactory::DownloadEngineFactory() {}
|
||||||
|
|
||||||
std::shared_ptr<DownloadEngine>
|
std::shared_ptr<DownloadEngine>
|
||||||
DownloadEngineFactory::newDownloadEngine
|
DownloadEngineFactory::newDownloadEngine
|
||||||
(Option* op, const std::vector<std::shared_ptr<RequestGroup> >& requestGroups)
|
(Option* op, std::vector<std::shared_ptr<RequestGroup> > requestGroups)
|
||||||
{
|
{
|
||||||
const size_t MAX_CONCURRENT_DOWNLOADS =
|
const size_t MAX_CONCURRENT_DOWNLOADS =
|
||||||
op->getAsInt(PREF_MAX_CONCURRENT_DOWNLOADS);
|
op->getAsInt(PREF_MAX_CONCURRENT_DOWNLOADS);
|
||||||
|
@ -149,9 +149,8 @@ DownloadEngineFactory::newDownloadEngine
|
||||||
std::shared_ptr<DownloadEngine> e(new DownloadEngine(eventPoll));
|
std::shared_ptr<DownloadEngine> e(new DownloadEngine(eventPoll));
|
||||||
e->setOption(op);
|
e->setOption(op);
|
||||||
|
|
||||||
std::shared_ptr<RequestGroupMan>
|
auto requestGroupMan = std::make_shared<RequestGroupMan>
|
||||||
requestGroupMan(new RequestGroupMan(requestGroups, MAX_CONCURRENT_DOWNLOADS,
|
(std::move(requestGroups), MAX_CONCURRENT_DOWNLOADS, op);
|
||||||
op));
|
|
||||||
requestGroupMan->initWrDiskCache();
|
requestGroupMan->initWrDiskCache();
|
||||||
e->setRequestGroupMan(requestGroupMan);
|
e->setRequestGroupMan(requestGroupMan);
|
||||||
e->setFileAllocationMan
|
e->setFileAllocationMan
|
||||||
|
|
|
@ -52,7 +52,7 @@ public:
|
||||||
|
|
||||||
std::shared_ptr<DownloadEngine>
|
std::shared_ptr<DownloadEngine>
|
||||||
newDownloadEngine
|
newDownloadEngine
|
||||||
(Option* op, const std::vector<std::shared_ptr<RequestGroup> >& requestGroups);
|
(Option* op, std::vector<std::shared_ptr<RequestGroup> > requestGroups);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -104,12 +104,13 @@ void handler(int signal) {
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
MultiUrlRequestInfo::MultiUrlRequestInfo
|
MultiUrlRequestInfo::MultiUrlRequestInfo
|
||||||
(std::vector<std::shared_ptr<RequestGroup> >& requestGroups,
|
(std::vector<std::shared_ptr<RequestGroup> > requestGroups,
|
||||||
const std::shared_ptr<Option>& op,
|
const std::shared_ptr<Option>& op,
|
||||||
const std::shared_ptr<StatCalc>& statCalc,
|
const std::shared_ptr<StatCalc>& statCalc,
|
||||||
const std::shared_ptr<OutputFile>& summaryOut,
|
const std::shared_ptr<OutputFile>& summaryOut,
|
||||||
const std::shared_ptr<UriListParser>& uriListParser)
|
const std::shared_ptr<UriListParser>& uriListParser)
|
||||||
: option_(op),
|
: requestGroups_(std::move(requestGroups)),
|
||||||
|
option_(op),
|
||||||
statCalc_(statCalc),
|
statCalc_(statCalc),
|
||||||
summaryOut_(summaryOut),
|
summaryOut_(summaryOut),
|
||||||
uriListParser_(uriListParser),
|
uriListParser_(uriListParser),
|
||||||
|
@ -120,7 +121,6 @@ MultiUrlRequestInfo::MultiUrlRequestInfo
|
||||||
#else // !HAVE_SIGACTION
|
#else // !HAVE_SIGACTION
|
||||||
mask_ = 0;
|
mask_ = 0;
|
||||||
#endif // !HAVE_SIGACTION
|
#endif // !HAVE_SIGACTION
|
||||||
requestGroups_.swap(requestGroups);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiUrlRequestInfo::~MultiUrlRequestInfo() {}
|
MultiUrlRequestInfo::~MultiUrlRequestInfo() {}
|
||||||
|
@ -160,10 +160,9 @@ int MultiUrlRequestInfo::prepare()
|
||||||
}
|
}
|
||||||
#endif // ENABLE_SSL
|
#endif // ENABLE_SSL
|
||||||
|
|
||||||
|
// RequestGroups will be transferred to DownloadEngine
|
||||||
e_ = DownloadEngineFactory().newDownloadEngine(option_.get(),
|
e_ = DownloadEngineFactory().newDownloadEngine(option_.get(),
|
||||||
requestGroups_);
|
std::move(requestGroups_));
|
||||||
// Avoid keeping RequestGroups alive longer than necessary
|
|
||||||
requestGroups_.clear();
|
|
||||||
|
|
||||||
#ifdef ENABLE_WEBSOCKET
|
#ifdef ENABLE_WEBSOCKET
|
||||||
if(option_->getAsBool(PREF_ENABLE_RPC)) {
|
if(option_->getAsBool(PREF_ENABLE_RPC)) {
|
||||||
|
|
|
@ -81,7 +81,7 @@ public:
|
||||||
* requestGroups.
|
* requestGroups.
|
||||||
*/
|
*/
|
||||||
MultiUrlRequestInfo
|
MultiUrlRequestInfo
|
||||||
(std::vector<std::shared_ptr<RequestGroup> >& requestGroups,
|
(std::vector<std::shared_ptr<RequestGroup> > requestGroups,
|
||||||
const std::shared_ptr<Option>& op,
|
const std::shared_ptr<Option>& op,
|
||||||
const std::shared_ptr<StatCalc>& statCalc,
|
const std::shared_ptr<StatCalc>& statCalc,
|
||||||
const std::shared_ptr<OutputFile>& summaryOut,
|
const std::shared_ptr<OutputFile>& summaryOut,
|
||||||
|
|
|
@ -96,7 +96,7 @@ void appendReservedGroup(RequestGroupList& list,
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
RequestGroupMan::RequestGroupMan
|
RequestGroupMan::RequestGroupMan
|
||||||
(const std::vector<std::shared_ptr<RequestGroup> >& requestGroups,
|
(std::vector<std::shared_ptr<RequestGroup> > requestGroups,
|
||||||
int maxSimultaneousDownloads,
|
int maxSimultaneousDownloads,
|
||||||
const Option* option)
|
const Option* option)
|
||||||
: maxSimultaneousDownloads_(maxSimultaneousDownloads),
|
: maxSimultaneousDownloads_(maxSimultaneousDownloads),
|
||||||
|
|
|
@ -120,7 +120,7 @@ private:
|
||||||
void addRequestGroupIndex
|
void addRequestGroupIndex
|
||||||
(const std::vector<std::shared_ptr<RequestGroup> >& groups);
|
(const std::vector<std::shared_ptr<RequestGroup> >& groups);
|
||||||
public:
|
public:
|
||||||
RequestGroupMan(const std::vector<std::shared_ptr<RequestGroup> >& requestGroups,
|
RequestGroupMan(std::vector<std::shared_ptr<RequestGroup> > requestGroups,
|
||||||
int maxSimultaneousDownloads,
|
int maxSimultaneousDownloads,
|
||||||
const Option* option);
|
const Option* option);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue