Remove unused scheduler_id parameters.

This commit is contained in:
levlam 2022-06-30 00:46:02 +03:00
parent 32724a5a6c
commit e43d90c089
4 changed files with 16 additions and 17 deletions

View File

@ -104,6 +104,6 @@ std::shared_ptr<DialogDbSyncSafeInterface> create_dialog_db_sync(
std::shared_ptr<SqliteConnectionSafe> sqlite_connection);
std::shared_ptr<DialogDbAsyncInterface> create_dialog_db_async(std::shared_ptr<DialogDbSyncSafeInterface> sync_db,
int32 scheduler_id);
int32 scheduler_id = -1);
} // namespace td

View File

@ -205,6 +205,6 @@ std::shared_ptr<MessagesDbSyncSafeInterface> create_messages_db_sync(
std::shared_ptr<SqliteConnectionSafe> sqlite_connection);
std::shared_ptr<MessagesDbAsyncInterface> create_messages_db_async(std::shared_ptr<MessagesDbSyncSafeInterface> sync_db,
int32 scheduler_id);
int32 scheduler_id = -1);
} // namespace td

View File

@ -273,7 +273,7 @@ void TdDb::do_close(Promise<> on_finished, bool destroy_flag) {
lock.set_value(Unit());
}
Status TdDb::init_sqlite(int32 scheduler_id, const TdParameters &parameters, const DbKey &key, const DbKey &old_key,
Status TdDb::init_sqlite(const TdParameters &parameters, const DbKey &key, const DbKey &old_key,
BinlogKeyValue<Binlog> &binlog_pmc) {
CHECK(!parameters.use_message_db || parameters.use_chat_info_db);
CHECK(!parameters.use_chat_info_db || parameters.use_file_db);
@ -358,32 +358,31 @@ Status TdDb::init_sqlite(int32 scheduler_id, const TdParameters &parameters, con
TRY_STATUS(db.exec("COMMIT TRANSACTION"));
file_db_ = create_file_db(sql_connection_, scheduler_id);
file_db_ = create_file_db(sql_connection_);
common_kv_safe_ = std::make_shared<SqliteKeyValueSafe>("common", sql_connection_);
common_kv_async_ = create_sqlite_key_value_async(common_kv_safe_, scheduler_id);
common_kv_async_ = create_sqlite_key_value_async(common_kv_safe_);
if (use_dialog_db) {
dialog_db_sync_safe_ = create_dialog_db_sync(sql_connection_);
dialog_db_async_ = create_dialog_db_async(dialog_db_sync_safe_, scheduler_id);
dialog_db_async_ = create_dialog_db_async(dialog_db_sync_safe_);
}
if (use_downloads_db) {
messages_db_sync_safe_ = create_messages_db_sync(sql_connection_);
messages_db_async_ = create_messages_db_async(messages_db_sync_safe_, scheduler_id);
messages_db_async_ = create_messages_db_async(messages_db_sync_safe_);
}
return Status::OK();
}
void TdDb::open(int32 scheduler_id, TdParameters parameters, DbKey key, Promise<OpenedDatabase> &&promise) {
Scheduler::instance()->run_on_scheduler(scheduler_id, [parameters = std::move(parameters), key = std::move(key),
promise = std::move(promise)](Unit) mutable {
TdDb::open_impl(-1, std::move(parameters), std::move(key), std::move(promise));
});
Scheduler::instance()->run_on_scheduler(
scheduler_id, [parameters = std::move(parameters), key = std::move(key), promise = std::move(promise)](
Unit) mutable { TdDb::open_impl(std::move(parameters), std::move(key), std::move(promise)); });
}
void TdDb::open_impl(int32 scheduler_id, TdParameters parameters, DbKey key, Promise<OpenedDatabase> &&promise) {
void TdDb::open_impl(TdParameters parameters, DbKey key, Promise<OpenedDatabase> &&promise) {
OpenedDatabase result;
// Init pmc
@ -427,7 +426,7 @@ void TdDb::open_impl(int32 scheduler_id, TdParameters parameters, DbKey key, Pro
}
VLOG(td_init) << "Start to init database";
auto db = make_unique<TdDb>();
auto init_sqlite_status = db->init_sqlite(scheduler_id, parameters, new_sqlite_key, old_sqlite_key, *binlog_pmc);
auto init_sqlite_status = db->init_sqlite(parameters, new_sqlite_key, old_sqlite_key, *binlog_pmc);
VLOG(td_init) << "Finish to init database";
if (init_sqlite_status.is_error()) {
LOG(ERROR) << "Destroy bad SQLite database because of " << init_sqlite_status;
@ -435,7 +434,7 @@ void TdDb::open_impl(int32 scheduler_id, TdParameters parameters, DbKey key, Pro
db->sql_connection_->get().close();
}
SqliteDb::destroy(get_sqlite_path(parameters)).ignore();
TRY_STATUS_PROMISE(promise, db->init_sqlite(scheduler_id, parameters, new_sqlite_key, old_sqlite_key, *binlog_pmc));
TRY_STATUS_PROMISE(promise, db->init_sqlite(parameters, new_sqlite_key, old_sqlite_key, *binlog_pmc));
}
if (drop_sqlite_key) {
binlog_pmc->erase("sqlite_key");
@ -458,7 +457,7 @@ void TdDb::open_impl(int32 scheduler_id, TdParameters parameters, DbKey key, Pro
CHECK(binlog_ptr != nullptr);
VLOG(td_init) << "Create concurrent_binlog";
auto concurrent_binlog = std::make_shared<ConcurrentBinlog>(unique_ptr<Binlog>(binlog_ptr), scheduler_id);
auto concurrent_binlog = std::make_shared<ConcurrentBinlog>(unique_ptr<Binlog>(binlog_ptr));
VLOG(td_init) << "Init concurrent_binlog_pmc";
concurrent_binlog_pmc->external_init_finish(concurrent_binlog);

View File

@ -124,11 +124,11 @@ class TdDb {
std::shared_ptr<BinlogKeyValue<ConcurrentBinlog>> config_pmc_;
std::shared_ptr<ConcurrentBinlog> binlog_;
static void open_impl(int32 scheduler_id, TdParameters parameters, DbKey key, Promise<OpenedDatabase> &&promise);
static void open_impl(TdParameters parameters, DbKey key, Promise<OpenedDatabase> &&promise);
static void check_parameters_impl(TdParameters parameters, Promise<CheckedParameters> promise);
Status init_sqlite(int32 scheduler_id, const TdParameters &parameters, const DbKey &key, const DbKey &old_key,
Status init_sqlite(const TdParameters &parameters, const DbKey &key, const DbKey &old_key,
BinlogKeyValue<Binlog> &binlog_pmc);
void do_close(Promise<> on_finished, bool destroy_flag);