Commit 3146bf51 authored by Max Kellermann's avatar Max Kellermann

db/update/Service: eliminate attribute "progress"

Use walk!=nullptr instead.
parent b24a5e06
...@@ -45,7 +45,6 @@ UpdateService::UpdateService(EventLoop &_loop, SimpleDatabase &_db, ...@@ -45,7 +45,6 @@ UpdateService::UpdateService(EventLoop &_loop, SimpleDatabase &_db,
:DeferredMonitor(_loop), :DeferredMonitor(_loop),
db(_db), storage(_storage), db(_db), storage(_storage),
listener(_listener), listener(_listener),
progress(UPDATE_PROGRESS_IDLE),
update_task_id(0), update_task_id(0),
walk(nullptr) walk(nullptr)
{ {
...@@ -140,7 +139,6 @@ UpdateService::Task() ...@@ -140,7 +139,6 @@ UpdateService::Task()
else else
LogDebug(update_domain, "finished"); LogDebug(update_domain, "finished");
progress = UPDATE_PROGRESS_DONE;
DeferredMonitor::Schedule(); DeferredMonitor::Schedule();
} }
...@@ -157,7 +155,6 @@ UpdateService::StartThread(UpdateQueueItem &&i) ...@@ -157,7 +155,6 @@ UpdateService::StartThread(UpdateQueueItem &&i)
assert(GetEventLoop().IsInsideOrNull()); assert(GetEventLoop().IsInsideOrNull());
assert(walk == nullptr); assert(walk == nullptr);
progress = UPDATE_PROGRESS_RUNNING;
modified = false; modified = false;
next = std::move(i); next = std::move(i);
...@@ -231,7 +228,7 @@ UpdateService::Enqueue(const char *path, bool discard) ...@@ -231,7 +228,7 @@ UpdateService::Enqueue(const char *path, bool discard)
happen */ happen */
return 0; return 0;
if (progress != UPDATE_PROGRESS_IDLE) { if (walk != nullptr) {
const unsigned id = GenerateId(); const unsigned id = GenerateId();
if (!queue.Push(*db2, *storage2, path, discard, id)) if (!queue.Push(*db2, *storage2, path, discard, id))
return 0; return 0;
...@@ -254,7 +251,6 @@ UpdateService::Enqueue(const char *path, bool discard) ...@@ -254,7 +251,6 @@ UpdateService::Enqueue(const char *path, bool discard)
void void
UpdateService::RunDeferred() UpdateService::RunDeferred()
{ {
assert(progress == UPDATE_PROGRESS_DONE);
assert(next.IsDefined()); assert(next.IsDefined());
assert(walk != nullptr); assert(walk != nullptr);
...@@ -278,7 +274,5 @@ UpdateService::RunDeferred() ...@@ -278,7 +274,5 @@ UpdateService::RunDeferred()
if (i.IsDefined()) { if (i.IsDefined()) {
/* schedule the next path */ /* schedule the next path */
StartThread(std::move(i)); StartThread(std::move(i));
} else {
progress = UPDATE_PROGRESS_IDLE;
} }
} }
...@@ -35,19 +35,11 @@ class CompositeStorage; ...@@ -35,19 +35,11 @@ class CompositeStorage;
* This class manages the update queue and runs the update thread. * This class manages the update queue and runs the update thread.
*/ */
class UpdateService final : DeferredMonitor { class UpdateService final : DeferredMonitor {
enum Progress {
UPDATE_PROGRESS_IDLE = 0,
UPDATE_PROGRESS_RUNNING = 1,
UPDATE_PROGRESS_DONE = 2
};
SimpleDatabase &db; SimpleDatabase &db;
CompositeStorage &storage; CompositeStorage &storage;
DatabaseListener &listener; DatabaseListener &listener;
Progress progress;
bool modified; bool modified;
Thread update_thread; Thread update_thread;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment