db/update: cancel the update on shutdown
This commit is contained in:
@@ -47,6 +47,23 @@ UpdateService::UpdateService(EventLoop &_loop, SimpleDatabase &_db,
|
||||
{
|
||||
}
|
||||
|
||||
UpdateService::~UpdateService()
|
||||
{
|
||||
CancelAllAsync();
|
||||
|
||||
if (update_thread.IsDefined())
|
||||
update_thread.Join();
|
||||
}
|
||||
|
||||
void
|
||||
UpdateService::CancelAllAsync()
|
||||
{
|
||||
assert(GetEventLoop().IsInsideOrNull());
|
||||
|
||||
queue.Clear();
|
||||
walk.Cancel();
|
||||
}
|
||||
|
||||
inline void
|
||||
UpdateService::Task()
|
||||
{
|
||||
@@ -94,6 +111,8 @@ UpdateService::StartThread(UpdateQueueItem &&i)
|
||||
|
||||
next = std::move(i);
|
||||
|
||||
walk.Prepare();
|
||||
|
||||
Error error;
|
||||
if (!update_thread.Start(Task, this, error))
|
||||
FatalError(error);
|
||||
|
Reference in New Issue
Block a user