Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
ca3686a7
Commit
ca3686a7
authored
Sep 22, 2020
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add diagnostic for partial response handle support
parent
9a414758
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
87 additions
and
17 deletions
+87
-17
libcaf_core/caf/detail/type_traits.hpp
libcaf_core/caf/detail/type_traits.hpp
+64
-0
libcaf_core/caf/response_handle.hpp
libcaf_core/caf/response_handle.hpp
+22
-16
libcaf_core/src/scheduled_actor.cpp
libcaf_core/src/scheduled_actor.cpp
+1
-1
No files found.
libcaf_core/caf/detail/type_traits.hpp
View file @
ca3686a7
...
...
@@ -685,6 +685,70 @@ public:
static
constexpr
bool
value
=
sfinae_type
::
value
;
};
template
<
class
T
>
class
has_call_error_handler
{
private:
template
<
class
Actor
>
static
auto
sfinae
(
Actor
*
self
)
->
decltype
(
self
->
call_error_handler
(
std
::
declval
<
error
&>
()),
std
::
true_type
());
template
<
class
U
>
static
auto
sfinae
(...)
->
std
::
false_type
;
using
sfinae_type
=
decltype
(
sfinae
<
T
>
(
nullptr
));
public:
static
constexpr
bool
value
=
sfinae_type
::
value
;
};
template
<
class
T
>
constexpr
bool
has_call_error_handler_v
=
has_call_error_handler
<
T
>::
value
;
template
<
class
T
>
class
has_add_awaited_response_handler
{
private:
template
<
class
Actor
>
static
auto
sfinae
(
Actor
*
self
)
->
decltype
(
self
->
add_awaited_response_handler
(
std
::
declval
<
message_id
>
(),
std
::
declval
<
behavior
&>
()),
std
::
true_type
());
template
<
class
U
>
static
auto
sfinae
(...)
->
std
::
false_type
;
using
sfinae_type
=
decltype
(
sfinae
<
T
>
(
nullptr
));
public:
static
constexpr
bool
value
=
sfinae_type
::
value
;
};
template
<
class
T
>
constexpr
bool
has_add_awaited_response_handler_v
=
has_add_awaited_response_handler
<
T
>::
value
;
template
<
class
T
>
class
has_add_multiplexed_response_handler
{
private:
template
<
class
Actor
>
static
auto
sfinae
(
Actor
*
self
)
->
decltype
(
self
->
add_multiplexed_response_handler
(
std
::
declval
<
message_id
>
(),
std
::
declval
<
behavior
&>
()),
std
::
true_type
());
template
<
class
U
>
static
auto
sfinae
(...)
->
std
::
false_type
;
using
sfinae_type
=
decltype
(
sfinae
<
T
>
(
nullptr
));
public:
static
constexpr
bool
value
=
sfinae_type
::
value
;
};
template
<
class
T
>
constexpr
bool
has_add_multiplexed_response_handler_v
=
has_add_multiplexed_response_handler
<
T
>::
value
;
/// Checks whether T behaves like `std::vector`, `std::list`, or `std::set`.
template
<
class
T
>
struct
is_list_like
{
...
...
libcaf_core/caf/response_handle.hpp
View file @
ca3686a7
...
...
@@ -68,11 +68,13 @@ public:
// -- non-blocking API -------------------------------------------------------
template
<
class
T
=
traits
,
class
F
=
none_t
,
class
OnError
=
none_t
,
class
=
detail
::
enable_if_t
<
T
::
is_non_blocking
>
>
void
await
(
F
f
,
OnError
g
)
const
{
static_assert
(
detail
::
is_callable
<
F
>::
value
,
"F must provide a single, "
"non-template operator()"
);
template
<
class
T
=
traits
,
class
F
,
class
OnError
>
detail
::
enable_if_t
<
T
::
is_non_blocking
>
await
(
F
f
,
OnError
g
)
const
{
static_assert
(
detail
::
has_add_awaited_response_handler_v
<
ActorType
>
,
"this actor type does not support awaiting responses, "
"try using .then instead"
);
static_assert
(
detail
::
is_callable
<
F
>::
value
,
"F must provide a single, non-template operator()"
);
static_assert
(
detail
::
is_callable_with
<
OnError
,
error
&>::
value
,
"OnError must provide an operator() that takes a caf::error"
);
using
result_type
=
typename
detail
::
get_callable_trait
<
F
>::
result_type
;
...
...
@@ -83,18 +85,21 @@ public:
policy_
.
await
(
self_
,
std
::
move
(
f
),
std
::
move
(
g
));
}
template
<
class
T
=
traits
,
class
F
=
none_t
,
class
=
detail
::
enable_if_t
<
T
::
is_non_blocking
>
>
void
await
(
F
f
)
const
{
template
<
class
T
=
traits
,
class
F
>
detail
::
enable_if_t
<
detail
::
has_call_error_handler_v
<
ActorType
>
//
&&
T
::
is_non_blocking
>
await
(
F
f
)
const
{
auto
self
=
self_
;
await
(
std
::
move
(
f
),
[
self
](
error
&
err
)
{
self
->
call_error_handler
(
err
);
});
}
template
<
class
T
=
traits
,
class
F
=
none_t
,
class
OnError
=
none_t
,
class
=
detail
::
enable_if_t
<
T
::
is_non_blocking
>
>
void
then
(
F
f
,
OnError
g
)
const
{
static_assert
(
detail
::
is_callable
<
F
>::
value
,
"F must provide a single, "
"non-template operator()"
);
template
<
class
T
=
traits
,
class
F
,
class
OnError
>
detail
::
enable_if_t
<
T
::
is_non_blocking
>
then
(
F
f
,
OnError
g
)
const
{
static_assert
(
detail
::
has_add_multiplexed_response_handler_v
<
ActorType
>
,
"this actor type does not support multiplexed responses, "
"try using .await instead"
);
static_assert
(
detail
::
is_callable
<
F
>::
value
,
"F must provide a single, non-template operator()"
);
static_assert
(
detail
::
is_callable_with
<
OnError
,
error
&>::
value
,
"OnError must provide an operator() that takes a caf::error"
);
using
result_type
=
typename
detail
::
get_callable_trait
<
F
>::
result_type
;
...
...
@@ -105,9 +110,10 @@ public:
policy_
.
then
(
self_
,
std
::
move
(
f
),
std
::
move
(
g
));
}
template
<
class
T
=
traits
,
class
F
=
none_t
,
class
=
detail
::
enable_if_t
<
T
::
is_non_blocking
>
>
void
then
(
F
f
)
const
{
template
<
class
T
=
traits
,
class
F
>
detail
::
enable_if_t
<
detail
::
has_call_error_handler_v
<
ActorType
>
//
&&
T
::
is_non_blocking
>
then
(
F
f
)
const
{
auto
self
=
self_
;
then
(
std
::
move
(
f
),
[
self
](
error
&
err
)
{
self
->
call_error_handler
(
err
);
});
}
...
...
libcaf_core/src/scheduled_actor.cpp
View file @
ca3686a7
...
...
@@ -741,7 +741,7 @@ invoke_message_result scheduled_actor::consume(mailbox_element& x) {
auto
bhvr
=
std
::
move
(
mrh
->
second
);
multiplexed_responses_
.
erase
(
mrh
);
if
(
!
invoke
(
this
,
bhvr
,
x
))
{
CAF_LOG_DEBUG
(
"got unexpected_response
, invoke unexpected_response
"
);
CAF_LOG_DEBUG
(
"got unexpected_response"
);
auto
msg
=
make_message
(
make_error
(
sec
::
unexpected_response
,
std
::
move
(
x
.
payload
)));
bhvr
(
msg
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment