From e43d90c089b53cb08036da4dcec21f50decf32d0 Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 30 Jun 2022 00:46:02 +0300 Subject: [PATCH] Remove unused scheduler_id parameters. --- td/telegram/DialogDb.h | 2 +- td/telegram/MessagesDb.h | 2 +- td/telegram/TdDb.cpp | 25 ++++++++++++------------- td/telegram/TdDb.h | 4 ++-- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/td/telegram/DialogDb.h b/td/telegram/DialogDb.h index 9a9dfec66..dc98022a0 100644 --- a/td/telegram/DialogDb.h +++ b/td/telegram/DialogDb.h @@ -104,6 +104,6 @@ std::shared_ptr create_dialog_db_sync( std::shared_ptr sqlite_connection); std::shared_ptr create_dialog_db_async(std::shared_ptr sync_db, - int32 scheduler_id); + int32 scheduler_id = -1); } // namespace td diff --git a/td/telegram/MessagesDb.h b/td/telegram/MessagesDb.h index 94ab7cba5..57bcd54eb 100644 --- a/td/telegram/MessagesDb.h +++ b/td/telegram/MessagesDb.h @@ -205,6 +205,6 @@ std::shared_ptr create_messages_db_sync( std::shared_ptr sqlite_connection); std::shared_ptr create_messages_db_async(std::shared_ptr sync_db, - int32 scheduler_id); + int32 scheduler_id = -1); } // namespace td diff --git a/td/telegram/TdDb.cpp b/td/telegram/TdDb.cpp index 53236beb9..4b89edd8c 100644 --- a/td/telegram/TdDb.cpp +++ b/td/telegram/TdDb.cpp @@ -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 ¶meters, const DbKey &key, const DbKey &old_key, +Status TdDb::init_sqlite(const TdParameters ¶meters, const DbKey &key, const DbKey &old_key, BinlogKeyValue &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 ¶meters, 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("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 &&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 &&promise) { +void TdDb::open_impl(TdParameters parameters, DbKey key, Promise &&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(); - 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(unique_ptr(binlog_ptr), scheduler_id); + auto concurrent_binlog = std::make_shared(unique_ptr(binlog_ptr)); VLOG(td_init) << "Init concurrent_binlog_pmc"; concurrent_binlog_pmc->external_init_finish(concurrent_binlog); diff --git a/td/telegram/TdDb.h b/td/telegram/TdDb.h index 8dc97cbed..14beacfa3 100644 --- a/td/telegram/TdDb.h +++ b/td/telegram/TdDb.h @@ -124,11 +124,11 @@ class TdDb { std::shared_ptr> config_pmc_; std::shared_ptr binlog_; - static void open_impl(int32 scheduler_id, TdParameters parameters, DbKey key, Promise &&promise); + static void open_impl(TdParameters parameters, DbKey key, Promise &&promise); static void check_parameters_impl(TdParameters parameters, Promise promise); - Status init_sqlite(int32 scheduler_id, const TdParameters ¶meters, const DbKey &key, const DbKey &old_key, + Status init_sqlite(const TdParameters ¶meters, const DbKey &key, const DbKey &old_key, BinlogKeyValue &binlog_pmc); void do_close(Promise<> on_finished, bool destroy_flag);