Commit 85421ab3 authored by Dominik Charousset's avatar Dominik Charousset

Support custom blocking actors in mixin::requester

parent de6aae61
......@@ -23,6 +23,7 @@
#include <mutex>
#include <condition_variable>
#include "caf/fwd.hpp"
#include "caf/send.hpp"
#include "caf/none.hpp"
#include "caf/extend.hpp"
......@@ -38,6 +39,15 @@
#include "caf/mixin/sender.hpp"
#include "caf/mixin/requester.hpp"
namespace caf {
namespace mixin {
template <>
struct is_blocking_requester<blocking_actor> : std::true_type { };
} // namespace caf
} // namespace mixin
namespace caf {
/// A thread-mapped or context-switching actor using a blocking
......
......@@ -34,6 +34,9 @@
namespace caf {
namespace mixin {
template <class T>
struct is_blocking_requester : std::false_type { };
/// A `requester` is an actor that supports
/// `self->request(...).{then|await|receive}`.
template <class Base, class Subtype>
......@@ -44,6 +47,8 @@ public:
// nop
}
static constexpr bool is_blocking_subtype = is_blocking_requester<Subtype>::value;
/// Sends `{xs...}` as a synchronous message to `dest` with priority `mp`.
/// @returns A handle identifying a future-like handle to the response.
/// @warning The returned handle is actor specific and the response to the
......@@ -57,7 +62,8 @@ public:
typename detail::implicit_conversions<
typename std::decay<Ts>::type
>::type...>
>::type>
>::type,
is_blocking_subtype>
request(const Handle& dest, const duration& timeout, Ts&&... xs) {
static_assert(sizeof...(Ts) > 0, "no message to send");
using token =
......
......@@ -34,20 +34,9 @@
namespace caf {
/// This tag identifies response handles featuring a
/// nonblocking API by providing a `then` member function.
/// @relates response_handle
struct nonblocking_response_handle_tag {};
/// This tag identifies response handles featuring a
/// blocking API by providing an `await` member function.
/// @relates response_handle
struct blocking_response_handle_tag {};
/// This helper class identifies an expected response message
/// and enables `request(...).then(...)`.
template <class Self, class Output,
bool IsBlocking = std::is_same<Self, blocking_actor>::value>
template <class Self, class Output, bool IsBlocking>
class response_handle;
/******************************************************************************
......
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