diff options
| author | levlam <levlam@telegram.org> | 2022-10-01 11:29:09 +0300 |
|---|---|---|
| committer | levlam <levlam@telegram.org> | 2022-10-01 11:29:09 +0300 |
| commit | 39d2ac80b0212102ecf4f9421d68c0060aff42e0 (patch) | |
| tree | 55f0c842c6e0a1ba3f69b8e773c108a4ff464250 /tdactor | |
| parent | fd8c7534a466460ee1ef081b22dca7a9e3aef789 (diff) | |
Remove unused ActorId methods.
Diffstat (limited to 'tdactor')
| -rw-r--r-- | tdactor/td/actor/impl/ActorId-decl.h | 16 | ||||
| -rw-r--r-- | tdactor/td/actor/impl/ActorId.h | 31 |
2 files changed, 18 insertions, 29 deletions
diff --git a/tdactor/td/actor/impl/ActorId-decl.h b/tdactor/td/actor/impl/ActorId-decl.h index bdbc5da72..03db2775b 100644 --- a/tdactor/td/actor/impl/ActorId-decl.h +++ b/tdactor/td/actor/impl/ActorId-decl.h @@ -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_; diff --git a/tdactor/td/actor/impl/ActorId.h b/tdactor/td/actor/impl/ActorId.h index bdc320e1f..fa93118e2 100644 --- a/tdactor/td/actor/impl/ActorId.h +++ b/tdactor/td/actor/impl/ActorId.h @@ -30,15 +30,6 @@ ActorType *ActorId<ActorType>::get_actor_unsafe() const { } 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) { |
