summaryrefslogtreecommitdiff
path: root/src/DownloadEngine.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2013-04-26 23:55:51 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2013-04-26 23:59:48 +0900
commit6fcf274f279603db02a1abc45fc8c0a34f37033b (patch)
treed84cef6e051d824b172801f30bc4831f04d93d66 /src/DownloadEngine.cc
parent90abec8a362d6224bfff76d12fc9365fac36ddaa (diff)
Add initialization function and addUri API function for libaria2
Diffstat (limited to 'src/DownloadEngine.cc')
-rw-r--r--src/DownloadEngine.cc9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/DownloadEngine.cc b/src/DownloadEngine.cc
index 0f266b58..4df4aed1 100644
--- a/src/DownloadEngine.cc
+++ b/src/DownloadEngine.cc
@@ -88,6 +88,7 @@ DownloadEngine::DownloadEngine(const SharedHandle<EventPoll>& eventPoll)
haltRequested_(0),
noWait_(true),
refreshInterval_(DEFAULT_REFRESH_INTERVAL),
+ lastRefresh_(0),
cookieStorage_(new CookieStorage()),
#ifdef ENABLE_BITTORRENT
btRegistry_(new BtRegistry()),
@@ -141,8 +142,6 @@ void executeCommand(std::deque<Command*>& commands,
int DownloadEngine::run(bool oneshot)
{
- Timer cp;
- cp.reset(0);
while(!commands_.empty() || !routineCommands_.empty()) {
if(!commands_.empty()) {
waitData();
@@ -150,17 +149,17 @@ int DownloadEngine::run(bool oneshot)
noWait_ = false;
global::wallclock().reset();
calculateStatistics();
- if(cp.differenceInMillis(global::wallclock())+A2_DELTA_MILLIS >=
+ if(lastRefresh_.differenceInMillis(global::wallclock())+A2_DELTA_MILLIS >=
refreshInterval_) {
refreshInterval_ = DEFAULT_REFRESH_INTERVAL;
- cp = global::wallclock();
+ lastRefresh_ = global::wallclock();
executeCommand(commands_, Command::STATUS_ALL);
} else {
executeCommand(commands_, Command::STATUS_ACTIVE);
}
executeCommand(routineCommands_, Command::STATUS_ALL);
afterEachIteration();
- if(oneshot) {
+ if(!noWait_ && oneshot) {
return 1;
}
}