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