Commit 98c77c17 authored by Dominik Charousset's avatar Dominik Charousset

Deprecate all versions of `send_tuple`

parent 1a3de3f7
...@@ -301,7 +301,7 @@ class proper_actor<Base, Policies, true> ...@@ -301,7 +301,7 @@ class proper_actor<Base, Policies, true>
// auto e = this->new_mailbox_element(this, std::move(msg)); // auto e = this->new_mailbox_element(this, std::move(msg));
// this->m_mailbox.enqueue(e); // this->m_mailbox.enqueue(e);
} else { } else {
this->delayed_send_tuple(this, d, std::move(msg)); this->delayed_send(this, d, std::move(msg));
} }
m_pending_timeouts.push_back(tid); m_pending_timeouts.push_back(tid);
return tid; return tid;
......
...@@ -138,28 +138,16 @@ class local_actor : public extend<abstract_actor>::with<mixin::memory_cached> { ...@@ -138,28 +138,16 @@ class local_actor : public extend<abstract_actor>::with<mixin::memory_cached> {
} }
/************************************************************************** /**************************************************************************
* send asynchronous messages * * send asynchronous messages *
**************************************************************************/ **************************************************************************/
/**
* Sends `what` to the receiver specified in `dest`.
*/
void send_tuple(message_priority prio, const channel& whom, message what);
/**
* Sends `what` to the receiver specified in `dest`.
*/
inline void send_tuple(const channel& whom, message what) {
send_tuple(message_priority::normal, whom, std::move(what));
}
/** /**
* Sends `{what...} to `whom` using the priority `prio`. * Sends `{what...} to `whom` using the priority `prio`.
*/ */
template <class... Ts> template <class... Ts>
inline void send(message_priority prio, const channel& whom, Ts&&... what) { inline void send(message_priority prio, const channel& whom, Ts&&... what) {
static_assert(sizeof...(Ts) > 0, "sizeof...(Ts) == 0"); static_assert(sizeof...(Ts) > 0, "sizeof...(Ts) == 0");
send_tuple(prio, whom, make_message(std::forward<Ts>(what)...)); send_impl(prio, whom, make_message(std::forward<Ts>(what)...));
} }
/** /**
...@@ -168,8 +156,8 @@ class local_actor : public extend<abstract_actor>::with<mixin::memory_cached> { ...@@ -168,8 +156,8 @@ class local_actor : public extend<abstract_actor>::with<mixin::memory_cached> {
template <class... Ts> template <class... Ts>
inline void send(const channel& whom, Ts&&... what) { inline void send(const channel& whom, Ts&&... what) {
static_assert(sizeof...(Ts) > 0, "sizeof...(Ts) == 0"); static_assert(sizeof...(Ts) > 0, "sizeof...(Ts) == 0");
send_tuple(message_priority::normal, whom, send_impl(message_priority::normal, whom,
make_message(std::forward<Ts>(what)...)); make_message(std::forward<Ts>(what)...));
} }
/** /**
...@@ -181,8 +169,8 @@ class local_actor : public extend<abstract_actor>::with<mixin::memory_cached> { ...@@ -181,8 +169,8 @@ class local_actor : public extend<abstract_actor>::with<mixin::memory_cached> {
detail::type_list<typename detail::implicit_conversions< detail::type_list<typename detail::implicit_conversions<
typename std::decay<Ts>::type typename std::decay<Ts>::type
>::type...>{}); >::type...>{});
send_tuple(message_priority::normal, actor{whom.m_ptr.get()}, send_impl(message_priority::normal, actor{whom.m_ptr.get()},
make_message(std::forward<Ts>(what)...)); make_message(std::forward<Ts>(what)...));
} }
/** /**
...@@ -205,21 +193,6 @@ class local_actor : public extend<abstract_actor>::with<mixin::memory_cached> { ...@@ -205,21 +193,6 @@ class local_actor : public extend<abstract_actor>::with<mixin::memory_cached> {
send_exit(whom.address(), reason); send_exit(whom.address(), reason);
} }
/**
* Sends a message to `whom` with priority `prio`
* that is delayed by `rel_time`.
*/
void delayed_send_tuple(message_priority prio, const channel& whom,
const duration& rtime, message data);
/**
* Sends a message to `whom` that is delayed by `rel_time`.
*/
inline void delayed_send_tuple(const channel& whom, const duration& rtime,
message data) {
delayed_send_tuple(message_priority::normal, whom, rtime, std::move(data));
}
/** /**
* Sends a message to `whom` using priority `prio` * Sends a message to `whom` using priority `prio`
* that is delayed by `rel_time`. * that is delayed by `rel_time`.
...@@ -227,7 +200,7 @@ class local_actor : public extend<abstract_actor>::with<mixin::memory_cached> { ...@@ -227,7 +200,7 @@ class local_actor : public extend<abstract_actor>::with<mixin::memory_cached> {
template <class... Ts> template <class... Ts>
void delayed_send(message_priority prio, const channel& whom, void delayed_send(message_priority prio, const channel& whom,
const duration& rtime, Ts&&... args) { const duration& rtime, Ts&&... args) {
delayed_send_tuple(prio, whom, rtime, delayed_send_impl(prio, whom, rtime,
make_message(std::forward<Ts>(args)...)); make_message(std::forward<Ts>(args)...));
} }
...@@ -236,8 +209,8 @@ class local_actor : public extend<abstract_actor>::with<mixin::memory_cached> { ...@@ -236,8 +209,8 @@ class local_actor : public extend<abstract_actor>::with<mixin::memory_cached> {
*/ */
template <class... Ts> template <class... Ts>
void delayed_send(const channel& whom, const duration& rtime, Ts&&... args) { void delayed_send(const channel& whom, const duration& rtime, Ts&&... args) {
delayed_send_tuple(message_priority::normal, whom, rtime, delayed_send_impl(message_priority::normal, whom, rtime,
make_message(std::forward<Ts>(args)...)); make_message(std::forward<Ts>(args)...));
} }
/************************************************************************** /**************************************************************************
...@@ -433,6 +406,24 @@ class local_actor : public extend<abstract_actor>::with<mixin::memory_cached> { ...@@ -433,6 +406,24 @@ class local_actor : public extend<abstract_actor>::with<mixin::memory_cached> {
attach(attachable_ptr{new functor_attachable(std::move(f))}); attach(attachable_ptr{new functor_attachable(std::move(f))});
} }
/**************************************************************************
* outdated member functions *
**************************************************************************/
// <backward_compatibility version="0.9">
inline void send_tuple(message_priority prio, const channel& whom,
message what) CAF_DEPRECATED;
inline void send_tuple(const channel& whom, message what) CAF_DEPRECATED;
inline void delayed_send_tuple(message_priority prio, const channel& whom,
const duration& rtime,
message data) CAF_DEPRECATED;
inline void delayed_send_tuple(const channel& whom, const duration& rtime,
message data) CAF_DEPRECATED;
// </backward_compatibility>
/************************************************************************** /**************************************************************************
* here be dragons: end of public interface * * here be dragons: end of public interface *
**************************************************************************/ **************************************************************************/
...@@ -561,6 +552,9 @@ class local_actor : public extend<abstract_actor>::with<mixin::memory_cached> { ...@@ -561,6 +552,9 @@ class local_actor : public extend<abstract_actor>::with<mixin::memory_cached> {
/** @endcond */ /** @endcond */
private: private:
void send_impl(message_priority prio, const channel& dest, message&& what);
void delayed_send_impl(message_priority prio, const channel& whom,
const duration& rtime, message data);
using super = combined_type; using super = combined_type;
std::function<void()> m_sync_failure_handler; std::function<void()> m_sync_failure_handler;
std::function<void()> m_sync_timeout_handler; std::function<void()> m_sync_timeout_handler;
...@@ -572,6 +566,30 @@ class local_actor : public extend<abstract_actor>::with<mixin::memory_cached> { ...@@ -572,6 +566,30 @@ class local_actor : public extend<abstract_actor>::with<mixin::memory_cached> {
*/ */
using local_actor_ptr = intrusive_ptr<local_actor>; using local_actor_ptr = intrusive_ptr<local_actor>;
// <backward_compatibility version="0.9">
inline void local_actor::send_tuple(message_priority prio, const channel& whom,
message what) {
send_impl(prio, whom, std::move(what));
}
inline void local_actor::send_tuple(const channel& whom, message what) {
send_impl(message_priority::normal, whom, std::move(what));
}
inline void local_actor::delayed_send_tuple(message_priority prio,
const channel& whom,
const duration& rtime,
message data) {
delayed_send_impl(prio, whom, rtime, std::move(data));
}
inline void local_actor::delayed_send_tuple(const channel& whom,
const duration& rtime,
message data) {
delayed_send_impl(message_priority::normal, whom, rtime, std::move(data));
}
// </backward_compatibility>
} // namespace caf } // namespace caf
#endif // CAF_CONTEXT_HPP #endif // CAF_CONTEXT_HPP
...@@ -54,7 +54,7 @@ class single_timeout : public Base { ...@@ -54,7 +54,7 @@ class single_timeout : public Base {
this->enqueue(this->address(), invalid_message_id, this->enqueue(this->address(), invalid_message_id,
std::move(msg), this->host()); std::move(msg), this->host());
} else } else
this->delayed_send_tuple(this, d, std::move(msg)); this->delayed_send(this, d, std::move(msg));
} else } else
this->has_timeout(false); this->has_timeout(false);
} }
......
...@@ -76,7 +76,7 @@ class response_handle<Self, message, nonblocking_response_handle_tag> { ...@@ -76,7 +76,7 @@ class response_handle<Self, message, nonblocking_response_handle_tag> {
std::forward<Ts>(args)..., std::forward<Ts>(args)...,
on<sync_timeout_msg>() >> [selfptr]() -> skip_message_t { on<sync_timeout_msg>() >> [selfptr]() -> skip_message_t {
selfptr->handle_sync_timeout(); selfptr->handle_sync_timeout();
return {}; return skip_message();
} }
}; };
m_self->bhvr_stack().push_back(std::move(bhvr), m_mid); m_self->bhvr_stack().push_back(std::move(bhvr), m_mid);
......
...@@ -33,6 +33,18 @@ ...@@ -33,6 +33,18 @@
namespace caf { namespace caf {
// mark outdated functions as deprecated
inline void send_tuple_as(const actor& from, const channel& to,
message msg) CAF_DEPRECATED;
inline void send_tuple_as(const actor& from, const channel& to,
message_priority prio, message msg) CAF_DEPRECATED;
inline void anon_send_tuple(const channel& to, message msg) CAF_DEPRECATED;
inline void anon_send_tuple(const channel& to, message_priority prio,
message msg) CAF_DEPRECATED;
/** /**
* Sends `to` a message under the identity of `from`. * Sends `to` a message under the identity of `from`.
*/ */
...@@ -54,29 +66,38 @@ inline void send_tuple_as(const actor& from, const channel& to, ...@@ -54,29 +66,38 @@ inline void send_tuple_as(const actor& from, const channel& to,
} }
/** /**
* Sends `to` a message under the identity of `from`. * Sends `to` a message under the identity of `from` with priority `prio`.
*/ */
template <class... Ts> template <class... Ts>
void send_as(const actor& from, const channel& to, Ts&&... args) { void send_as(const actor& from, message_priority prio, const channel& to,
send_tuple_as(from, to, make_message(std::forward<Ts>(args)...)); Ts&&... args) {
if (!to) {
return;
}
message_id mid;
to->enqueue(from.address(),
prio == message_priority::high ? mid.with_high_priority() : mid,
make_message(std::forward<Ts>(args)...), nullptr);
} }
/**
* Sends `to` a message under the identity of `from`.
*/
template <class... Ts> template <class... Ts>
void send_as(const actor& from, const channel& to, message_priority prio, void send_as(const actor& from, const channel& to, Ts&&... args) {
Ts&&... args) { send_as(from, to, make_message(std::forward<Ts>(args)...));
send_tuple_as(from, to, prio, make_message(std::forward<Ts>(args)...));
} }
/** /**
* Anonymously sends `to` a message. * Anonymously sends `to` a message.
*/ */
inline void anon_send_tuple(const channel& to, message msg) { inline void anon_send_tuple(const channel& to, message msg) {
send_tuple_as(invalid_actor, to, std::move(msg)); send_as(invalid_actor, to, std::move(msg));
} }
inline void anon_send_tuple(const channel& to, message_priority prio, inline void anon_send_tuple(const channel& to, message_priority prio,
message msg) { message msg) {
send_tuple_as(invalid_actor, to, prio, std::move(msg)); send_as(invalid_actor, to, prio, std::move(msg));
} }
/** /**
......
...@@ -105,7 +105,7 @@ void local_actor::reply_message(message&& what) { ...@@ -105,7 +105,7 @@ void local_actor::reply_message(message&& what) {
} }
auto& mid = m_current_node->mid; auto& mid = m_current_node->mid;
if (mid.valid() == false || mid.is_response()) { if (mid.valid() == false || mid.is_response()) {
send_tuple(actor_cast<channel>(whom), std::move(what)); send(actor_cast<channel>(whom), std::move(what));
} else if (!mid.is_answered()) { } else if (!mid.is_answered()) {
auto ptr = actor_cast<actor>(whom); auto ptr = actor_cast<actor>(whom);
ptr->enqueue(address(), mid.response_id(), std::move(what), host()); ptr->enqueue(address(), mid.response_id(), std::move(what), host());
...@@ -125,8 +125,8 @@ void local_actor::forward_message(const actor& dest, message_priority prio) { ...@@ -125,8 +125,8 @@ void local_actor::forward_message(const actor& dest, message_priority prio) {
m_current_node->mid = invalid_message_id; m_current_node->mid = invalid_message_id;
} }
void local_actor::send_tuple(message_priority prio, const channel& dest, void local_actor::send_impl(message_priority prio, const channel& dest,
message what) { message&& what) {
if (!dest) { if (!dest) {
return; return;
} }
...@@ -141,8 +141,8 @@ void local_actor::send_exit(const actor_addr& whom, uint32_t reason) { ...@@ -141,8 +141,8 @@ void local_actor::send_exit(const actor_addr& whom, uint32_t reason) {
send(actor_cast<actor>(whom), exit_msg{address(), reason}); send(actor_cast<actor>(whom), exit_msg{address(), reason});
} }
void local_actor::delayed_send_tuple(message_priority prio, const channel& dest, void local_actor::delayed_send_impl(message_priority prio, const channel& dest,
const duration& rel_time, message msg) { const duration& rel_time, message msg) {
message_id mid; message_id mid;
if (prio == message_priority::high) { if (prio == message_priority::high) {
mid = mid.with_high_priority(); mid = mid.with_high_priority();
......
...@@ -283,7 +283,7 @@ void test_spawn() { ...@@ -283,7 +283,7 @@ void test_spawn() {
CAF_PRINT("test self->send()"); CAF_PRINT("test self->send()");
self->send(self, 1, 2, 3, true); self->send(self, 1, 2, 3, true);
self->receive(on(1, 2, 3, true) >> [] { }); self->receive(on(1, 2, 3, true) >> [] { });
self->send_tuple(self, message{}); self->send(self, message{});
self->receive(on() >> [] { }); self->receive(on() >> [] { });
self->await_all_other_actors_done(); self->await_all_other_actors_done();
CAF_CHECKPOINT(); CAF_CHECKPOINT();
...@@ -472,8 +472,8 @@ void test_spawn() { ...@@ -472,8 +472,8 @@ void test_spawn() {
); );
// kill joe and bob // kill joe and bob
auto poison_pill = make_message(atom("done")); auto poison_pill = make_message(atom("done"));
anon_send_tuple(joe, poison_pill); anon_send(joe, poison_pill);
anon_send_tuple(bob, poison_pill); anon_send(bob, poison_pill);
self->await_all_other_actors_done(); self->await_all_other_actors_done();
function<actor (const string&, const actor&)> spawn_next; function<actor (const string&, const actor&)> spawn_next;
...@@ -489,7 +489,7 @@ void test_spawn() { ...@@ -489,7 +489,7 @@ void test_spawn() {
s->become ( s->become (
others() >> [=] { others() >> [=] {
// forward message and die // forward message and die
s->send_tuple(pal, s->last_dequeued()); s->send(pal, s->last_dequeued());
s->quit(); s->quit();
} }
); );
......
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