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
7dd737e7
Unverified
Commit
7dd737e7
authored
Oct 16, 2019
by
Joseph Noir
Committed by
GitHub
Oct 16, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #936
Fix silent dropping of errors in request().then()
parents
d41a9e43
685e1008
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
56 deletions
+40
-56
libcaf_core/caf/response_handle.hpp
libcaf_core/caf/response_handle.hpp
+36
-56
libcaf_core/caf/scheduled_actor.hpp
libcaf_core/caf/scheduled_actor.hpp
+4
-0
No files found.
libcaf_core/caf/response_handle.hpp
View file @
7dd737e7
...
...
@@ -20,19 +20,19 @@
#include <type_traits>
#include "caf/sec.hpp"
#include "caf/catch_all.hpp"
#include "caf/message_id.hpp"
#include "caf/
typed_behavior
.hpp"
#include "caf/
sec
.hpp"
#include "caf/system_messages.hpp"
#include "caf/typed_behavior.hpp"
#include "caf/detail/type_list.hpp"
#include "caf/detail/typed_actor_util.hpp"
namespace
caf
{
/// This helper class identifies an expected response message
///
and enables
`request(...).then(...)`.
/// This helper class identifies an expected response message
and enables
/// `request(...).then(...)`.
template
<
class
Self
,
class
Output
,
bool
IsBlocking
>
class
response_handle
;
...
...
@@ -55,8 +55,7 @@ public:
await_impl
(
f
);
}
template
<
class
F
,
class
OnError
,
class
E1
=
detail
::
is_callable_t
<
F
>,
template
<
class
F
,
class
OnError
,
class
E1
=
detail
::
is_callable_t
<
F
>,
class
E2
=
detail
::
is_handler_for_ef
<
OnError
,
error
>>
void
await
(
F
f
,
OnError
e
)
const
{
await_impl
(
f
,
e
);
...
...
@@ -67,8 +66,7 @@ public:
then_impl
(
f
);
}
template
<
class
F
,
class
OnError
,
class
E1
=
detail
::
is_callable_t
<
F
>,
template
<
class
F
,
class
OnError
,
class
E1
=
detail
::
is_callable_t
<
F
>,
class
E2
=
detail
::
is_handler_for_ef
<
OnError
,
error
>>
void
then
(
F
f
,
OnError
e
)
const
{
then_impl
(
f
,
e
);
...
...
@@ -79,54 +77,40 @@ public:
}
private:
template
<
class
F
>
void
await_impl
(
F
&
f
)
const
{
static_assert
(
std
::
is_same
<
void
,
typename
detail
::
get_callable_trait
<
F
>::
result_type
>::
value
,
"response handlers are not allowed to have a return "
"type other than void"
);
detail
::
type_checker
<
Output
,
F
>::
check
();
self_
->
add_awaited_response_handler
(
mid_
,
message_handler
{
std
::
move
(
f
)});
}
template
<
class
F
,
class
OnError
>
void
await_impl
(
F
&
f
,
OnError
&
ef
)
const
{
static_assert
(
std
::
is_same
<
void
,
typename
detail
::
get_callable_trait
<
F
>::
result_type
>::
value
,
void
await_impl
(
F
&
f
,
OnError
&
g
)
const
{
using
result_type
=
typename
detail
::
get_callable_trait
<
F
>::
result_type
;
static_assert
(
std
::
is_same
<
void
,
result_type
>::
value
,
"response handlers are not allowed to have a return "
"type other than void"
);
detail
::
type_checker
<
Output
,
F
>::
check
();
self_
->
add_awaited_response_handler
(
mid_
,
behavior
{
std
::
move
(
f
),
std
::
move
(
ef
)});
self_
->
add_awaited_response_handler
(
mid_
,
behavior
{
std
::
move
(
f
),
std
::
move
(
g
)});
}
template
<
class
F
>
void
then_impl
(
F
&
f
)
const
{
static_assert
(
std
::
is_same
<
void
,
typename
detail
::
get_callable_trait
<
F
>::
result_type
>::
value
,
"response handlers are not allowed to have a return "
"type other than void"
);
detail
::
type_checker
<
Output
,
F
>::
check
();
self_
->
add_multiplexed_response_handler
(
mid_
,
behavior
{
std
::
move
(
f
)});
void
await_impl
(
F
&
f
)
const
{
auto
self
=
self_
;
auto
on_error
=
[
self
](
error
&
err
)
{
self
->
call_error_handler
(
err
);
};
return
await_impl
(
f
,
on_error
);
}
template
<
class
F
,
class
OnError
>
void
then_impl
(
F
&
f
,
OnError
&
ef
)
const
{
static_assert
(
std
::
is_same
<
void
,
typename
detail
::
get_callable_trait
<
F
>::
result_type
>::
value
,
void
then_impl
(
F
&
f
,
OnError
&
g
)
const
{
using
result_type
=
typename
detail
::
get_callable_trait
<
F
>::
result_type
;
static_assert
(
std
::
is_same
<
void
,
result_type
>::
value
,
"response handlers are not allowed to have a return "
"type other than void"
);
detail
::
type_checker
<
Output
,
F
>::
check
();
self_
->
add_multiplexed_response_handler
(
mid_
,
behavior
{
std
::
move
(
f
),
std
::
move
(
ef
)});
std
::
move
(
g
)});
}
template
<
class
F
>
void
then_impl
(
F
&
f
)
const
{
auto
self
=
self_
;
auto
on_error
=
[
self
](
error
&
err
)
{
self
->
call_error_handler
(
err
);
};
return
then_impl
(
f
,
on_error
);
}
message_id
mid_
;
...
...
@@ -147,33 +131,30 @@ public:
// nop
}
using
error_handler
=
std
::
function
<
void
(
error
&
)
>
;
using
error_handler
=
std
::
function
<
void
(
error
&
)
>
;
template
<
class
F
,
class
OnError
,
class
E
=
detail
::
is_handler_for_ef
<
OnError
,
error
>
>
detail
::
is_callable_t
<
F
>
receive
(
F
f
,
OnError
ef
)
{
static_assert
(
std
::
is_same
<
void
,
typename
detail
::
get_callable_trait
<
F
>::
result_type
>::
value
,
detail
::
is_callable_t
<
F
>
receive
(
F
f
,
OnError
g
)
{
using
result_type
=
typename
detail
::
get_callable_trait
<
F
>::
result_type
;
static_assert
(
std
::
is_same
<
void
,
result_type
>::
value
,
"response handlers are not allowed to have a return "
"type other than void"
);
detail
::
type_checker
<
Output
,
F
>::
check
();
typename
Self
::
accept_one_cond
rc
;
self_
->
varargs_receive
(
rc
,
mid_
,
std
::
move
(
f
),
std
::
move
(
ef
));
self_
->
varargs_receive
(
rc
,
mid_
,
std
::
move
(
f
),
std
::
move
(
g
));
}
template
<
class
OnError
,
class
F
,
class
E
=
detail
::
is_callable_t
<
F
>
>
detail
::
is_handler_for_ef
<
OnError
,
error
>
receive
(
OnError
ef
,
F
f
)
{
receive
(
std
::
move
(
f
),
std
::
move
(
ef
));
template
<
class
OnError
,
class
F
,
class
E
=
detail
::
is_callable_t
<
F
>
>
detail
::
is_handler_for_ef
<
OnError
,
error
>
receive
(
OnError
g
,
F
f
)
{
receive
(
std
::
move
(
f
),
std
::
move
(
g
));
}
template
<
class
OnError
,
class
F
,
class
E
=
detail
::
is_handler_for_ef
<
OnError
,
error
>
>
void
receive
(
OnError
ef
,
catch_all
<
F
>
ca
)
{
void
receive
(
OnError
g
,
catch_all
<
F
>
f
)
{
typename
Self
::
accept_one_cond
rc
;
self_
->
varargs_receive
(
rc
,
mid_
,
std
::
move
(
ef
),
std
::
move
(
ca
));
self_
->
varargs_receive
(
rc
,
mid_
,
std
::
move
(
g
),
std
::
move
(
f
));
}
Self
*
self
()
{
...
...
@@ -186,4 +167,3 @@ private:
};
}
// namespace caf
libcaf_core/caf/scheduled_actor.hpp
View file @
7dd737e7
...
...
@@ -815,6 +815,10 @@ public:
swap
(
g
,
f
);
}
void
call_error_handler
(
error
&
err
)
{
call_handler
(
error_handler_
,
this
,
err
);
}
// -- timeout management -----------------------------------------------------
/// Requests a new timeout and returns its ID.
...
...
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