Commit e1f51dc0 authored by Dominik Charousset's avatar Dominik Charousset

fixed bug in timed_sync_send

parent f543c4a1
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <type_traits> #include <type_traits>
#include "cppa/behavior.hpp" #include "cppa/behavior.hpp"
#include "cppa/to_string.hpp"
#include "cppa/message_id.hpp" #include "cppa/message_id.hpp"
#include "cppa/exit_reason.hpp" #include "cppa/exit_reason.hpp"
#include "cppa/partial_function.hpp" #include "cppa/partial_function.hpp"
...@@ -133,8 +134,8 @@ class receive_policy { ...@@ -133,8 +134,8 @@ class receive_policy {
template<class Client, class FunOrBehavior> template<class Client, class FunOrBehavior>
inline void receive_wo_timeout(Client *client, FunOrBehavior& fun) { inline void receive_wo_timeout(Client *client, FunOrBehavior& fun) {
if (invoke_from_cache(client, fun) == false) { if (!invoke_from_cache(client, fun)) {
while (invoke(client, client->receive_node(), fun) == false) { } while (!invoke(client, client->receive_node(), fun)) { }
} }
} }
...@@ -145,10 +146,10 @@ class receive_policy { ...@@ -145,10 +146,10 @@ class receive_policy {
template<class Client> template<class Client>
void receive(Client* client, behavior& bhvr) { void receive(Client* client, behavior& bhvr) {
if (bhvr.timeout().valid() == false) { if (!bhvr.timeout().valid()) {
receive_wo_timeout(client, bhvr); receive_wo_timeout(client, bhvr);
} }
else if (invoke_from_cache(client, bhvr) == false) { else if (!invoke_from_cache(client, bhvr)) {
if (bhvr.timeout().is_zero()) { if (bhvr.timeout().is_zero()) {
pointer e = nullptr; pointer e = nullptr;
while ((e = client->try_receive_node()) != nullptr) { while ((e = client->try_receive_node()) != nullptr) {
...@@ -174,19 +175,24 @@ class receive_policy { ...@@ -174,19 +175,24 @@ class receive_policy {
} }
template<class Client> template<class Client>
void receive(Client* client, behavior& bhvr, message_id_t awaited_response) { void receive(Client* client, behavior& bhvr, message_id_t mid) {
CPPA_REQUIRE(bhvr.timeout().valid()); CPPA_REQUIRE(mid.is_response());
CPPA_REQUIRE(bhvr.timeout().is_zero() == false); if (!invoke_from_cache(client, bhvr, mid)) {
if (invoke_from_cache(client, bhvr, awaited_response) == false) { if (bhvr.timeout().valid()) {
auto timeout = client->init_timeout(bhvr.timeout()); CPPA_REQUIRE(bhvr.timeout().is_zero() == false);
pointer e = nullptr; auto timeout = client->init_timeout(bhvr.timeout());
while ((e = client->try_receive_node(timeout)) != nullptr) { pointer e = nullptr;
CPPA_REQUIRE(e->marked == false); while ((e = client->try_receive_node(timeout)) != nullptr) {
if (invoke(client, e, bhvr, awaited_response)) { CPPA_REQUIRE(e->marked == false);
return; // done if (invoke(client, e, bhvr, mid)) {
return; // done
}
} }
handle_timeout(client, bhvr);
}
else {
while (!invoke(client, client->receive_node(), bhvr, mid)) { }
} }
handle_timeout(client, bhvr);
} }
} }
......
...@@ -141,9 +141,10 @@ void event_based_actor::do_become(behavior&& bhvr, bool discard_old) { ...@@ -141,9 +141,10 @@ void event_based_actor::do_become(behavior&& bhvr, bool discard_old) {
} }
void event_based_actor::become_waiting_for(behavior&& bhvr, message_id_t mf) { void event_based_actor::become_waiting_for(behavior&& bhvr, message_id_t mf) {
CPPA_REQUIRE(bhvr.timeout().valid()); if (bhvr.timeout().valid()) {
reset_timeout(); reset_timeout();
request_timeout(bhvr.timeout()); request_timeout(bhvr.timeout());
}
m_bhvr_stack.push_back(std::move(bhvr), mf); m_bhvr_stack.push_back(std::move(bhvr), mf);
} }
......
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