mirror of https://github.com/djcb/mu.git
indexer: fix some threading issues with Progress
Make it a const object with atomic members.
This commit is contained in:
parent
a628f214a1
commit
18ddbe06e6
|
@ -284,7 +284,7 @@ Indexer::Private::cleanup()
|
||||||
void
|
void
|
||||||
Indexer::Private::scan_worker()
|
Indexer::Private::scan_worker()
|
||||||
{
|
{
|
||||||
progress_ = {};
|
progress_.reset();
|
||||||
|
|
||||||
if (conf_.scan) {
|
if (conf_.scan) {
|
||||||
g_debug("starting scanner");
|
g_debug("starting scanner");
|
||||||
|
@ -410,7 +410,7 @@ Indexer::is_running() const
|
||||||
return priv_->state_ != IndexState::Idle;
|
return priv_->state_ != IndexState::Idle;
|
||||||
}
|
}
|
||||||
|
|
||||||
Indexer::Progress
|
const Indexer::Progress&
|
||||||
Indexer::progress() const
|
Indexer::progress() const
|
||||||
{
|
{
|
||||||
priv_->progress_.running = priv_->state_ == IndexState::Idle ? false : true;
|
priv_->progress_.running = priv_->state_ == IndexState::Idle ? false : true;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** Copyright (C) 2021 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
** Copyright (C) 2022 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||||
**
|
**
|
||||||
** This program is free software; you can redistribute it and/or modify it
|
** This program is free software; you can redistribute it and/or modify it
|
||||||
** under the terms of the GNU General Public License as published by the
|
** under the terms of the GNU General Public License as published by the
|
||||||
|
@ -20,6 +20,7 @@
|
||||||
#ifndef MU_INDEXER_HH__
|
#ifndef MU_INDEXER_HH__
|
||||||
#define MU_INDEXER_HH__
|
#define MU_INDEXER_HH__
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
|
@ -88,20 +89,26 @@ public:
|
||||||
|
|
||||||
// Object describing current progress
|
// Object describing current progress
|
||||||
struct Progress {
|
struct Progress {
|
||||||
bool running{}; /**< Is an index operation in progress? */
|
void reset()
|
||||||
size_t checked{}; /**< Number of messages checked for changes */
|
{
|
||||||
size_t updated{}; /**< Number of messages (re)parsed & added/updated to store */
|
running = false;
|
||||||
size_t removed{}; /**< Number of message removed from store */
|
checked = updated = removed = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::atomic<bool> running{}; /**< Is an index operation in progress? */
|
||||||
|
std::atomic<size_t> checked{}; /**< Number of messages checked for changes */
|
||||||
|
std::atomic<size_t> updated{}; /**< Number of messages (re)parsed/added/updated */
|
||||||
|
std::atomic<size_t> removed{}; /**< Number of message removed from store */
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an object describing the current progress. The progress object
|
* Get an object describing the current progress. The progress object
|
||||||
* describes the most recent indexing job, and is reset up a fresh
|
* describes the most recent indexing job, and is reset upon a fresh
|
||||||
* start().
|
* start().
|
||||||
*
|
*
|
||||||
* @return a progress object.
|
* @return a progress object.
|
||||||
*/
|
*/
|
||||||
Progress progress() const;
|
const Progress& progress() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Private;
|
struct Private;
|
||||||
|
|
Loading…
Reference in New Issue