Commit dd826000 authored by Dominik Charousset's avatar Dominik Charousset

fixed continuation handling

continuation is called only if given functor is invoked
parent 7f9d99c4
......@@ -119,6 +119,20 @@ class projection {
return false;
}
/**
* @brief Invokes @p fun with a projection of <tt>args...</tt> and stores
* the result of @p fun in @p result.
*/
template<class PartialFun>
inline bool operator()(PartialFun& fun, typename PartialFun::result_type& result, Args... args) const {
return invoke(fun, result, args...);
}
template<class PartialFun>
inline bool operator()(PartialFun& fun, const util::void_type&, Args... args) const {
return (*this)(fun, args...);
}
private:
template<typename Storage, typename T>
......@@ -181,6 +195,24 @@ class projection<util::empty_type_list> {
return false;
}
template<class PartialFun>
bool operator()(PartialFun& fun, const util::void_type&) const {
if (fun.defined_at()) {
fun();
return true;
}
return false;
}
template<class PartialFun>
bool operator()(PartialFun& fun, typename PartialFun::result_type& res) const {
if (fun.defined_at()) {
res = fun();
return true;
}
return false;
}
};
template<class ProjectionFuns, class List>
......
......@@ -49,7 +49,7 @@ struct pseudo_tuple {
}
inline pointer mutable_at(size_t p) {
return const_cast<pointer>(data[p]);
return data[p];
}
inline pointer& operator[](size_t p) {
......
......@@ -359,14 +359,7 @@ class receive_policy {
case sync_response: {
if (awaited_response.valid() && node->mid == awaited_response) {
auto previous_node = hm_begin(client, node, policy);
# ifdef CPPA_DEBUG
if (!fun(node->msg)) {
std::cerr << "WARNING: actor didn't handle a "
"synchronous message\n";
}
# else
fun(node->msg);
# endif
client->mark_arrived(awaited_response);
client->remove_handler(awaited_response);
hm_cleanup(client, previous_node, policy);
......
This diff is collapsed.
......@@ -136,7 +136,12 @@ class message_future {
template<typename F>
behavior bhvr_from_fun(F fun) {
auto handle_sync_failure = [] { self->handle_sync_failure(); };
auto handle_sync_failure = []() -> bool {
self->handle_sync_failure();
return false; // do not treat this as a match to cause a
// continuation to be invoked only in case
// `fun` was invoked
};
return {
on(atom("EXITED"), any_vals) >> handle_sync_failure,
on(atom("TIMEOUT")) >> handle_sync_failure,
......
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