Commit a74b25bf authored by Dominik Charousset's avatar Dominik Charousset

change reply_to to accept const response_handler&

this commit patches a bug when using response_handle in a lambda;
response_handle::apply no longer invalidates the handle, which gives
weaker correctness guarantees but allows usage in closures (*sigh*)
parent 33e40722
......@@ -533,7 +533,7 @@ inline void reply(Args&&... what) {
* @brief Sends a message as reply to @p handle.
*/
template<typename... Args>
inline void reply_to(response_handle& handle, Args&&... what) {
inline void reply_to(const response_handle& handle, Args&&... what) {
if (handle.valid()) {
handle.apply(make_any_tuple(std::forward<Args>(what)...));
}
......@@ -543,7 +543,7 @@ inline void reply_to(response_handle& handle, Args&&... what) {
* @brief Sends a message to the sender of the last received message.
* @param what Message content as a tuple.
*/
inline void reply_tuple_to(response_handle& handle, any_tuple what) {
inline void reply_tuple_to(const response_handle& handle, any_tuple what) {
handle.apply(std::move(what));
}
......
......@@ -68,7 +68,7 @@ class response_handle {
/**
* @brief Sends @p response_message and invalidates this handle afterwards.
*/
void apply(any_tuple response_message);
void apply(any_tuple response_message) const;
/**
* @brief Returns the message id for the response message.
......
......@@ -53,7 +53,7 @@ bool response_handle::synchronous() const {
return m_id.valid();
}
void response_handle::apply(any_tuple msg) {
void response_handle::apply(any_tuple msg) const {
if (valid()) {
local_actor* sptr = self.unchecked();
if (sptr && sptr == m_from) {
......@@ -64,7 +64,6 @@ void response_handle::apply(any_tuple msg) {
}
}
else m_to->enqueue(m_from.get(), move(msg));
m_to.reset();
}
}
......
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