Commit 2dfe753e authored by Dominik Charousset's avatar Dominik Charousset

Deprecate remaining `*_send_tuple` functions

parent 889067e5
...@@ -78,7 +78,7 @@ void client_bhvr(event_based_actor* self, const string& host, ...@@ -78,7 +78,7 @@ void client_bhvr(event_based_actor* self, const string& host,
} }
} }
auto sync_send_request = [=](int lhs, const char* op, int rhs) { auto sync_send_request = [=](int lhs, const char* op, int rhs) {
self->sync_send_tuple(server, self->last_dequeued()).then( self->sync_send(server, self->last_dequeued()).then(
[=](result_atom, int result) { [=](result_atom, int result) {
aout(self) << lhs << " " << op << " " << rhs << " = " << result << endl; aout(self) << lhs << " " << op << " " << rhs << " = " << result << endl;
} }
......
...@@ -400,11 +400,11 @@ class local_actor : public abstract_actor { ...@@ -400,11 +400,11 @@ class local_actor : public abstract_actor {
attach(attachable_ptr{new functor_attachable(std::move(f))}); attach(attachable_ptr{new functor_attachable(std::move(f))});
} }
// <backward_compatibility version="0.9">
/************************************************************************** /**************************************************************************
* outdated member functions * * outdated member functions *
**************************************************************************/ **************************************************************************/
// <backward_compatibility version="0.9">
inline void send_tuple(message_priority prio, const channel& whom, inline void send_tuple(message_priority prio, const channel& whom,
message what) CAF_DEPRECATED; message what) CAF_DEPRECATED;
...@@ -464,23 +464,11 @@ class local_actor : public abstract_actor { ...@@ -464,23 +464,11 @@ class local_actor : public abstract_actor {
} }
// returns the response ID // returns the response ID
message_id timed_sync_send_tuple_impl(message_priority mp, message_id timed_sync_send_impl(message_priority, const actor&,
const actor& whom, const duration&, message&&);
const duration& rel_time,
message&& what);
// returns the response ID // returns the response ID
message_id sync_send_tuple_impl(message_priority mp, message_id sync_send_impl(message_priority, const actor&, message&&);
const actor& whom,
message&& what);
// returns the response ID
template <class... Rs, class... Ts>
message_id sync_send_tuple_impl(message_priority mp,
const typed_actor<Rs...>& whom,
message&& msg) {
return sync_send_tuple_impl(mp, actor{whom.m_ptr.get()}, std::move(msg));
}
// returns 0 if last_dequeued() is an asynchronous or sync request message, // returns 0 if last_dequeued() is an asynchronous or sync request message,
// a response id generated from the request id otherwise // a response id generated from the request id otherwise
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "caf/actor.hpp" #include "caf/actor.hpp"
#include "caf/message.hpp" #include "caf/message.hpp"
#include "caf/duration.hpp" #include "caf/duration.hpp"
#include "caf/actor_cast.hpp"
#include "caf/response_handle.hpp" #include "caf/response_handle.hpp"
#include "caf/message_priority.hpp" #include "caf/message_priority.hpp"
#include "caf/check_typed_input.hpp" #include "caf/check_typed_input.hpp"
...@@ -32,260 +33,252 @@ ...@@ -32,260 +33,252 @@
namespace caf { namespace caf {
namespace mixin { namespace mixin {
template <class Base, class Subtype, class ResponseHandleTag> template <class Base, class Subtype, class HandleTag>
class sync_sender_impl : public Base { class sync_sender_impl : public Base {
public: public:
using response_handle_type = response_handle<Subtype, message, using response_handle_type = response_handle<Subtype, message, HandleTag>;
ResponseHandleTag>;
/************************************************************************** /****************************************************************************
* sync_send[_tuple](actor, ...) * * sync_send(...) *
**************************************************************************/ ****************************************************************************/
/** /**
* Sends `what` as a synchronous message to `whom`. * Sends `{vs...}` as a synchronous message to `dest` with priority `prio`.
* @param dest Receiver of the message. * @returns A handle identifying a future-like handle to the response.
* @param what Message content as tuple.
* @returns A handle identifying a future to the response of `whom`.
* @warning The returned handle is actor specific and the response to the * @warning The returned handle is actor specific and the response to the
* sent message cannot be received by another actor. * sent message cannot be received by another actor.
* @throws std::invalid_argument if `whom == nullptr * @throws std::invalid_argument if `dest == invalid_actor`
*/ */
response_handle_type sync_send_tuple(message_priority prio, template <class... Vs>
const actor& dest, message what) { response_handle_type sync_send(message_priority prio, const actor& dest,
return {dptr()->sync_send_tuple_impl(prio, dest, std::move(what)), Vs&&... vs) {
static_assert(sizeof...(Vs) > 0, "no message to send");
return {dptr()->sync_send_impl(prio, dest,
make_message(std::forward<Vs>(vs)...)),
dptr()}; dptr()};
} }
response_handle_type sync_send_tuple(const actor& dest, message what) {
return sync_send_tuple(message_priority::normal, dest, std::move(what));
}
/** /**
* Sends `{what...}` as a synchronous message to `whom`. * Sends `{vs...}` as a synchronous message to `dest`.
* @param dest Receiver of the message. * @returns A handle identifying a future-like handle to the response.
* @param what Message elements.
* @returns A handle identifying a future to the response of `whom`.
* @warning The returned handle is actor specific and the response to the * @warning The returned handle is actor specific and the response to the
* sent message cannot be received by another actor. * sent message cannot be received by another actor.
* @throws std::invalid_argument if `whom == nullptr` * @throws std::invalid_argument if `dest == invalid_actor`
*/ */
template <class... Ts> template <class... Vs>
response_handle_type sync_send(message_priority prio, const actor& dest, response_handle_type sync_send(const actor& dest, Vs&&... vs) {
Ts&&... what) { return sync_send(message_priority::normal, dest, std::forward<Vs>(vs)...);
static_assert(sizeof...(Ts) > 0, "no message to send");
return sync_send_tuple(prio, dest,
make_message(std::forward<Ts>(what)...));
}
template <class... Ts>
response_handle_type sync_send(const actor& dest, Ts&&... what) {
static_assert(sizeof...(Ts) > 0, "no message to send");
return sync_send_tuple(message_priority::normal, dest,
make_message(std::forward<Ts>(what)...));
}
/**************************************************************************
* timed_sync_send[_tuple](actor, ...) *
**************************************************************************/
response_handle_type timed_sync_send_tuple(message_priority prio,
const actor& dest,
const duration& rtime,
message what) {
return {dptr()->timed_sync_send_tuple_impl(prio, dest, rtime,
std::move(what)),
dptr()};
}
response_handle_type timed_sync_send_tuple(const actor& dest,
const duration& rtime,
message what) {
return {dptr()->timed_sync_send_tuple_impl(
message_priority::normal, dest, rtime, std::move(what)),
dptr()};
}
template <class... Ts>
response_handle_type timed_sync_send(message_priority prio,
const actor& dest,
const duration& rtime, Ts&&... what) {
static_assert(sizeof...(Ts) > 0, "no message to send");
return timed_sync_send_tuple(prio, dest, rtime,
make_message(std::forward<Ts>(what)...));
}
template <class... Ts>
response_handle_type timed_sync_send(const actor& dest,
const duration& rtime, Ts&&... what) {
static_assert(sizeof...(Ts) > 0, "no message to send");
return timed_sync_send_tuple(message_priority::normal, dest, rtime,
make_message(std::forward<Ts>(what)...));
} }
/************************************************************************** /**
* sync_send[_tuple](typed_actor<...>, ...) * * Sends `{vs...}` as a synchronous message to `dest` with priority `prio`.
**************************************************************************/ * @returns A handle identifying a future-like handle to the response.
* @warning The returned handle is actor specific and the response to the
template <class... Rs, class... Ts> * sent message cannot be received by another actor.
* @throws std::invalid_argument if `dest == invalid_actor`
*/
template <class... Rs, class... Vs>
response_handle<Subtype, response_handle<Subtype,
typename detail::deduce_output_type< typename detail::deduce_output_type<
detail::type_list<Rs...>, detail::type_list<Rs...>,
detail::type_list<Ts...> detail::type_list<
typename detail::implicit_conversions<
typename std::decay<Vs>::type
>::type...>
>::type, >::type,
ResponseHandleTag> HandleTag>
sync_send_tuple(message_priority prio, const typed_actor<Rs...>& dest, sync_send(message_priority prio, const typed_actor<Rs...>& dest, Vs&&... vs) {
std::tuple<Ts...> what) { static_assert(sizeof...(Vs) > 0, "no message to send");
return sync_send_impl(prio, dest, detail::type_list<Ts...>{}, using token =
message::move_from_tuple(std::move(what))); detail::type_list<
} typename detail::implicit_conversions<
typename std::decay<Vs>::type
template <class... Rs, class... Ts> >::type...>;
response_handle< token tk;
Subtype, typename detail::deduce_output_type< check_typed_input(dest, tk);
detail::type_list<Rs...>, detail::type_list<Ts...>>::type, return {dptr()->sync_send_impl(prio, actor_cast<actor>(dest),
ResponseHandleTag> make_message(std::forward<Vs>(vs)...)),
sync_send_tuple(const typed_actor<Rs...>& dest, std::tuple<Ts...> what) { dptr()};
return sync_send_impl(message_priority::normal, dest,
detail::type_list<Ts...>{},
message::move_from_tuple(std::move(what)));
} }
template <class... Rs, class... Ts> /**
response_handle< * Sends `{vs...}` as a synchronous message to `dest`.
Subtype, * @returns A handle identifying a future-like handle to the response.
* @warning The returned handle is actor specific and the response to the
* sent message cannot be received by another actor.
* @throws std::invalid_argument if `dest == invalid_actor`
*/
template <class... Rs, class... Vs>
response_handle<Subtype,
typename detail::deduce_output_type< typename detail::deduce_output_type<
detail::type_list<Rs...>, detail::type_list<Rs...>,
detail::type_list<
typename detail::implicit_conversions< typename detail::implicit_conversions<
typename std::decay<Ts>::type>::type... typename std::decay<Vs>::type
>::type...>
>::type, >::type,
ResponseHandleTag> HandleTag>
sync_send(message_priority prio, const typed_actor<Rs...>& dest, sync_send(const typed_actor<Rs...>& dest, Vs&&... vs) {
Ts&&... what) { return sync_send(message_priority::normal, dest, std::forward<Vs>(vs)...);
return sync_send_impl(
prio, dest,
detail::type_list<typename detail::implicit_conversions<
typename std::decay<Ts>::type>::type...>{},
make_message(std::forward<Ts>(what)...));
}
template <class... Rs, class... Ts>
response_handle<
Subtype,
typename detail::deduce_output_type<
detail::type_list<Rs...>,
detail::type_list<typename detail::implicit_conversions<
typename std::decay<Ts>::type>::type...>>::type,
ResponseHandleTag>
sync_send(const typed_actor<Rs...>& dest, Ts&&... what) {
return sync_send_impl(
message_priority::normal, dest,
detail::type_list<typename detail::implicit_conversions<
typename std::decay<Ts>::type>::type...>{},
make_message(std::forward<Ts>(what)...));
} }
/************************************************************************** /****************************************************************************
* timed_sync_send[_tuple](typed_actor<...>, ...) * * timed_sync_send(...) *
**************************************************************************/ ****************************************************************************/
/* /**
template <class... Rs, class... Ts> * Sends `{vs...}` as a synchronous message to `dest` with priority `prio`
response_handle< * and relative timeout `rtime`.
Subtype, * @returns A handle identifying a future-like handle to the response.
typename detail::deduce_output_type< * @warning The returned handle is actor specific and the response to the
detail::type_list<Rs...>, * sent message cannot be received by another actor.
detail::type_list<Ts...> * @throws std::invalid_argument if `dest == invalid_actor`
>::type, */
ResponseHandleTag template <class... Vs>
> response_handle_type timed_sync_send(message_priority prio, const actor& dest,
timed_sync_send_tuple(message_priority prio, const duration& rtime, Vs&&... vs) {
const typed_actor<Rs...>& dest, static_assert(sizeof...(Vs) > 0, "no message to send");
const duration& rtime, return {dptr()->timed_sync_send_impl(prio, dest, rtime,
cow_tuple<Ts...> what) { make_message(std::forward<Vs>(vs)...)),
return {dptr()->timed_sync_send_tuple_impl(prio, dest, rtime,
std::move(what)),
dptr()}; dptr()};
} }
template <class... Rs, class... Ts> /**
response_handle< * Sends `{vs...}` as a synchronous message to `dest` with
Subtype, * relative timeout `rtime`.
typename detail::deduce_output_type< * @returns A handle identifying a future-like handle to the response.
detail::type_list<Rs...>, * @warning The returned handle is actor specific and the response to the
detail::type_list<Ts...> * sent message cannot be received by another actor.
>::type, * @throws std::invalid_argument if `dest == invalid_actor`
ResponseHandleTag
>
timed_sync_send_tuple(const typed_actor<Rs...>& dest,
const duration& rtime,
cow_tuple<Ts...> what) {
return {dptr()->timed_sync_send_tuple_impl(message_priority::normal,
dest, rtime,
std::move(what)),
dptr()};
}
*/ */
template <class... Vs>
response_handle_type timed_sync_send(const actor& dest, const duration& rtime,
Vs&&... vs) {
return timed_sync_send(message_priority::normal, dest, rtime,
std::forward<Vs>(vs)...);
}
template <class... Rs, class... Ts> /**
response_handle< * Sends `{vs...}` as a synchronous message to `dest` with priority `prio`
Subtype, * and relative timeout `rtime`.
* @returns A handle identifying a future-like handle to the response.
* @warning The returned handle is actor specific and the response to the
* sent message cannot be received by another actor.
* @throws std::invalid_argument if `dest == invalid_actor`
*/
template <class... Rs, class... Vs>
response_handle<Subtype,
typename detail::deduce_output_type< typename detail::deduce_output_type<
detail::type_list<Rs...>, detail::type_list<Rs...>,
typename detail::implicit_conversions< typename detail::implicit_conversions<
typename std::decay<Ts>::type>::type...>::type, typename std::decay<Vs>::type
ResponseHandleTag> >::type...
>::type,
HandleTag>
timed_sync_send(message_priority prio, const typed_actor<Rs...>& dest, timed_sync_send(message_priority prio, const typed_actor<Rs...>& dest,
const duration& rtime, Ts&&... what) { const duration& rtime, Vs&&... vs) {
static_assert(sizeof...(Ts) > 0, "no message to send"); static_assert(sizeof...(Vs) > 0, "no message to send");
return timed_sync_send_tuple(prio, dest, rtime, using token =
make_message(std::forward<Ts>(what)...)); detail::type_list<
typename detail::implicit_conversions<
typename std::decay<Vs>::type
>::type...>;
token tk;
check_typed_input(dest, tk);
return {dptr()->timed_sync_send_impl(prio, actor_cast<actor>(dest), rtime,
make_message(std::forward<Vs>(vs)...)),
dptr()};
} }
template <class... Rs, class... Ts> /**
response_handle< * Sends `{vs...}` as a synchronous message to `dest` with
Subtype, * relative timeout `rtime`.
* @returns A handle identifying a future-like handle to the response.
* @warning The returned handle is actor specific and the response to the
* sent message cannot be received by another actor.
* @throws std::invalid_argument if `dest == invalid_actor`
*/
template <class... Rs, class... Vs>
response_handle<Subtype,
typename detail::deduce_output_type< typename detail::deduce_output_type<
detail::type_list<Rs...>, detail::type_list<Rs...>,
typename detail::implicit_conversions< typename detail::implicit_conversions<
typename std::decay<Ts>::type>::type...>::type, typename std::decay<Vs>::type
ResponseHandleTag> >::type...
>::type,
HandleTag>
timed_sync_send(const typed_actor<Rs...>& dest, const duration& rtime, timed_sync_send(const typed_actor<Rs...>& dest, const duration& rtime,
Ts&&... what) { Vs&&... vs) {
static_assert(sizeof...(Ts) > 0, "no message to send"); return timed_sync_send(message_priority::normal, dest, rtime,
return timed_sync_send_tuple(message_priority::normal, dest, rtime, std::forward<Vs>(vs)...);
make_message(std::forward<Ts>(what)...));
} }
private: // <backward_compatibility version="0.9">
/****************************************************************************
* outdated member functions *
****************************************************************************/
template <class... Rs, class... Ts> response_handle_type sync_send_tuple(message_priority prio, const actor& dest,
response_handle< message what) CAF_DEPRECATED;
Subtype, typename detail::deduce_output_type<
detail::type_list<Rs...>, detail::type_list<Ts...>>::type,
ResponseHandleTag>
sync_send_impl(message_priority prio, const typed_actor<Rs...>& dest,
detail::type_list<Ts...> token, message&& what) {
check_typed_input(dest, token);
return {dptr()->sync_send_tuple_impl(prio, dest, std::move(what)),
dptr()};
}
inline Subtype* dptr() { return static_cast<Subtype*>(this); } response_handle_type sync_send_tuple(const actor& dest,
message what) CAF_DEPRECATED;
response_handle_type timed_sync_send_tuple(message_priority prio,
const actor& dest,
const duration& rtime,
message what) CAF_DEPRECATED;
response_handle_type timed_sync_send_tuple(const actor& dest,
const duration& rtime,
message what) CAF_DEPRECATED;
// </backward_compatibility>
private:
Subtype* dptr() {
return static_cast<Subtype*>(this);
}
}; };
template <class ResponseHandleTag> template <class ResponseHandleTag>
class sync_sender { class sync_sender {
public: public:
template <class Base, class Subtype> template <class Base, class Subtype>
using impl = sync_sender_impl<Base, Subtype, ResponseHandleTag>; using impl = sync_sender_impl<Base, Subtype, ResponseHandleTag>;
}; };
// <backward_compatibility version="0.9">
template <class B, class S, class H>
typename sync_sender_impl<B, S, H>::response_handle_type
sync_sender_impl<B, S, H>::sync_send_tuple(message_priority prio,
const actor& dest, message what) {
return sync_send(prio, dest, std::move(what));
}
template <class B, class S, class H>
typename sync_sender_impl<B, S, H>::response_handle_type
sync_sender_impl<B, S, H>::sync_send_tuple(const actor& dest, message what) {
return sync_send(message_priority::normal, dest, std::move(what));
}
template <class B, class S, class H>
typename sync_sender_impl<B, S, H>::response_handle_type
sync_sender_impl<B, S, H>::timed_sync_send_tuple(message_priority prio,
const actor& dest,
const duration& rtime,
message msg) {
return timed_sync_send(prio, dest, rtime, std::move(msg));
}
template <class B, class S, class H>
typename sync_sender_impl<B, S, H>::response_handle_type
sync_sender_impl<B, S, H>::timed_sync_send_tuple(const actor& dest,
const duration& rtime,
message msg) {
return timed_sync_send(message_priority::normal, dest, rtime, std::move(msg));
}
// </backward_compatibility>
} // namespace mixin } // namespace mixin
} // namespace caf } // namespace caf
......
...@@ -179,14 +179,12 @@ void local_actor::quit(uint32_t reason) { ...@@ -179,14 +179,12 @@ void local_actor::quit(uint32_t reason) {
} }
} }
message_id local_actor::timed_sync_send_tuple_impl(message_priority mp, message_id local_actor::timed_sync_send_impl(message_priority mp,
const actor& dest, const actor& dest,
const duration& rtime, const duration& rtime,
message&& what) { message&& what) {
if (!dest) { if (!dest) {
throw std::invalid_argument( throw std::invalid_argument("cannot sync_send to invalid_actor");
"cannot send synchronous message "
"to invalid_actor");
} }
auto nri = new_request_id(); auto nri = new_request_id();
if (mp == message_priority::high) { if (mp == message_priority::high) {
...@@ -200,13 +198,11 @@ message_id local_actor::timed_sync_send_tuple_impl(message_priority mp, ...@@ -200,13 +198,11 @@ message_id local_actor::timed_sync_send_tuple_impl(message_priority mp,
return rri; return rri;
} }
message_id local_actor::sync_send_tuple_impl(message_priority mp, message_id local_actor::sync_send_impl(message_priority mp,
const actor& dest, const actor& dest,
message&& what) { message&& what) {
if (!dest) { if (!dest) {
throw std::invalid_argument( throw std::invalid_argument("cannot sync_send to invalid_actor");
"cannot send synchronous message "
"to invalid_actor");
} }
auto nri = new_request_id(); auto nri = new_request_id();
if (mp == message_priority::high) { if (mp == message_priority::high) {
......
...@@ -158,7 +158,7 @@ class D : public popular_actor { ...@@ -158,7 +158,7 @@ class D : public popular_actor {
behavior make_behavior() override { behavior make_behavior() override {
return { return {
others() >> [=] { others() >> [=] {
return sync_send_tuple(buddy(), last_dequeued()).then( return sync_send(buddy(), last_dequeued()).then(
others() >> [=]() -> message { others() >> [=]() -> message {
quit(); quit();
return last_dequeued(); return last_dequeued();
......
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