Use std::atomic for close_state.

This commit is contained in:
levlam 2022-08-18 22:04:20 +03:00
parent 939f4fa9fd
commit af8042dc61
2 changed files with 4 additions and 2 deletions

View File

@ -18,7 +18,7 @@ SqliteConnectionSafe::SqliteConnectionSafe(string path, DbKey key, optional<int3
cipher_version = std::move(cipher_version)] {
auto r_db = SqliteDb::open_with_key(path, false, key, cipher_version.copy());
if (r_db.is_error()) {
LOG(FATAL) << "Can't open database in state " << *close_state_ptr << ": " << r_db.error().message();
LOG(FATAL) << "Can't open database in state " << close_state_ptr->load() << ": " << r_db.error().message();
}
auto db = r_db.move_as_ok();
db.exec("PRAGMA journal_mode=WAL").ensure();

View File

@ -14,6 +14,8 @@
#include "td/utils/common.h"
#include "td/utils/optional.h"
#include <atomic>
namespace td {
class SqliteConnectionSafe {
@ -30,7 +32,7 @@ class SqliteConnectionSafe {
private:
string path_;
uint32 close_state_ = 0;
std::atomic<uint32> close_state_ = 0;
LazySchedulerLocalStorage<SqliteDb> lsls_connection_;
};