157
167
std::multimap<std::string, SocketPoolEntry>::iterator
158
168
findSocketPoolEntry(const std::string& key);
160
std::deque<Command*> commands_;
161
SharedHandle<RequestGroupMan> requestGroupMan_;
162
SharedHandle<FileAllocationMan> fileAllocationMan_;
163
SharedHandle<CheckIntegrityMan> checkIntegrityMan_;
170
std::deque<std::unique_ptr<Command>> commands_;
171
std::unique_ptr<RequestGroupMan> requestGroupMan_;
172
std::unique_ptr<FileAllocationMan> fileAllocationMan_;
173
std::unique_ptr<CheckIntegrityMan> checkIntegrityMan_;
166
DownloadEngine(const SharedHandle<EventPoll>& eventPoll);
176
DownloadEngine(std::unique_ptr<EventPoll> eventPoll);
168
178
~DownloadEngine();
174
bool addSocketForReadCheck(const SharedHandle<SocketCore>& socket,
180
// If oneshot is true, this function returns after one event polling
181
// and performing action for them. This function returns 1 when
182
// oneshot is true and there are still downloads to be
183
// processed. Otherwise, returns 0.
184
int run(bool oneshot=false);
186
bool addSocketForReadCheck(const std::shared_ptr<SocketCore>& socket,
175
187
Command* command);
176
bool deleteSocketForReadCheck(const SharedHandle<SocketCore>& socket,
188
bool deleteSocketForReadCheck(const std::shared_ptr<SocketCore>& socket,
177
189
Command* command);
178
bool addSocketForWriteCheck(const SharedHandle<SocketCore>& socket,
190
bool addSocketForWriteCheck(const std::shared_ptr<SocketCore>& socket,
179
191
Command* command);
180
bool deleteSocketForWriteCheck(const SharedHandle<SocketCore>& socket,
192
bool deleteSocketForWriteCheck(const std::shared_ptr<SocketCore>& socket,
181
193
Command* command);
183
195
#ifdef ENABLE_ASYNC_DNS
185
bool addNameResolverCheck(const SharedHandle<AsyncNameResolver>& resolver,
197
bool addNameResolverCheck(const std::shared_ptr<AsyncNameResolver>& resolver,
186
198
Command* command);
187
bool deleteNameResolverCheck(const SharedHandle<AsyncNameResolver>& resolver,
199
bool deleteNameResolverCheck(const std::shared_ptr<AsyncNameResolver>& resolver,
188
200
Command* command);
189
201
#endif // ENABLE_ASYNC_DNS
191
void addCommand(const std::vector<Command*>& commands);
193
void addCommand(Command* command);
195
const SharedHandle<RequestGroupMan>& getRequestGroupMan() const
203
void addCommand(std::vector<std::unique_ptr<Command>> commands);
205
void addCommand(std::unique_ptr<Command> command);
207
const std::unique_ptr<RequestGroupMan>& getRequestGroupMan() const
197
209
return requestGroupMan_;
200
void setRequestGroupMan(const SharedHandle<RequestGroupMan>& rgman);
212
void setRequestGroupMan(std::unique_ptr<RequestGroupMan> rgman);
202
const SharedHandle<FileAllocationMan>& getFileAllocationMan() const
214
const std::unique_ptr<FileAllocationMan>& getFileAllocationMan() const
204
216
return fileAllocationMan_;
207
void setFileAllocationMan(const SharedHandle<FileAllocationMan>& faman);
219
void setFileAllocationMan(std::unique_ptr<FileAllocationMan> faman);
209
const SharedHandle<CheckIntegrityMan>& getCheckIntegrityMan() const
221
const std::unique_ptr<CheckIntegrityMan>& getCheckIntegrityMan() const
211
223
return checkIntegrityMan_;
214
void setCheckIntegrityMan(const SharedHandle<CheckIntegrityMan>& ciman);
226
void setCheckIntegrityMan(std::unique_ptr<CheckIntegrityMan> ciman);
216
228
Option* getOption() const
242
254
void setNoWait(bool b);
244
void addRoutineCommand(Command* command);
246
void poolSocket(const std::string& ipaddr, uint16_t port,
247
const std::string& username,
248
const std::string& proxyhost, uint16_t proxyport,
249
const SharedHandle<SocketCore>& sock,
250
const std::string& options,
251
time_t timeout = 15);
253
void poolSocket(const SharedHandle<Request>& request,
254
const std::string& username,
255
const SharedHandle<Request>& proxyRequest,
256
const SharedHandle<SocketCore>& socket,
257
const std::string& options,
258
time_t timeout = 15);
260
void poolSocket(const std::string& ipaddr, uint16_t port,
261
const std::string& proxyhost, uint16_t proxyport,
262
const SharedHandle<SocketCore>& sock,
263
time_t timeout = 15);
265
void poolSocket(const SharedHandle<Request>& request,
266
const SharedHandle<Request>& proxyRequest,
267
const SharedHandle<SocketCore>& socket,
268
time_t timeout = 15);
270
SharedHandle<SocketCore> popPooledSocket
256
void addRoutineCommand(std::unique_ptr<Command> command);
258
void poolSocket(const std::string& ipaddr, uint16_t port,
259
const std::string& username,
260
const std::string& proxyhost, uint16_t proxyport,
261
const std::shared_ptr<SocketCore>& sock,
262
const std::string& options,
263
time_t timeout = 15);
265
void poolSocket(const std::shared_ptr<Request>& request,
266
const std::string& username,
267
const std::shared_ptr<Request>& proxyRequest,
268
const std::shared_ptr<SocketCore>& socket,
269
const std::string& options,
270
time_t timeout = 15);
272
void poolSocket(const std::string& ipaddr, uint16_t port,
273
const std::string& proxyhost, uint16_t proxyport,
274
const std::shared_ptr<SocketCore>& sock,
275
time_t timeout = 15);
277
void poolSocket(const std::shared_ptr<Request>& request,
278
const std::shared_ptr<Request>& proxyRequest,
279
const std::shared_ptr<SocketCore>& socket,
280
time_t timeout = 15);
282
std::shared_ptr<SocketCore> popPooledSocket
271
283
(const std::string& ipaddr,
273
285
const std::string& proxyhost, uint16_t proxyport);
275
SharedHandle<SocketCore> popPooledSocket
287
std::shared_ptr<SocketCore> popPooledSocket
276
288
(std::string& options,
277
289
const std::string& ipaddr,
279
291
const std::string& username,
280
292
const std::string& proxyhost, uint16_t proxyport);
282
SharedHandle<SocketCore>
294
std::shared_ptr<SocketCore>
284
296
(const std::vector<std::string>& ipaddrs, uint16_t port);
286
SharedHandle<SocketCore>
298
std::shared_ptr<SocketCore>
288
300
(std::string& options,
289
301
const std::vector<std::string>& ipaddrs,
291
303
const std::string& username);
293
const SharedHandle<CookieStorage>& getCookieStorage() const
295
return cookieStorage_;
305
const std::unique_ptr<CookieStorage>& getCookieStorage() const;
298
307
#ifdef ENABLE_BITTORRENT
299
const SharedHandle<BtRegistry>& getBtRegistry() const
308
const std::unique_ptr<BtRegistry>& getBtRegistry() const
301
310
return btRegistry_;