Commit 3abbb933 authored by Dominik Charousset's avatar Dominik Charousset

Fix send_as, annotate deprecated versions

parent 98c77c17
...@@ -33,128 +33,149 @@ ...@@ -33,128 +33,149 @@
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`.
*/
inline void send_tuple_as(const actor& from, const channel& to, message msg) {
if (to) {
to->enqueue(from.address(), invalid_message_id, std::move(msg), nullptr);
}
}
inline void send_tuple_as(const actor& from, const channel& to,
message_priority prio, message msg) {
if (to) {
message_id id;
if (prio == message_priority::high) {
id = id.with_high_priority();
}
to->enqueue(from.address(), id, std::move(msg), nullptr);
}
}
/** /**
* Sends `to` a message under the identity of `from` with priority `prio`. * Sends `to` a message under the identity of `from` with priority `prio`.
*/ */
template <class... Ts> template <class... Ts>
void send_as(const actor& from, message_priority prio, const channel& to, void send_as(const actor& from, message_priority prio,
Ts&&... args) { const channel& to, Ts&&... vs) {
if (!to) { if (!to) {
return; return;
} }
message_id mid; message_id mid;
to->enqueue(from.address(), to->enqueue(from.address(),
prio == message_priority::high ? mid.with_high_priority() : mid, prio == message_priority::high ? mid.with_high_priority() : mid,
make_message(std::forward<Ts>(args)...), nullptr); make_message(std::forward<Ts>(vs)...), nullptr);
} }
/** /**
* Sends `to` a message under the identity of `from`. * Sends `to` a message under the identity of `from`.
*/ */
template <class... Ts> template <class... Ts>
void send_as(const actor& from, const channel& to, Ts&&... args) { void send_as(const actor& from, const channel& to, Ts&&... vs) {
send_as(from, to, make_message(std::forward<Ts>(args)...)); send_as(from, message_priority::normal, to, std::forward<Ts>(vs)...);
} }
/** /**
* Anonymously sends `to` a message. * Sends `to` a message under the identity of `from` with priority `prio`.
*/ */
inline void anon_send_tuple(const channel& to, message msg) { template <class... Rs, class... Ts>
send_as(invalid_actor, to, std::move(msg)); void send_as(const actor& from, message_priority prio,
const typed_actor<Rs...>& to, Ts&&... vs) {
check_typed_input(to,
detail::type_list<typename detail::implicit_conversions<
typename std::decay<Ts>::type
>::type...>{});
send_as(from, prio, actor_cast<channel>(to), std::forward<Ts>(vs)...);
} }
inline void anon_send_tuple(const channel& to, message_priority prio, /**
message msg) { * Sends `to` a message under the identity of `from`.
send_as(invalid_actor, to, prio, std::move(msg)); */
template <class... Rs, class... Ts>
void send_as(const actor& from, const typed_actor<Rs...>& to, Ts&&... vs) {
check_typed_input(to,
detail::type_list<typename detail::implicit_conversions<
typename std::decay<Ts>::type
>::type...>{});
send_as(from, message_priority::normal,
actor_cast<channel>(to), std::forward<Ts>(vs)...);
} }
/** /**
* Anonymously sends `whom` a message. * Anonymously sends `to` a message with priority `prio`.
*/ */
template <class... Ts> template <class... Ts>
void anon_send(const channel& to, Ts&&... args) { void anon_send(message_priority prio, const channel& to, Ts&&... vs) {
send_as(invalid_actor, to, std::forward<Ts>(args)...); send_as(invalid_actor, prio, to, std::forward<Ts>(vs)...);
} }
/**
* Anonymously sends `to` a message.
*/
template <class... Ts> template <class... Ts>
void anon_send(const channel& to, message_priority prio, Ts&&... args) { void anon_send(const channel& to, Ts&&... vs) {
send_as(invalid_actor, to, prio, std::forward<Ts>(args)...); send_as(invalid_actor, message_priority::normal, to, std::forward<Ts>(vs)...);
} }
/** /**
* Anonymously sends `whom` a message. * Anonymously sends `to` a message with priority `prio`.
*/ */
template <class... Rs, class... Ts> template <class... Rs, class... Ts>
void anon_send(const typed_actor<Rs...>& whom, Ts&&... args) { void anon_send(message_priority prio, const typed_actor<Rs...>& to,
check_typed_input(whom, Ts&&... vs) {
check_typed_input(to,
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...>{});
anon_send(actor_cast<channel>(whom), std::forward<Ts>(args)...); anon_send(prio, actor_cast<channel>(to), std::forward<Ts>(vs)...);
} }
/**
* Anonymously sends `to` a message.
*/
template <class... Rs, class... Ts> template <class... Rs, class... Ts>
void anon_send(const typed_actor<Rs...>& whom, message_priority prio, void anon_send(const typed_actor<Rs...>& to, Ts&&... vs) {
Ts&&... args) { check_typed_input(to,
check_typed_input(whom,
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...>{});
anon_send(actor_cast<channel>(whom), prio, std::forward<Ts>(args)...); anon_send(message_priority::normal, actor_cast<channel>(to),
std::forward<Ts>(vs)...);
} }
/** /**
* Anonymously sends `whom` an exit message. * Anonymously sends `to` an exit message.
*/ */
inline void anon_send_exit(const actor_addr& whom, uint32_t reason) { inline void anon_send_exit(const actor_addr& to, uint32_t reason) {
if (!whom){ if (!to){
return; return;
} }
auto ptr = actor_cast<actor>(whom); auto ptr = actor_cast<actor>(to);
ptr->enqueue(invalid_actor_addr, message_id{}.with_high_priority(), ptr->enqueue(invalid_actor_addr, message_id{}.with_high_priority(),
make_message(exit_msg{invalid_actor_addr, reason}), nullptr); make_message(exit_msg{invalid_actor_addr, reason}), nullptr);
} }
/** /**
* Anonymously sends `whom` an exit message. * Anonymously sends `to` an exit message.
*/ */
template <class ActorHandle> template <class ActorHandle>
void anon_send_exit(const ActorHandle& whom, uint32_t reason) { void anon_send_exit(const ActorHandle& to, uint32_t reason) {
anon_send_exit(whom.address(), reason); anon_send_exit(to.address(), reason);
}
// <backward_compatibility version="0.9">
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;
inline void send_tuple_as(const actor& from, const channel& to, message msg) {
send_as(from, to, std::move(msg));
}
inline void send_tuple_as(const actor& from, const channel& to,
message_priority prio, message msg) {
send_as(from, prio, to, std::move(msg));
} }
inline void anon_send_tuple(const channel& to, message msg) {
send_as(invalid_actor, to, std::move(msg));
}
inline void anon_send_tuple(const channel& to, message_priority prio,
message msg) {
send_as(invalid_actor, prio, to, std::move(msg));
}
// </backward_compatibility>
} // namespace caf } // namespace caf
#endif // CAF_SEND_HPP #endif // CAF_SEND_HPP
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