Give different names to MultiPromise actors.
GitOrigin-RevId: 4277553637ca342bc80af07ddcdf013eec506221
This commit is contained in:
parent
65c8dd4b04
commit
7627dc27a7
@ -9151,7 +9151,7 @@ void ContactsManager::on_load_dialog_administrators_from_database(DialogId dialo
|
|||||||
|
|
||||||
LOG(INFO) << "Successfully loaded " << user_ids.size() << " administrators in " << dialog_id << " from database";
|
LOG(INFO) << "Successfully loaded " << user_ids.size() << " administrators in " << dialog_id << " from database";
|
||||||
|
|
||||||
MultiPromiseActorSafe load_users_multipromise;
|
MultiPromiseActorSafe load_users_multipromise{"LoadUsersMultiPromiseActor"};
|
||||||
load_users_multipromise.add_promise(
|
load_users_multipromise.add_promise(
|
||||||
PromiseCreator::lambda([dialog_id, user_ids, promise = std::move(promise)](Result<> result) mutable {
|
PromiseCreator::lambda([dialog_id, user_ids, promise = std::move(promise)](Result<> result) mutable {
|
||||||
send_closure(G()->contacts_manager(), &ContactsManager::on_load_administrator_users_finished, dialog_id,
|
send_closure(G()->contacts_manager(), &ContactsManager::on_load_administrator_users_finished, dialog_id,
|
||||||
|
@ -1099,7 +1099,7 @@ class ContactsManager : public Actor {
|
|||||||
int32 next_contacts_sync_date_ = 0;
|
int32 next_contacts_sync_date_ = 0;
|
||||||
Hints contacts_hints_; // search contacts by first name, last name and username
|
Hints contacts_hints_; // search contacts by first name, last name and username
|
||||||
vector<Promise<Unit>> load_contacts_queries_;
|
vector<Promise<Unit>> load_contacts_queries_;
|
||||||
MultiPromiseActor load_contact_users_multipromise_;
|
MultiPromiseActor load_contact_users_multipromise_{"LoadContactUsersMultiPromiseActor"};
|
||||||
int32 saved_contact_count_ = -1;
|
int32 saved_contact_count_ = -1;
|
||||||
|
|
||||||
int32 was_online_local_ = 0;
|
int32 was_online_local_ = 0;
|
||||||
@ -1107,7 +1107,7 @@ class ContactsManager : public Actor {
|
|||||||
|
|
||||||
bool are_imported_contacts_loaded_ = false;
|
bool are_imported_contacts_loaded_ = false;
|
||||||
vector<Promise<Unit>> load_imported_contacts_queries_;
|
vector<Promise<Unit>> load_imported_contacts_queries_;
|
||||||
MultiPromiseActor load_imported_contact_users_multipromise_;
|
MultiPromiseActor load_imported_contact_users_multipromise_{"LoadImportedContactUsersMultiPromiseActor"};
|
||||||
vector<Contact> all_imported_contacts_;
|
vector<Contact> all_imported_contacts_;
|
||||||
bool are_imported_contacts_changing_ = false;
|
bool are_imported_contacts_changing_ = false;
|
||||||
bool need_clear_imported_contacts_ = false;
|
bool need_clear_imported_contacts_ = false;
|
||||||
|
@ -118,7 +118,7 @@ class InlineQueriesManager : public Actor {
|
|||||||
void tear_down() override;
|
void tear_down() override;
|
||||||
|
|
||||||
int32 recently_used_bots_loaded_ = 0; // 0 - not loaded, 1 - load request was sent, 2 - loaded
|
int32 recently_used_bots_loaded_ = 0; // 0 - not loaded, 1 - load request was sent, 2 - loaded
|
||||||
MultiPromiseActor resolve_recent_inline_bots_multipromise_;
|
MultiPromiseActor resolve_recent_inline_bots_multipromise_{"ResolveRecentInlineBotsMultiPromiseActor"};
|
||||||
|
|
||||||
vector<UserId> recently_used_bot_user_ids_;
|
vector<UserId> recently_used_bot_user_ids_;
|
||||||
|
|
||||||
|
@ -21357,7 +21357,7 @@ void MessagesManager::do_delete_message_logevent(const DeleteMessageLogEvent &lo
|
|||||||
logevent_id = binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::DeleteMessage, storer);
|
logevent_id = binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::DeleteMessage, storer);
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiPromiseActorSafe mpas;
|
MultiPromiseActorSafe mpas{"DeleteMessageMultiPromiseActor"};
|
||||||
mpas.add_promise(PromiseCreator::lambda([logevent_id](Result<Unit> result) {
|
mpas.add_promise(PromiseCreator::lambda([logevent_id](Result<Unit> result) {
|
||||||
if (result.is_error()) {
|
if (result.is_error()) {
|
||||||
return;
|
return;
|
||||||
@ -23799,7 +23799,7 @@ bool MessagesManager::load_recently_found_dialogs(Promise<Unit> &promise) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto found_dialogs = full_split(found_dialogs_str, ',');
|
auto found_dialogs = full_split(found_dialogs_str, ',');
|
||||||
if (recently_found_dialogs_loaded_ == 1 && resolve_recent_found_dialogs_multipromise_.promise_count() == 0) {
|
if (recently_found_dialogs_loaded_ == 1 && resolve_recently_found_dialogs_multipromise_.promise_count() == 0) {
|
||||||
// queries was sent and have already been finished
|
// queries was sent and have already been finished
|
||||||
auto newly_found_dialogs = std::move(recently_found_dialog_ids_);
|
auto newly_found_dialogs = std::move(recently_found_dialog_ids_);
|
||||||
recently_found_dialog_ids_.clear();
|
recently_found_dialog_ids_.clear();
|
||||||
@ -23830,15 +23830,15 @@ bool MessagesManager::load_recently_found_dialogs(Promise<Unit> &promise) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve_recent_found_dialogs_multipromise_.add_promise(std::move(promise));
|
resolve_recently_found_dialogs_multipromise_.add_promise(std::move(promise));
|
||||||
if (recently_found_dialogs_loaded_ == 0) {
|
if (recently_found_dialogs_loaded_ == 0) {
|
||||||
recently_found_dialogs_loaded_ = 1;
|
recently_found_dialogs_loaded_ = 1;
|
||||||
|
|
||||||
resolve_recent_found_dialogs_multipromise_.set_ignore_errors(true);
|
resolve_recently_found_dialogs_multipromise_.set_ignore_errors(true);
|
||||||
|
|
||||||
for (auto &found_dialog : found_dialogs) {
|
for (auto &found_dialog : found_dialogs) {
|
||||||
if (found_dialog[0] == '@') {
|
if (found_dialog[0] == '@') {
|
||||||
search_public_dialog(found_dialog, false, resolve_recent_found_dialogs_multipromise_.get_promise());
|
search_public_dialog(found_dialog, false, resolve_recently_found_dialogs_multipromise_.get_promise());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (G()->parameters().use_message_db) {
|
if (G()->parameters().use_message_db) {
|
||||||
@ -23847,14 +23847,14 @@ bool MessagesManager::load_recently_found_dialogs(Promise<Unit> &promise) {
|
|||||||
auto dialog_id = DialogId(to_integer<int64>(found_dialog));
|
auto dialog_id = DialogId(to_integer<int64>(found_dialog));
|
||||||
CHECK(dialog_id.is_valid());
|
CHECK(dialog_id.is_valid());
|
||||||
// TODO use asynchronous load
|
// TODO use asynchronous load
|
||||||
// get_dialog(dialog_id, resolve_recent_found_dialogs_multipromise_.get_promise());
|
// get_dialog(dialog_id, resolve_recently_found_dialogs_multipromise_.get_promise());
|
||||||
get_dialog_force(dialog_id);
|
get_dialog_force(dialog_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resolve_recent_found_dialogs_multipromise_.get_promise().set_value(Unit());
|
resolve_recently_found_dialogs_multipromise_.get_promise().set_value(Unit());
|
||||||
} else {
|
} else {
|
||||||
get_dialogs(MIN_DIALOG_DATE, MAX_GET_DIALOGS, false, resolve_recent_found_dialogs_multipromise_.get_promise());
|
get_dialogs(MIN_DIALOG_DATE, MAX_GET_DIALOGS, false, resolve_recently_found_dialogs_multipromise_.get_promise());
|
||||||
td_->contacts_manager_->search_contacts("", 1, resolve_recent_found_dialogs_multipromise_.get_promise());
|
td_->contacts_manager_->search_contacts("", 1, resolve_recently_found_dialogs_multipromise_.get_promise());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -1125,7 +1125,7 @@ class MessagesManager : public Actor {
|
|||||||
|
|
||||||
struct PendingSecretMessage {
|
struct PendingSecretMessage {
|
||||||
MessageInfo message_info;
|
MessageInfo message_info;
|
||||||
MultiPromiseActor load_data_multipromise;
|
MultiPromiseActor load_data_multipromise{"LoadPendingSecretMessageDataMultiPromiseActor"};
|
||||||
Promise<> success_promise;
|
Promise<> success_promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1980,7 +1980,7 @@ class MessagesManager : public Actor {
|
|||||||
bool is_broadcast_channel(DialogId dialog_id) const;
|
bool is_broadcast_channel(DialogId dialog_id) const;
|
||||||
|
|
||||||
int32 recently_found_dialogs_loaded_ = 0; // 0 - not loaded, 1 - load request was sent, 2 - loaded
|
int32 recently_found_dialogs_loaded_ = 0; // 0 - not loaded, 1 - load request was sent, 2 - loaded
|
||||||
MultiPromiseActor resolve_recent_found_dialogs_multipromise_;
|
MultiPromiseActor resolve_recently_found_dialogs_multipromise_{"ResolveRecentlyFoundDialogsMultiPromiseActor"};
|
||||||
|
|
||||||
vector<DialogId> recently_found_dialog_ids_;
|
vector<DialogId> recently_found_dialog_ids_;
|
||||||
|
|
||||||
@ -2171,7 +2171,8 @@ class MessagesManager : public Actor {
|
|||||||
DialogDate last_loaded_database_dialog_date_ = MIN_DIALOG_DATE;
|
DialogDate last_loaded_database_dialog_date_ = MIN_DIALOG_DATE;
|
||||||
DialogDate last_database_server_dialog_date_ = MIN_DIALOG_DATE;
|
DialogDate last_database_server_dialog_date_ = MIN_DIALOG_DATE;
|
||||||
|
|
||||||
MultiPromiseActor load_dialog_list_multipromise_; // should be defined before pending_on_get_dialogs_
|
MultiPromiseActor load_dialog_list_multipromise_{
|
||||||
|
"LoadDialogListMultiPromiseActor"}; // should be defined before pending_on_get_dialogs_
|
||||||
Timeout preload_dialog_list_timeout_;
|
Timeout preload_dialog_list_timeout_;
|
||||||
|
|
||||||
std::unordered_map<DialogId, string, DialogIdHash> active_get_channel_differencies_;
|
std::unordered_map<DialogId, string, DialogIdHash> active_get_channel_differencies_;
|
||||||
|
@ -1328,7 +1328,7 @@ Status SecretChatActor::do_inbound_message_decrypted(unique_ptr<logevent::Inboun
|
|||||||
if (random_ids.size() == 1) {
|
if (random_ids.size() == 1) {
|
||||||
context_->on_read_message(random_ids[0], std::move(save_message_finish));
|
context_->on_read_message(random_ids[0], std::move(save_message_finish));
|
||||||
} else { // probably never happens
|
} else { // probably never happens
|
||||||
MultiPromiseActorSafe mpas;
|
MultiPromiseActorSafe mpas{"ReadSecretMessagesMultiPromiseActor"};
|
||||||
mpas.add_promise(std::move(save_message_finish));
|
mpas.add_promise(std::move(save_message_finish));
|
||||||
auto lock = mpas.get_promise();
|
auto lock = mpas.get_promise();
|
||||||
for (auto random_id : random_ids) {
|
for (auto random_id : random_ids) {
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
class MultiPromiseActor;
|
|
||||||
class Td;
|
class Td;
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
|
||||||
@ -274,7 +273,7 @@ class StickersManager : public Actor {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct PendingNewStickerSet {
|
struct PendingNewStickerSet {
|
||||||
MultiPromiseActor upload_files_multipromise;
|
MultiPromiseActor upload_files_multipromise{"UploadNewStickerSetFilesMultiPromiseActor"};
|
||||||
UserId user_id;
|
UserId user_id;
|
||||||
string title;
|
string title;
|
||||||
string short_name;
|
string short_name;
|
||||||
|
@ -193,7 +193,7 @@ void TdDb::close_and_destroy_all(Promise<> on_finished) {
|
|||||||
do_close(std::move(on_finished), true /*destroy_flag*/);
|
do_close(std::move(on_finished), true /*destroy_flag*/);
|
||||||
}
|
}
|
||||||
void TdDb::do_close(Promise<> on_finished, bool destroy_flag) {
|
void TdDb::do_close(Promise<> on_finished, bool destroy_flag) {
|
||||||
MultiPromiseActorSafe mpas;
|
MultiPromiseActorSafe mpas{"TdDbCloseMultiPromiseActor"};
|
||||||
mpas.add_promise(PromiseCreator::lambda(
|
mpas.add_promise(PromiseCreator::lambda(
|
||||||
[promise = std::move(on_finished), sql_connection = std::move(sql_connection_), destroy_flag](Unit) mutable {
|
[promise = std::move(on_finished), sql_connection = std::move(sql_connection_), destroy_flag](Unit) mutable {
|
||||||
if (sql_connection) {
|
if (sql_connection) {
|
||||||
|
@ -13,9 +13,6 @@ void MultiPromiseActor::add_promise(Promise<Unit> &&promise) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Promise<Unit> MultiPromiseActor::get_promise() {
|
Promise<Unit> MultiPromiseActor::get_promise() {
|
||||||
if (empty()) {
|
|
||||||
register_actor("MultiPromise", this).release();
|
|
||||||
}
|
|
||||||
CHECK(!promises_.empty());
|
CHECK(!promises_.empty());
|
||||||
|
|
||||||
PromiseActor<Unit> promise;
|
PromiseActor<Unit> promise;
|
||||||
|
@ -41,7 +41,6 @@ class MultiPromise : public MultiPromiseInterface {
|
|||||||
return impl_->get_promise();
|
return impl_->get_promise();
|
||||||
}
|
}
|
||||||
|
|
||||||
// deprecated?
|
|
||||||
size_t promise_count() const override {
|
size_t promise_count() const override {
|
||||||
return impl_->promise_count();
|
return impl_->promise_count();
|
||||||
}
|
}
|
||||||
@ -61,7 +60,9 @@ class MultiPromiseActor final
|
|||||||
: public Actor
|
: public Actor
|
||||||
, public MultiPromiseInterface {
|
, public MultiPromiseInterface {
|
||||||
public:
|
public:
|
||||||
MultiPromiseActor() = default;
|
MultiPromiseActor(Slice name) {
|
||||||
|
register_actor(name, this).release();
|
||||||
|
}
|
||||||
|
|
||||||
void add_promise(Promise<Unit> &&promise) override;
|
void add_promise(Promise<Unit> &&promise) override;
|
||||||
|
|
||||||
@ -95,7 +96,8 @@ class MultiPromiseActorSafe : public MultiPromiseInterface {
|
|||||||
Promise<Unit> get_promise() override;
|
Promise<Unit> get_promise() override;
|
||||||
void set_ignore_errors(bool ignore_errors) override;
|
void set_ignore_errors(bool ignore_errors) override;
|
||||||
size_t promise_count() const override;
|
size_t promise_count() const override;
|
||||||
MultiPromiseActorSafe() = default;
|
explicit MultiPromiseActorSafe(Slice name) : multi_promise_(make_unique<MultiPromiseActor>(name)) {
|
||||||
|
}
|
||||||
MultiPromiseActorSafe(const MultiPromiseActorSafe &other) = delete;
|
MultiPromiseActorSafe(const MultiPromiseActorSafe &other) = delete;
|
||||||
MultiPromiseActorSafe &operator=(const MultiPromiseActorSafe &other) = delete;
|
MultiPromiseActorSafe &operator=(const MultiPromiseActorSafe &other) = delete;
|
||||||
MultiPromiseActorSafe(MultiPromiseActorSafe &&other) = delete;
|
MultiPromiseActorSafe(MultiPromiseActorSafe &&other) = delete;
|
||||||
@ -103,14 +105,7 @@ class MultiPromiseActorSafe : public MultiPromiseInterface {
|
|||||||
~MultiPromiseActorSafe() override;
|
~MultiPromiseActorSafe() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unique_ptr<MultiPromiseActor> multi_promise_ = make_unique<MultiPromiseActor>();
|
unique_ptr<MultiPromiseActor> multi_promise_;
|
||||||
};
|
|
||||||
|
|
||||||
class MultiPromiseCreator {
|
|
||||||
public:
|
|
||||||
static MultiPromise create() {
|
|
||||||
return MultiPromise(make_unique<MultiPromiseActor>());
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -517,7 +517,7 @@ class MultiPromise2 : public Actor {
|
|||||||
Scheduler::instance()->finish();
|
Scheduler::instance()->finish();
|
||||||
});
|
});
|
||||||
|
|
||||||
MultiPromiseActorSafe multi_promise;
|
MultiPromiseActorSafe multi_promise{"MultiPromiseActor2"};
|
||||||
multi_promise.add_promise(std::move(promise));
|
multi_promise.add_promise(std::move(promise));
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
create_actor<SleepActor>("Sleep", 0.1, multi_promise.get_promise()).release();
|
create_actor<SleepActor>("Sleep", 0.1, multi_promise.get_promise()).release();
|
||||||
@ -532,7 +532,7 @@ class MultiPromise1 : public Actor {
|
|||||||
CHECK(result.is_error());
|
CHECK(result.is_error());
|
||||||
create_actor<MultiPromise2>("B").release();
|
create_actor<MultiPromise2>("B").release();
|
||||||
});
|
});
|
||||||
MultiPromiseActorSafe multi_promise;
|
MultiPromiseActorSafe multi_promise{"MultiPromiseActor1"};
|
||||||
multi_promise.add_promise(std::move(promise));
|
multi_promise.add_promise(std::move(promise));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user