Commit 637d7d9a authored by Dominik Charousset's avatar Dominik Charousset

got rid of 'reply is deprecated' warnings

parent a781875b
...@@ -87,7 +87,7 @@ class actor_companion_mixin : public Base { ...@@ -87,7 +87,7 @@ class actor_companion_mixin : public Base {
/** /**
* @brief Defines the message handler. * @brief Defines the message handler.
* @note While the message handler is invoked, @p self will point * @note While the message handler is invoked, @p self will point
* to the companion object to enable send() and reply(). * to the companion object to enable function calls to send().
*/ */
template<typename... Ts> template<typename... Ts>
void set_message_handler(Ts&&... args) { void set_message_handler(Ts&&... args) {
...@@ -97,7 +97,7 @@ class actor_companion_mixin : public Base { ...@@ -97,7 +97,7 @@ class actor_companion_mixin : public Base {
/** /**
* @brief Invokes the message handler with @p msg. * @brief Invokes the message handler with @p msg.
* @note While the message handler is invoked, @p self will point * @note While the message handler is invoked, @p self will point
* to the companion object to enable send() and reply(). * to the companion object to enable function calls to send().
*/ */
void handle_message(const message_pointer& msg) { void handle_message(const message_pointer& msg) {
if (!msg) return; if (!msg) return;
......
...@@ -87,6 +87,13 @@ class any_tuple { ...@@ -87,6 +87,13 @@ class any_tuple {
template<typename... Ts> template<typename... Ts>
any_tuple(cow_tuple<Ts...>&& arg) : m_vals(std::move(arg.m_vals)) { } any_tuple(cow_tuple<Ts...>&& arg) : m_vals(std::move(arg.m_vals)) { }
/**
* @brief Creates a tuple from a set of values.
*/
template<typename T, typename... Ts>
any_tuple(T v0, Ts&&... vs)
: m_vals(make_cow_tuple(std::move(v0), std::forward<Ts>(vs)...).vals()) { }
/** /**
* @brief Move constructor. * @brief Move constructor.
*/ */
......
...@@ -276,7 +276,7 @@ ...@@ -276,7 +276,7 @@
* on(atom("compute"), arg_match) >> [](int i0, int i1, int i2) * on(atom("compute"), arg_match) >> [](int i0, int i1, int i2)
* { * {
* // send our result back to the sender of this messages * // send our result back to the sender of this messages
* reply(atom("result"), i0 + i1 + i2); * return make_cow_tuple(atom("result"), i0 + i1 + i2);
* } * }
* ); * );
* @endcode * @endcode
...@@ -296,10 +296,10 @@ ...@@ -296,10 +296,10 @@
* void math_actor() { * void math_actor() {
* receive_loop ( * receive_loop (
* on(atom("plus"), arg_match) >> [](int a, int b) { * on(atom("plus"), arg_match) >> [](int a, int b) {
* reply(atom("result"), a + b); * return make_cow_tuple(atom("result"), a + b);
* }, * },
* on(atom("minus"), arg_match) >> [](int a, int b) { * on(atom("minus"), arg_match) >> [](int a, int b) {
* reply(atom("result"), a - b); * return make_cow_tuple(atom("result"), a - b);
* } * }
* ); * );
* } * }
...@@ -340,7 +340,7 @@ ...@@ -340,7 +340,7 @@
* std::vector<int> vec {1, 2, 3, 4}; * std::vector<int> vec {1, 2, 3, 4};
* auto i = vec.begin(); * auto i = vec.begin();
* receive_for(i, vec.end()) ( * receive_for(i, vec.end()) (
* on(atom("get")) >> [&]() { reply(atom("result"), *i); } * on(atom("get")) >> [&]() -> any_tuple { return {atom("result"), *i}; }
* ); * );
* @endcode * @endcode
* *
...@@ -654,6 +654,11 @@ inline const actor_ostream& operator<<(const actor_ostream& o, const any_tuple& ...@@ -654,6 +654,11 @@ inline const actor_ostream& operator<<(const actor_ostream& o, const any_tuple&
return o.write(cppa::to_string(arg)); return o.write(cppa::to_string(arg));
} }
// disambiguate between conversion to string and to any_tuple
inline const actor_ostream& operator<<(const actor_ostream& o, const char* arg) {
return o << std::string{arg};
}
template<typename T> template<typename T>
inline typename std::enable_if< inline typename std::enable_if<
!std::is_convertible<T, std::string>::value !std::is_convertible<T, std::string>::value
......
...@@ -184,8 +184,6 @@ class local_actor : public extend<actor>::with<memory_cached> { ...@@ -184,8 +184,6 @@ class local_actor : public extend<actor>::with<memory_cached> {
/** /**
* @brief Returns the sender of the last dequeued message. * @brief Returns the sender of the last dequeued message.
* @warning Only set during callback invocation. * @warning Only set during callback invocation.
* @note Implicitly used by the function {@link cppa::reply}.
* @see cppa::reply()
*/ */
inline actor_ptr& last_sender(); inline actor_ptr& last_sender();
......
...@@ -440,6 +440,17 @@ std::ostream& operator<<(std::ostream& lhs, const optional_variant<T0, Ts...>& r ...@@ -440,6 +440,17 @@ std::ostream& operator<<(std::ostream& lhs, const optional_variant<T0, Ts...>& r
return apply_visitor(detail::optional_variant_ostream_helper{lhs}, rhs); return apply_visitor(detail::optional_variant_ostream_helper{lhs}, rhs);
} }
template<typename T, typename... Ts>
optional_variant<T, typename util::rm_const_and_ref<Ts>::type...>
make_optional_variant(T value, Ts&&... args) {
return {std::move(value), std::forward<Ts>(args)...};
}
template<typename... Ts>
inline optional_variant<Ts...> make_optional_variant(optional_variant<Ts...> value) {
return std::move(value);
}
} // namespace cppa } // namespace cppa
#endif // OPTIONAL_VARIANT_HPP #endif // OPTIONAL_VARIANT_HPP
...@@ -67,7 +67,7 @@ void receive_loop(Ts&&... args); ...@@ -67,7 +67,7 @@ void receive_loop(Ts&&... args);
* @code * @code
* int i = 0; * int i = 0;
* receive_for(i, 10) ( * receive_for(i, 10) (
* on(atom("get")) >> [&]() { reply("result", i); } * on(atom("get")) >> [&]() -> any_tuple { return {"result", i}; }
* ); * );
* @endcode * @endcode
* @param begin First value in range. * @param begin First value in range.
......
...@@ -41,6 +41,10 @@ namespace cppa { ...@@ -41,6 +41,10 @@ namespace cppa {
struct typed_actor_result_visitor { struct typed_actor_result_visitor {
typed_actor_result_visitor() : m_hdl(self->make_response_handle()) { }
typed_actor_result_visitor(response_handle hdl) : m_hdl(hdl) { }
inline void operator()(const none_t&) const { inline void operator()(const none_t&) const {
CPPA_LOG_ERROR("a typed actor received a " CPPA_LOG_ERROR("a typed actor received a "
"non-matching message: " "non-matching message: "
...@@ -51,29 +55,27 @@ struct typed_actor_result_visitor { ...@@ -51,29 +55,27 @@ struct typed_actor_result_visitor {
template<typename T> template<typename T>
inline void operator()(T& value) const { inline void operator()(T& value) const {
reply(std::move(value)); reply_to(m_hdl, std::move(value));
} }
template<typename... Ts> template<typename... Ts>
inline void operator()(cow_tuple<Ts...>& value) const { inline void operator()(cow_tuple<Ts...>& value) const {
reply_tuple(std::move(value)); reply_tuple_to(m_hdl, std::move(value));
} }
template<typename R> template<typename R>
inline void operator()(typed_continue_helper<R>& ch) const { inline void operator()(typed_continue_helper<R>& ch) const {
auto hdl = self->make_response_handle(); auto hdl = m_hdl;
ch.continue_with([=](R value) { ch.continue_with([=](R value) {
reply_to(hdl, std::move(value)); typed_actor_result_visitor tarv{hdl};
auto ov = make_optional_variant(std::move(value));
apply_visitor(tarv, ov);
}); });
} }
template<typename... Rs> private:
inline void operator()(typed_continue_helper<cow_tuple<Rs...>>& ch) const {
auto hdl = self->make_response_handle(); response_handle m_hdl;
ch.continue_with([=](cow_tuple<Rs...> value) {
reply_tuple_to(hdl, std::move(value));
});
}
}; };
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <sstream>
#include <algorithm> #include <algorithm>
#include <type_traits> #include <type_traits>
...@@ -47,12 +48,14 @@ std::vector<std::string> split(const std::string& str, ...@@ -47,12 +48,14 @@ std::vector<std::string> split(const std::string& str,
template<typename Iterator> template<typename Iterator>
typename std::enable_if<is_forward_iterator<Iterator>::value,std::string>::type typename std::enable_if<is_forward_iterator<Iterator>::value,std::string>::type
join(Iterator begin, Iterator end, const std::string& glue = "") { join(Iterator begin, Iterator end, const std::string& glue = "") {
std::string result; bool first = true;
std::for_each(begin, end, [&](const std::string& str) { std::ostringstream oss;
if (!result.empty()) result += glue; for ( ; begin != end; ++begin) {
result += str; if (first) first = false;
}); else oss << glue;
return result; oss << *begin;
}
return oss.str();
} }
template<typename Container> template<typename Container>
......
...@@ -28,11 +28,11 @@ using namespace cppa::placeholders; ...@@ -28,11 +28,11 @@ using namespace cppa::placeholders;
// our "service" // our "service"
void calculator() { void calculator() {
become ( become (
on(atom("plus"), arg_match) >> [](int a, int b) { on(atom("plus"), arg_match) >> [](int a, int b) -> any_tuple {
reply(atom("result"), a + b); return {atom("result"), a + b};
}, },
on(atom("minus"), arg_match) >> [](int a, int b) { on(atom("minus"), arg_match) >> [](int a, int b) -> any_tuple {
reply(atom("result"), a - b); return {atom("result"), a - b};
}, },
on(atom("quit")) >> [=]() { on(atom("quit")) >> [=]() {
self->quit(); self->quit();
......
...@@ -61,10 +61,10 @@ void ping(size_t num_pings) { ...@@ -61,10 +61,10 @@ void ping(size_t num_pings) {
on(atom("kickoff"), arg_match) >> [=](const actor_ptr& pong) { on(atom("kickoff"), arg_match) >> [=](const actor_ptr& pong) {
send(pong, atom("ping"), 1); send(pong, atom("ping"), 1);
become ( become (
on(atom("pong"), arg_match) >> [=](int value) { on(atom("pong"), arg_match) >> [=](int value) -> any_tuple {
aout << "pong: " << value << endl; aout << "pong: " << value << endl;
if (++*count >= num_pings) self->quit_later(); if (++*count >= num_pings) self->quit();
else reply(atom("ping"), value + 1); return {atom("ping"), value + 1};
} }
); );
} }
......
...@@ -597,7 +597,7 @@ class default_meta_tuple : public uniform_type_info { ...@@ -597,7 +597,7 @@ class default_meta_tuple : public uniform_type_info {
} }
any_tuple as_any_tuple(void* ptr) const override { any_tuple as_any_tuple(void* ptr) const override {
return any_tuple{cast(ptr)}; return any_tuple{static_cast<any_tuple::raw_ptr>(cast(ptr))};
} }
const char* name() const override { const char* name() const override {
......
...@@ -17,7 +17,7 @@ size_t s_pongs = 0; ...@@ -17,7 +17,7 @@ size_t s_pongs = 0;
behavior ping_behavior(size_t num_pings) { behavior ping_behavior(size_t num_pings) {
return ( return (
on(atom("pong"), arg_match) >> [num_pings](int value) { on(atom("pong"), arg_match) >> [num_pings](int value) -> any_tuple {
CPPA_LOGF_ERROR_IF(!self->last_sender(), "last_sender() == nullptr"); CPPA_LOGF_ERROR_IF(!self->last_sender(), "last_sender() == nullptr");
CPPA_LOGF_INFO("received {'pong', " << value << "}"); CPPA_LOGF_INFO("received {'pong', " << value << "}");
//cout << to_string(self->last_dequeued()) << endl; //cout << to_string(self->last_dequeued()) << endl;
...@@ -27,7 +27,7 @@ behavior ping_behavior(size_t num_pings) { ...@@ -27,7 +27,7 @@ behavior ping_behavior(size_t num_pings) {
send_exit(self->last_sender(), exit_reason::user_defined); send_exit(self->last_sender(), exit_reason::user_defined);
self->quit(); self->quit();
} }
else reply(atom("ping"), value); return {atom("ping"), value};
}, },
others() >> [] { others() >> [] {
CPPA_LOGF_ERROR("unexpected message; " CPPA_LOGF_ERROR("unexpected message; "
...@@ -39,9 +39,9 @@ behavior ping_behavior(size_t num_pings) { ...@@ -39,9 +39,9 @@ behavior ping_behavior(size_t num_pings) {
behavior pong_behavior() { behavior pong_behavior() {
return ( return (
on(atom("ping"), arg_match) >> [](int value) { on(atom("ping"), arg_match) >> [](int value) -> any_tuple {
CPPA_LOGF_INFO("received {'ping', " << value << "}"); CPPA_LOGF_INFO("received {'ping', " << value << "}");
reply(atom("pong"), value + 1); return {atom("pong"), value + 1};
}, },
others() >> [] { others() >> [] {
CPPA_LOGF_ERROR("unexpected message; " CPPA_LOGF_ERROR("unexpected message; "
......
...@@ -45,9 +45,10 @@ void ping(size_t num_pings) { ...@@ -45,9 +45,10 @@ void ping(size_t num_pings) {
on(atom("kickoff"), arg_match) >> [=](const actor_ptr& pong) { on(atom("kickoff"), arg_match) >> [=](const actor_ptr& pong) {
send(pong, atom("ping"), 1); send(pong, atom("ping"), 1);
become ( become (
on(atom("pong"), arg_match) >> [=](int value) { on(atom("pong"), arg_match)
>> [=](int value) -> cow_tuple<atom_value, int> {
if (++*count >= num_pings) self->quit(); if (++*count >= num_pings) self->quit();
else reply(atom("ping"), value + 1); return make_cow_tuple(atom("ping"), value + 1);
}, },
others() >> CPPA_UNEXPECTED_MSG_CB() others() >> CPPA_UNEXPECTED_MSG_CB()
); );
...@@ -58,18 +59,21 @@ void ping(size_t num_pings) { ...@@ -58,18 +59,21 @@ void ping(size_t num_pings) {
void pong() { void pong() {
become ( become (
on(atom("ping"), arg_match) >> [](int value) { on(atom("ping"), arg_match)
>> [](int value) -> cow_tuple<atom_value, int> {
self->monitor(self->last_sender()); self->monitor(self->last_sender());
reply(atom("pong"), value); // set next behavior
become ( become (
on(atom("ping"), arg_match) >> [](int value) { on(atom("ping"), arg_match) >> [](int value) {
reply(atom("pong"), value); return make_cow_tuple(atom("pong"), value);
}, },
on(atom("DOWN"), arg_match) >> [=](uint32_t reason) { on(atom("DOWN"), arg_match) >> [=](uint32_t reason) {
self->quit(reason); self->quit(reason);
}, },
others() >> CPPA_UNEXPECTED_MSG_CB() others() >> CPPA_UNEXPECTED_MSG_CB()
); );
// reply to 'ping'
return {atom("pong"), value};
}, },
others() >> CPPA_UNEXPECTED_MSG_CB() others() >> CPPA_UNEXPECTED_MSG_CB()
); );
......
...@@ -367,7 +367,7 @@ template<typename... Ts> ...@@ -367,7 +367,7 @@ template<typename... Ts>
any_tuple make_dynamically_typed(Ts&&... args) { any_tuple make_dynamically_typed(Ts&&... args) {
auto oarr = new detail::object_array; auto oarr = new detail::object_array;
make_dynamically_typed_impl(*oarr, std::forward<Ts>(args)...); make_dynamically_typed_impl(*oarr, std::forward<Ts>(args)...);
return any_tuple{oarr}; return any_tuple{static_cast<any_tuple::raw_ptr>(oarr)};
} }
void test_wildcards() { void test_wildcards() {
......
...@@ -25,8 +25,8 @@ void reflector() { ...@@ -25,8 +25,8 @@ void reflector() {
become ( become (
others() >> [=] { others() >> [=] {
CPPA_LOGF_INFO("reflect and quit"); CPPA_LOGF_INFO("reflect and quit");
reply_tuple(self->last_dequeued());
self->quit(); self->quit();
return self->last_dequeued();
} }
); );
} }
...@@ -111,17 +111,17 @@ void spawn5_server(actor_ptr client, bool inverted) { ...@@ -111,17 +111,17 @@ void spawn5_server(actor_ptr client, bool inverted) {
void spawn5_client() { void spawn5_client() {
CPPA_SET_DEBUG_NAME("spawn5_client"); CPPA_SET_DEBUG_NAME("spawn5_client");
become ( become (
on(atom("GetGroup")) >> [] { on(atom("GetGroup")) >> []() -> group_ptr {
CPPA_LOGF_INFO("received {'GetGroup'}"); CPPA_LOGF_INFO("received {'GetGroup'}");
reply(group::get("local", "foobar")); return group::get("local", "foobar");
}, },
on(atom("Spawn5"), arg_match) >> [=](const group_ptr& grp) { on(atom("Spawn5"), arg_match) >> [=](const group_ptr& grp) -> any_tuple {
CPPA_LOGF_INFO("received {'Spawn5'}"); CPPA_LOGF_INFO("received {'Spawn5'}");
actor_vector vec; actor_vector vec;
for (int i = 0; i < 5; ++i) { for (int i = 0; i < 5; ++i) {
vec.push_back(spawn_in_group(grp, reflector)); vec.push_back(spawn_in_group(grp, reflector));
} }
reply(atom("ok"), std::move(vec)); return {atom("ok"), std::move(vec)};
}, },
on(atom("Spawn5Done")) >> [] { on(atom("Spawn5Done")) >> [] {
CPPA_LOGF_INFO("received {'Spawn5Done'}"); CPPA_LOGF_INFO("received {'Spawn5Done'}");
...@@ -211,14 +211,15 @@ class client : public event_based_actor { ...@@ -211,14 +211,15 @@ class client : public event_based_actor {
void test_group_comm_inverted() { void test_group_comm_inverted() {
CPPA_PRINT("test group communication via network (inverted setup)"); CPPA_PRINT("test group communication via network (inverted setup)");
become ( become (
on(atom("GClient")) >> [=] { on(atom("GClient")) >> [=]() -> any_tuple {
auto cptr = self->last_sender(); auto cptr = self->last_sender();
auto s5c = spawn<monitored>(spawn5_client); auto s5c = spawn<monitored>(spawn5_client);
reply(atom("GClient"), s5c); // set next behavior
await_down(s5c, [=] { await_down(s5c, [=] {
CPPA_CHECKPOINT(); CPPA_CHECKPOINT();
self->quit(); self->quit();
}); });
return {atom("GClient"), s5c};
} }
); );
} }
...@@ -241,18 +242,18 @@ class server : public event_based_actor { ...@@ -241,18 +242,18 @@ class server : public event_based_actor {
void await_spawn_ping() { void await_spawn_ping() {
CPPA_PRINT("await {'SpawnPing'}"); CPPA_PRINT("await {'SpawnPing'}");
become ( become (
on(atom("SpawnPing")) >> [=] { on(atom("SpawnPing")) >> [=]() -> any_tuple {
CPPA_PRINT("received {'SpawnPing'}"); CPPA_PRINT("received {'SpawnPing'}");
auto client = self->last_sender(); auto client = self->last_sender();
CPPA_LOGF_ERROR_IF(!client, "last_sender() == nullptr"); CPPA_LOGF_ERROR_IF(!client, "last_sender() == nullptr");
CPPA_LOGF_INFO("spawn event-based ping actor"); CPPA_LOGF_INFO("spawn event-based ping actor");
auto pptr = spawn<monitored>(event_based_ping, num_pings); auto pptr = spawn<monitored>(event_based_ping, num_pings);
reply(atom("PingPtr"), pptr);
CPPA_LOGF_INFO("wait until spawned ping actor is done"); CPPA_LOGF_INFO("wait until spawned ping actor is done");
await_down(pptr, [=] { await_down(pptr, [=] {
CPPA_CHECK_EQUAL(pongs(), num_pings); CPPA_CHECK_EQUAL(pongs(), num_pings);
await_sync_msg(); await_sync_msg();
}); });
return {atom("PingPtr"), pptr};
} }
); );
} }
...@@ -260,11 +261,11 @@ class server : public event_based_actor { ...@@ -260,11 +261,11 @@ class server : public event_based_actor {
void await_sync_msg() { void await_sync_msg() {
CPPA_PRINT("await {'SyncMsg'}"); CPPA_PRINT("await {'SyncMsg'}");
become ( become (
on(atom("SyncMsg"), arg_match) >> [=](float f) { on(atom("SyncMsg"), arg_match) >> [=](float f) -> atom_value {
CPPA_PRINT("received {'SyncMsg', " << f << "}"); CPPA_PRINT("received {'SyncMsg', " << f << "}");
CPPA_CHECK_EQUAL(f, 4.2f); CPPA_CHECK_EQUAL(f, 4.2f);
reply(atom("SyncReply"));
await_foobars(); await_foobars();
return atom("SyncReply");
} }
); );
} }
...@@ -273,13 +274,13 @@ class server : public event_based_actor { ...@@ -273,13 +274,13 @@ class server : public event_based_actor {
CPPA_PRINT("await foobars"); CPPA_PRINT("await foobars");
auto foobars = make_shared<int>(0); auto foobars = make_shared<int>(0);
become ( become (
on(atom("foo"), atom("bar"), arg_match) >> [=](int i) { on(atom("foo"), atom("bar"), arg_match) >> [=](int i) -> any_tuple {
++*foobars; ++*foobars;
reply_tuple(self->last_dequeued());
if (i == 99) { if (i == 99) {
CPPA_CHECK_EQUAL(*foobars, 100); CPPA_CHECK_EQUAL(*foobars, 100);
test_group_comm(); test_group_comm();
} }
return self->last_dequeued();
} }
); );
} }
...@@ -287,13 +288,13 @@ class server : public event_based_actor { ...@@ -287,13 +288,13 @@ class server : public event_based_actor {
void test_group_comm() { void test_group_comm() {
CPPA_PRINT("test group communication via network"); CPPA_PRINT("test group communication via network");
become ( become (
on(atom("GClient")) >> [=] { on(atom("GClient")) >> [=]() -> any_tuple {
auto cptr = self->last_sender(); auto cptr = self->last_sender();
auto s5c = spawn<monitored>(spawn5_client); auto s5c = spawn<monitored>(spawn5_client);
reply(atom("GClient"), s5c);
await_down(s5c, [=] { await_down(s5c, [=] {
test_group_comm_inverted(cptr); test_group_comm_inverted(cptr);
}); });
return {atom("GClient"), s5c};
} }
); );
} }
......
...@@ -159,7 +159,7 @@ int main() { ...@@ -159,7 +159,7 @@ int main() {
oarr->push_back(object::from(static_cast<uint32_t>(42))); oarr->push_back(object::from(static_cast<uint32_t>(42)));
oarr->push_back(object::from("foo" )); oarr->push_back(object::from("foo" ));
any_tuple atuple1(oarr); any_tuple atuple1{static_cast<any_tuple::raw_ptr>(oarr)};
try { try {
auto opt = tuple_cast<uint32_t, string>(atuple1); auto opt = tuple_cast<uint32_t, string>(atuple1);
CPPA_CHECK(opt.valid()); CPPA_CHECK(opt.valid());
......
...@@ -227,10 +227,10 @@ class fixed_stack : public sb_actor<fixed_stack> { ...@@ -227,10 +227,10 @@ class fixed_stack : public sb_actor<fixed_stack> {
full = ( full = (
on(atom("push"), arg_match) >> [=](int) { }, on(atom("push"), arg_match) >> [=](int) { },
on(atom("pop")) >> [=]() { on(atom("pop")) >> [=]() -> any_tuple {
reply(atom("ok"), data.back());
data.pop_back(); data.pop_back();
become(filled); become(filled);
return {atom("ok"), data.back()};
} }
); );
...@@ -240,11 +240,12 @@ class fixed_stack : public sb_actor<fixed_stack> { ...@@ -240,11 +240,12 @@ class fixed_stack : public sb_actor<fixed_stack> {
if (data.size() == max_size) if (data.size() == max_size)
become(full); become(full);
}, },
on(atom("pop")) >> [=]() { on(atom("pop")) >> [=]() -> any_tuple {
reply(atom("ok"), data.back()); auto result = data.back();
data.pop_back(); data.pop_back();
if (data.empty()) if (data.empty())
become(empty); become(empty);
return {atom("ok"), result};
} }
); );
...@@ -264,9 +265,9 @@ class fixed_stack : public sb_actor<fixed_stack> { ...@@ -264,9 +265,9 @@ class fixed_stack : public sb_actor<fixed_stack> {
void echo_actor() { void echo_actor() {
become ( become (
others() >> [] { others() >> []() -> any_tuple {
reply_tuple(self->last_dequeued());
self->quit(exit_reason::normal); self->quit(exit_reason::normal);
return self->last_dequeued();
} }
); );
} }
...@@ -616,7 +617,7 @@ int main() { ...@@ -616,7 +617,7 @@ int main() {
} }
); );
vector<int> expected{9, 8, 7, 6, 5, 4, 3, 2, 1, 0}; vector<int> expected{9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
CPPA_CHECK(values == expected); CPPA_CHECK_EQUAL(util::join(values, ","), util::join(values, ","));
} }
// terminate st // terminate st
send_exit(st, exit_reason::user_defined); send_exit(st, exit_reason::user_defined);
...@@ -671,8 +672,9 @@ int main() { ...@@ -671,8 +672,9 @@ int main() {
on_arg_match >> [&](const string& str) { on_arg_match >> [&](const string& str) {
CPPA_CHECK(self->last_sender() != nullptr); CPPA_CHECK(self->last_sender() != nullptr);
CPPA_CHECK_EQUAL(str, "nothing"); CPPA_CHECK_EQUAL(str, "nothing");
reply("goodbye!");
self->quit(); self->quit();
// TODO: should return the value instead
send(self->last_sender(), "goodbye!");
}, },
after(chrono::minutes(1)) >> [] { after(chrono::minutes(1)) >> [] {
cerr << "PANIC!!!!" << endl; cerr << "PANIC!!!!" << endl;
...@@ -690,7 +692,7 @@ int main() { ...@@ -690,7 +692,7 @@ int main() {
send(sync_testee, "hi"); send(sync_testee, "hi");
receive ( receive (
on("whassup?") >> [&]() -> std::string { on("whassup?") >> [&]() -> std::string {
CPPA_CHECK(true); CPPA_CHECKPOINT();
// this is NOT a reply, it's just an asynchronous message // this is NOT a reply, it's just an asynchronous message
send(self->last_sender(), "a lot!"); send(self->last_sender(), "a lot!");
return "nothing"; return "nothing";
......
...@@ -76,9 +76,9 @@ struct B : popular_actor { ...@@ -76,9 +76,9 @@ struct B : popular_actor {
struct C : sb_actor<C> { struct C : sb_actor<C> {
behavior init_state = ( behavior init_state = (
on(atom("gogo")) >> [=] { on(atom("gogo")) >> [=]() -> atom_value {
reply(atom("gogogo"));
self->quit(); self->quit();
return atom("gogogo");
} }
); );
}; };
......
...@@ -90,10 +90,10 @@ optional<int> str2int(const std::string& str) { ...@@ -90,10 +90,10 @@ optional<int> str2int(const std::string& str) {
struct dummy_receiver : event_based_actor { struct dummy_receiver : event_based_actor {
void init() { void init() {
become( become(
on_arg_match >> [=](expensive_copy_struct& ecs) { on_arg_match >> [=](expensive_copy_struct& ecs) -> expensive_copy_struct {
ecs.value = 42; ecs.value = 42;
reply(std::move(ecs));
quit(); quit();
return std::move(ecs);
} }
); );
} }
......
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