2018-12-31 20:04:05 +01:00
|
|
|
//
|
2018-12-31 23:02:34 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2019
|
2018-12-31 20:04:05 +01:00
|
|
|
//
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
//
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "td/actor/SchedulerLocalStorage.h"
|
|
|
|
|
2019-10-03 19:15:15 +02:00
|
|
|
#include "td/db/DbKey.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/db/SqliteDb.h"
|
|
|
|
|
|
|
|
#include "td/utils/common.h"
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
|
|
|
class SqliteConnectionSafe {
|
|
|
|
public:
|
|
|
|
SqliteConnectionSafe() = default;
|
2019-10-03 19:38:47 +02:00
|
|
|
explicit SqliteConnectionSafe(string path, DbKey key = DbKey::empty());
|
2019-10-03 19:15:15 +02:00
|
|
|
|
|
|
|
SqliteDb &get();
|
|
|
|
|
|
|
|
void close();
|
|
|
|
|
|
|
|
void close_and_destroy();
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
private:
|
2019-10-03 19:38:47 +02:00
|
|
|
string path_;
|
2019-10-03 19:15:15 +02:00
|
|
|
LazySchedulerLocalStorage<SqliteDb> lsls_connection_;
|
2018-12-31 20:04:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace td
|