Commit 446ec6cb authored by ufownl's avatar ufownl

Fix function view

Fix the compilation errors when the result of `function_view` is an
actor handle.
parent c9234ddb
...@@ -85,6 +85,21 @@ struct function_view_flattened_result<std::tuple<void>> { ...@@ -85,6 +85,21 @@ struct function_view_flattened_result<std::tuple<void>> {
using type = unit_t; using type = unit_t;
}; };
template <class T>
struct function_view_result {
T value;
};
template <class... Ts>
struct function_view_result<typed_actor<Ts...>> {
typed_actor<Ts...> value{unsafe_actor_handle_init};
};
template <>
struct function_view_result<actor> {
actor value{unsafe_actor_handle_init};
};
/// A function view for an actor hides any messaging from the caller. /// A function view for an actor hides any messaging from the caller.
/// Internally, a function view uses a `scoped_actor` and uses /// Internally, a function view uses a `scoped_actor` and uses
/// blocking send and receive operations. /// blocking send and receive operations.
...@@ -136,8 +151,8 @@ public: ...@@ -136,8 +151,8 @@ public:
R operator()(Ts&&... xs) { R operator()(Ts&&... xs) {
if (impl_.unsafe()) if (impl_.unsafe())
throw std::bad_function_call(); throw std::bad_function_call();
R result; function_view_result<R> result;
function_view_storage<R> h{result}; function_view_storage<R> h{result.value};
try { try {
self_->request(impl_, infinite, std::forward<Ts>(xs)...).receive(h); self_->request(impl_, infinite, std::forward<Ts>(xs)...).receive(h);
} }
...@@ -145,7 +160,7 @@ public: ...@@ -145,7 +160,7 @@ public:
assign(unsafe_actor_handle_init); assign(unsafe_actor_handle_init);
throw; throw;
} }
return flatten(result); return flatten(result.value);
} }
void assign(type x) { void assign(type x) {
......
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