Remove unused ActorId methods.

This commit is contained in:
levlam 2022-10-01 11:29:09 +03:00
parent fd8c7534a4
commit 39d2ac80b0
7 changed files with 29 additions and 40 deletions

View File

@ -136,7 +136,7 @@ void CountryInfoManager::tear_down() {
}
string CountryInfoManager::get_main_language_code() {
return to_lower(td_->language_pack_manager_->get_actor_unsafe()->get_main_language_code());
return to_lower(td_->language_pack_manager_.get_actor_unsafe()->get_main_language_code());
}
void CountryInfoManager::get_countries(Promise<td_api::object_ptr<td_api::countries>> &&promise) {

View File

@ -2681,7 +2681,7 @@ void NotificationManager::process_push_notification(string payload, Promise<Unit
}
auto receiver_id = r_receiver_id.move_as_ok();
auto encryption_keys = td_->device_token_manager_->get_actor_unsafe()->get_encryption_keys();
auto encryption_keys = td_->device_token_manager_.get_actor_unsafe()->get_encryption_keys();
VLOG(notifications) << "Process push notification \"" << format::escaped(payload)
<< "\" with receiver_id = " << receiver_id << " and " << encryption_keys.size()
<< " encryption keys";

View File

@ -9031,7 +9031,7 @@ void StickersManager::on_get_language_codes(const string &key, Result<vector<str
vector<string> StickersManager::get_emoji_language_codes(const vector<string> &input_language_codes, Slice text,
Promise<Unit> &promise) {
vector<string> language_codes = td_->language_pack_manager_->get_actor_unsafe()->get_used_language_codes();
vector<string> language_codes = td_->language_pack_manager_.get_actor_unsafe()->get_used_language_codes();
auto system_language_code = G()->mtproto_header().get_system_language_code();
if (system_language_code.size() >= 2 && system_language_code.find('$') == string::npos &&
(system_language_code.size() == 2 || system_language_code[2] == '-')) {

View File

@ -3754,10 +3754,10 @@ void Td::init_connection_creator() {
auto net_stats_manager = create_actor<NetStatsManager>("NetStatsManager", create_reference());
// How else could I let two actor know about each other, without quite complex async logic?
auto net_stats_manager_ptr = net_stats_manager->get_actor_unsafe();
auto net_stats_manager_ptr = net_stats_manager.get_actor_unsafe();
net_stats_manager_ptr->init();
connection_creator->get_actor_unsafe()->set_net_stats_callback(net_stats_manager_ptr->get_common_stats_callback(),
net_stats_manager_ptr->get_media_stats_callback());
connection_creator.get_actor_unsafe()->set_net_stats_callback(net_stats_manager_ptr->get_common_stats_callback(),
net_stats_manager_ptr->get_media_stats_callback());
G()->set_net_stats_file_callbacks(net_stats_manager_ptr->get_file_stats_callbacks());
G()->set_connection_creator(std::move(connection_creator));
@ -4283,7 +4283,7 @@ void Td::on_request(uint64 id, const td_api::getCurrentState &request) {
notification_manager_->get_current_state(updates);
config_manager_->get_actor_unsafe()->get_current_state(updates);
config_manager_.get_actor_unsafe()->get_current_state(updates);
// TODO updateFileGenerationStart generation_id:int64 original_path:string destination_path:string conversion:string = Update;
// TODO updateCall call:call = Update;

View File

@ -26,7 +26,7 @@ class ActorId {
ActorId(const ActorId &other) = default;
ActorId &operator=(const ActorId &other) = default;
ActorId(ActorId &&other) noexcept : ptr_(other.ptr_) {
other.ptr_.clear();
other.clear();
}
ActorId &operator=(ActorId &&other) noexcept {
if (&other == this) {
@ -52,9 +52,6 @@ class ActorId {
ActorInfo *get_actor_info() const;
ActorType *get_actor_unsafe() const;
// returns pointer to actor if it is on current thread. nullptr otherwise
ActorType *try_get_actor() const;
Slice get_name() const;
template <class ToActorType, class = std::enable_if_t<std::is_base_of<ToActorType, ActorType>::value>>
@ -62,11 +59,6 @@ class ActorId {
return ActorId<ToActorType>(ptr_);
}
template <class AsActorType>
ActorId<AsActorType> as() const {
return ActorId<AsActorType>(ptr_);
}
private:
ObjectPool<ActorInfo>::WeakPtr ptr_;
};
@ -99,10 +91,7 @@ class ActorOwn {
ActorId<ActorType> release();
void reset(ActorId<ActorType> other = ActorId<ActorType>());
void hangup() const;
const ActorId<ActorType> *operator->() const;
using ActorIdConstRef = const ActorId<ActorType> &;
// operator ActorIdConstRef();
ActorType *get_actor_unsafe() const;
private:
ActorId<ActorType> id_;
@ -137,7 +126,6 @@ class ActorShared {
void reset(ActorId<ActorType> other = ActorId<ActorType>());
template <class OtherActorType>
void reset(ActorId<OtherActorType> other);
const ActorId<ActorType> *operator->() const;
private:
ActorId<ActorType> id_;

View File

@ -29,15 +29,6 @@ ActorType *ActorId<ActorType>::get_actor_unsafe() const {
return static_cast<ActorType *>(ptr_->get_actor_unsafe());
}
template <class ActorType>
ActorType *ActorId<ActorType>::try_get_actor() const {
auto info = get_actor_info();
if (info && !info->is_migrating() && Scheduler::instance()->sched_id() == info->migrate_dest()) {
return static_cast<ActorType *>(info->get_actor_unsafe());
}
return nullptr;
}
template <class ActorType>
Slice ActorId<ActorType>::get_name() const {
return ptr_->get_name();
@ -46,14 +37,17 @@ Slice ActorId<ActorType>::get_name() const {
template <class ActorType>
ActorOwn<ActorType>::ActorOwn(ActorId<ActorType> id) : id_(std::move(id)) {
}
template <class ActorType>
template <class OtherActorType>
ActorOwn<ActorType>::ActorOwn(ActorId<OtherActorType> id) : id_(std::move(id)) {
}
template <class ActorType>
template <class OtherActorType>
ActorOwn<ActorType>::ActorOwn(ActorOwn<OtherActorType> &&other) : id_(other.release()) {
}
template <class ActorType>
template <class OtherActorType>
ActorOwn<ActorType> &ActorOwn<ActorType>::operator=(ActorOwn<OtherActorType> &&other) {
@ -64,6 +58,7 @@ ActorOwn<ActorType> &ActorOwn<ActorType>::operator=(ActorOwn<OtherActorType> &&o
template <class ActorType>
ActorOwn<ActorType>::ActorOwn(ActorOwn &&other) noexcept : id_(other.release()) {
}
template <class ActorType>
ActorOwn<ActorType> &ActorOwn<ActorType>::operator=(ActorOwn &&other) noexcept {
reset(other.release());
@ -79,6 +74,7 @@ template <class ActorType>
bool ActorOwn<ActorType>::empty() const {
return id_.empty();
}
template <class ActorType>
ActorId<ActorType> ActorOwn<ActorType>::get() const {
return id_;
@ -88,6 +84,7 @@ template <class ActorType>
ActorId<ActorType> ActorOwn<ActorType>::release() {
return std::move(id_);
}
template <class ActorType>
void ActorOwn<ActorType>::reset(ActorId<ActorType> other) {
static_assert(sizeof(ActorType) > 0, "Can't use ActorOwn with incomplete type");
@ -101,23 +98,27 @@ void ActorOwn<ActorType>::hangup() const {
send_event(id_, Event::hangup());
}
}
template <class ActorType>
const ActorId<ActorType> *ActorOwn<ActorType>::operator->() const {
return &id_;
ActorType *ActorOwn<ActorType>::get_actor_unsafe() const {
return id_.get_actor_unsafe();
}
template <class ActorType>
template <class OtherActorType>
ActorShared<ActorType>::ActorShared(ActorId<OtherActorType> id, uint64 token) : id_(std::move(id)), token_(token) {
}
template <class ActorType>
template <class OtherActorType>
ActorShared<ActorType>::ActorShared(ActorShared<OtherActorType> &&other) : id_(other.release()), token_(other.token()) {
}
template <class ActorType>
template <class OtherActorType>
ActorShared<ActorType>::ActorShared(ActorOwn<OtherActorType> &&other) : id_(other.release()), token_(0) {
}
template <class ActorType>
template <class OtherActorType>
ActorShared<ActorType> &ActorShared<ActorType>::operator=(ActorShared<OtherActorType> &&other) {
@ -129,6 +130,7 @@ ActorShared<ActorType> &ActorShared<ActorType>::operator=(ActorShared<OtherActor
template <class ActorType>
ActorShared<ActorType>::ActorShared(ActorShared &&other) noexcept : id_(other.release()), token_(other.token_) {
}
template <class ActorType>
ActorShared<ActorType> &ActorShared<ActorType>::operator=(ActorShared &&other) noexcept {
reset(other.release());
@ -145,10 +147,12 @@ template <class ActorType>
uint64 ActorShared<ActorType>::token() const {
return token_;
}
template <class ActorType>
bool ActorShared<ActorType>::empty() const {
return id_.empty();
}
template <class ActorType>
ActorId<ActorType> ActorShared<ActorType>::get() const {
return id_;
@ -158,6 +162,7 @@ template <class ActorType>
ActorId<ActorType> ActorShared<ActorType>::release() {
return std::move(id_);
}
template <class ActorType>
void ActorShared<ActorType>::reset(ActorId<ActorType> other) {
reset<ActorType>(std::move(other));
@ -172,10 +177,6 @@ void ActorShared<ActorType>::reset(ActorId<OtherActorType> other) {
}
id_ = static_cast<ActorId<ActorType>>(other);
}
template <class ActorType>
const ActorId<ActorType> *ActorShared<ActorType>::operator->() const {
return &id_;
}
template <class T>
ActorRef::ActorRef(const ActorId<T> &actor_id) : actor_id_(actor_id) {

View File

@ -760,7 +760,7 @@ class Master final : public Actor {
auto old_context = set_context(std::make_shared<Global>());
alice_ = create_actor<SecretChatProxy>("SecretChatProxy alice", "alice", actor_shared(this, 1));
bob_ = create_actor<SecretChatProxy>("SecretChatProxy bob", "bob", actor_shared(this, 2));
send_closure(alice_->get_actor_unsafe()->actor_, &SecretChatActor::create_chat, UserId(static_cast<int64>(2)), 0,
send_closure(alice_.get_actor_unsafe()->actor_, &SecretChatActor::create_chat, UserId(static_cast<int64>(2)), 0,
123, PromiseCreator::lambda([actor_id = actor_id(this)](Result<SecretChatId> res) {
send_closure(actor_id, &Master::got_secret_chat_id, std::move(res), false);
}));
@ -838,9 +838,9 @@ class Master final : public Actor {
void process_net_query(my_api::messages_requestEncryption &&request_encryption, NetQueryPtr net_query,
ActorShared<NetQueryCallback> callback) {
CHECK(get_link_token() == 1);
send_closure(alice_->get_actor_unsafe()->actor_, &SecretChatActor::update_chat,
send_closure(alice_.get_actor_unsafe()->actor_, &SecretChatActor::update_chat,
make_tl_object<telegram_api::encryptedChatWaiting>(123, 321, 0, 1, 2));
send_closure(bob_->get_actor_unsafe()->actor_, &SecretChatActor::update_chat,
send_closure(bob_.get_actor_unsafe()->actor_, &SecretChatActor::update_chat,
make_tl_object<telegram_api::encryptedChatRequested>(0, false, 123, 321, 0, 1, 2,
request_encryption.g_a_.clone()));
net_query->clear();
@ -848,7 +848,7 @@ class Master final : public Actor {
void process_net_query(my_api::messages_acceptEncryption &&request_encryption, NetQueryPtr net_query,
ActorShared<NetQueryCallback> callback) {
CHECK(get_link_token() == 2);
send_closure(alice_->get_actor_unsafe()->actor_, &SecretChatActor::update_chat,
send_closure(alice_.get_actor_unsafe()->actor_, &SecretChatActor::update_chat,
make_tl_object<telegram_api::encryptedChat>(123, 321, 0, 1, 2, request_encryption.g_b_.clone(),
request_encryption.key_fingerprint_));