Fix names of MultiPromiseActor.

GitOrigin-RevId: 2efcb2dab1578b0b6deb08f70a7db096daadb4aa
This commit is contained in:
levlam 2018-12-12 20:02:50 +03:00
parent 3fad0a7693
commit cc4877d0da
4 changed files with 8 additions and 5 deletions

View File

@ -524,7 +524,7 @@ void TopDialogManager::init() {
void TopDialogManager::on_first_sync() { void TopDialogManager::on_first_sync() {
was_first_sync_ = true; was_first_sync_ = true;
if (G()->td().get_actor_unsafe()->auth_manager_->is_bot()) { if (!G()->close_flag() && G()->td().get_actor_unsafe()->auth_manager_->is_bot()) {
is_active_ = false; is_active_ = false;
init(); init();
} }

View File

@ -13,6 +13,9 @@ void MultiPromiseActor::add_promise(Promise<Unit> &&promise) {
} }
Promise<Unit> MultiPromiseActor::get_promise() { Promise<Unit> MultiPromiseActor::get_promise() {
if (empty()) {
register_actor(name_, this).release();
}
CHECK(!promises_.empty()); CHECK(!promises_.empty());
PromiseActor<Unit> promise; PromiseActor<Unit> promise;

View File

@ -60,8 +60,7 @@ class MultiPromiseActor final
: public Actor : public Actor
, public MultiPromiseInterface { , public MultiPromiseInterface {
public: public:
MultiPromiseActor(Slice name) { explicit MultiPromiseActor(string name) : name_(std::move(name)) {
register_actor(name, this).release();
} }
void add_promise(Promise<Unit> &&promise) override; void add_promise(Promise<Unit> &&promise) override;
@ -75,6 +74,7 @@ class MultiPromiseActor final
private: private:
void set_result(Result<Unit> &&result); void set_result(Result<Unit> &&result);
string name_;
vector<Promise<Unit>> promises_; // promises waiting for result vector<Promise<Unit>> promises_; // promises waiting for result
vector<FutureActor<Unit>> futures_; // futures waiting for result of the queries vector<FutureActor<Unit>> futures_; // futures waiting for result of the queries
size_t received_results_ = 0; size_t received_results_ = 0;
@ -96,7 +96,7 @@ 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;
explicit MultiPromiseActorSafe(Slice name) : multi_promise_(make_unique<MultiPromiseActor>(name)) { explicit MultiPromiseActorSafe(string name) : multi_promise_(td::make_unique<MultiPromiseActor>(std::move(name))) {
} }
MultiPromiseActorSafe(const MultiPromiseActorSafe &other) = delete; MultiPromiseActorSafe(const MultiPromiseActorSafe &other) = delete;
MultiPromiseActorSafe &operator=(const MultiPromiseActorSafe &other) = delete; MultiPromiseActorSafe &operator=(const MultiPromiseActorSafe &other) = delete;

View File

@ -227,7 +227,7 @@ class TlStorerToString {
int b = value[static_cast<int>(i)] & 0xff; int b = value[static_cast<int>(i)] & 0xff;
result += hex[b >> 4]; result += hex[b >> 4];
result += hex[b & 15]; result += hex[b & 15];
if (i != len) { if (i + 1 != len) {
result += ' '; result += ' ';
} }
} }