Commit 59e2d5c4 authored by ufownl's avatar ufownl

Deprecate .unsafe functions of typed_actor

parent 66d9e98c
...@@ -135,9 +135,7 @@ class function_view { ...@@ -135,9 +135,7 @@ class function_view {
public: public:
using type = Actor; using type = Actor;
function_view(duration rel_timeout = infinite) function_view(duration rel_timeout = infinite) : timeout(rel_timeout) {
: timeout(rel_timeout),
impl_(unsafe_actor_handle_init) {
// nop // nop
} }
...@@ -164,7 +162,7 @@ public: ...@@ -164,7 +162,7 @@ public:
function_view& operator=(function_view&& x) { function_view& operator=(function_view&& x) {
timeout = x.timeout; timeout = x.timeout;
assign(x.impl_); assign(x.impl_);
x.assign(unsafe_actor_handle_init); x.reset();
return *this; return *this;
} }
...@@ -195,16 +193,21 @@ public: ...@@ -195,16 +193,21 @@ public:
} }
void assign(type x) { void assign(type x) {
if (impl_.unsafe() && !x.unsafe()) if (!impl_ && x)
new_self(x); new_self(x);
if (!impl_.unsafe() && x.unsafe()) if (impl_ && !x)
self_.~scoped_actor(); self_.~scoped_actor();
impl_.swap(x); impl_.swap(x);
} }
void reset() {
self_.~scoped_actor();
impl_ = type();
}
/// Checks whether this function view has an actor assigned to it. /// Checks whether this function view has an actor assigned to it.
explicit operator bool() const { explicit operator bool() const {
return !impl_.unsafe(); return static_cast<bool>(impl_);
} }
duration timeout; duration timeout;
......
...@@ -125,6 +125,7 @@ class typed_actor : detail::comparable<typed_actor<Sigs...>>, ...@@ -125,6 +125,7 @@ class typed_actor : detail::comparable<typed_actor<Sigs...>>,
using stateful_broker_pointer = using stateful_broker_pointer =
stateful_actor<State, broker_base>*; stateful_actor<State, broker_base>*;
typed_actor() = default;
typed_actor(typed_actor&&) = default; typed_actor(typed_actor&&) = default;
typed_actor(const typed_actor&) = default; typed_actor(const typed_actor&) = default;
typed_actor& operator=(typed_actor&&) = default; typed_actor& operator=(typed_actor&&) = default;
...@@ -165,7 +166,7 @@ class typed_actor : detail::comparable<typed_actor<Sigs...>>, ...@@ -165,7 +166,7 @@ class typed_actor : detail::comparable<typed_actor<Sigs...>>,
return *this; return *this;
} }
typed_actor(const unsafe_actor_handle_init_t&) { explicit typed_actor(const unsafe_actor_handle_init_t&) CAF_DEPRECATED {
// nop // nop
} }
...@@ -206,7 +207,7 @@ class typed_actor : detail::comparable<typed_actor<Sigs...>>, ...@@ -206,7 +207,7 @@ class typed_actor : detail::comparable<typed_actor<Sigs...>>,
/// Queries whether this object was constructed using /// Queries whether this object was constructed using
/// `unsafe_actor_handle_init` or is in moved-from state. /// `unsafe_actor_handle_init` or is in moved-from state.
bool unsafe() const { bool unsafe() const CAF_DEPRECATED {
return !ptr_; return !ptr_;
} }
...@@ -250,8 +251,6 @@ class typed_actor : detail::comparable<typed_actor<Sigs...>>, ...@@ -250,8 +251,6 @@ class typed_actor : detail::comparable<typed_actor<Sigs...>>,
/// @endcond /// @endcond
private: private:
typed_actor() = default;
actor_control_block* get() const noexcept { actor_control_block* get() const noexcept {
return ptr_.get(); return ptr_.get();
} }
......
...@@ -101,9 +101,7 @@ actor_system::module* middleman::make(actor_system& sys, detail::type_list<>) { ...@@ -101,9 +101,7 @@ actor_system::module* middleman::make(actor_system& sys, detail::type_list<>) {
return new impl(sys); return new impl(sys);
} }
middleman::middleman(actor_system& sys) middleman::middleman(actor_system& sys) : system_(sys) {
: system_(sys),
manager_(unsafe_actor_handle_init) {
// nop // nop
} }
......
...@@ -89,7 +89,7 @@ void run_client(int argc, char** argv, uint16_t port) { ...@@ -89,7 +89,7 @@ void run_client(int argc, char** argv, uint16_t port) {
auto f1 = make_function_view(*calc); auto f1 = make_function_view(*calc);
CAF_REQUIRE_EQUAL(f1(add_atom::value, 10, 20), 30); CAF_REQUIRE_EQUAL(f1(add_atom::value, 10, 20), 30);
CAF_REQUIRE_EQUAL(f1(sub_atom::value, 10, 20), -10); CAF_REQUIRE_EQUAL(f1(sub_atom::value, 10, 20), -10);
f1.assign(unsafe_actor_handle_init); f1.reset();
anon_send_exit(*calc, exit_reason::kill); anon_send_exit(*calc, exit_reason::kill);
mm.close(port); mm.close(port);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment