Commit 22226951 authored by Dominik Charousset's avatar Dominik Charousset

added send_as and send_tuple_as functions

these functions provide a simple interface to "fake"
the sender information of a message
parent be17f214
...@@ -454,6 +454,34 @@ send(const intrusive_ptr<C>& whom, Args&&... what) { ...@@ -454,6 +454,34 @@ send(const intrusive_ptr<C>& whom, Args&&... what) {
detail::send_tpl_impl(whom.get(), std::forward<Args>(what)...); detail::send_tpl_impl(whom.get(), std::forward<Args>(what)...);
} }
/**
* @brief Sends @p what as a message to @p whom, but sets
* the sender information to @p from.
* @param from Sender as seen by @p whom.
* @param whom Receiver of the message.
* @param what Message elements.
* @pre <tt>sizeof...(Args) > 0</tt>
*/
template<class C, typename... Args>
inline typename std::enable_if<std::is_base_of<channel, C>::value>::type
send_tuple_as(const actor_ptr& from, const intrusive_ptr<C>& whom, any_tuple what) {
if (whom) whom->enqueue(from.get(), std::move(what));
}
/**
* @brief Sends <tt>{what...}</tt> as a message to @p whom, but sets
* the sender information to @p from.
* @param from Sender as seen by @p whom.
* @param whom Receiver of the message.
* @param what Message elements.
* @pre <tt>sizeof...(Args) > 0</tt>
*/
template<class C, typename... Args>
inline typename std::enable_if<std::is_base_of<channel, C>::value>::type
send_as(const actor_ptr& from, const intrusive_ptr<C>& whom, Args&&... what) {
send_tuple_as(from, whom, make_any_tuple(std::forward<Args>(what)...));
}
/** /**
* @brief Sends a message to @p whom. * @brief Sends a message to @p whom.
* *
......
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