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
e3267858
Commit
e3267858
authored
Mar 07, 2018
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support expected<T> in response promise
parent
014b1fb3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
14 deletions
+18
-14
libcaf_core/caf/response_promise.hpp
libcaf_core/caf/response_promise.hpp
+17
-10
libcaf_core/test/pipeline_streaming.cpp
libcaf_core/test/pipeline_streaming.cpp
+1
-4
No files found.
libcaf_core/caf/response_promise.hpp
View file @
e3267858
...
@@ -54,20 +54,27 @@ public:
...
@@ -54,20 +54,27 @@ public:
/// Satisfies the promise by sending a non-error response message.
/// Satisfies the promise by sending a non-error response message.
template
<
class
T
,
class
...
Ts
>
template
<
class
T
,
class
...
Ts
>
typename
std
::
enable_if
<
detail
::
enable_if_t
<
(
sizeof
...(
Ts
)
>
0
)
||
!
std
::
is_convertible
<
T
,
error
>::
value
,
(
(
sizeof
...(
Ts
)
>
0
)
||
!
std
::
is_convertible
<
T
,
error
>::
value
)
response_promise
&&
!
detail
::
is_expected
<
detail
::
decay_t
<
T
>>::
value
,
>::
type
response_promise
>
deliver
(
T
&&
x
,
Ts
&&
...
xs
)
{
deliver
(
T
&&
x
,
Ts
&&
...
xs
)
{
static_assert
(
!
detail
::
is_specialization
<
result
,
T
>::
value
using
ts
=
detail
::
type_list
<
detail
::
decay_t
<
T
>
,
detail
::
decay_t
<
Ts
>
...
>
;
&&
!
detail
::
disjunction
<
static_assert
(
!
detail
::
tl_exists
<
ts
,
detail
::
is_result
>::
value
,
detail
::
is_specialization
<
result
,
Ts
>::
value
...
"it is not possible to deliver objects of type result<T>"
);
>::
value
,
static_assert
(
!
detail
::
tl_exists
<
ts
,
detail
::
is_expected
>::
value
,
"
it is not possible to deliver objects of type result<...>
"
);
"
mixing expected<T> with regular values is not supported
"
);
return
deliver_impl
(
make_message
(
std
::
forward
<
T
>
(
x
),
return
deliver_impl
(
make_message
(
std
::
forward
<
T
>
(
x
),
std
::
forward
<
Ts
>
(
xs
)...));
std
::
forward
<
Ts
>
(
xs
)...));
}
}
template
<
class
T
>
response_promise
deliver
(
expected
<
T
>
x
)
{
if
(
x
)
return
deliver
(
std
::
move
(
*
x
));
return
deliver
(
std
::
move
(
x
.
error
()));
}
/// Satisfies the promise by delegating to another actor.
/// Satisfies the promise by delegating to another actor.
template
<
message_priority
P
=
message_priority
::
normal
,
template
<
message_priority
P
=
message_priority
::
normal
,
class
Handle
=
actor
,
class
...
Ts
>
class
Handle
=
actor
,
class
...
Ts
>
...
...
libcaf_core/test/pipeline_streaming.cpp
View file @
e3267858
...
@@ -90,10 +90,7 @@ VARARGS_TESTEE(file_reader, size_t buf_size) {
...
@@ -90,10 +90,7 @@ VARARGS_TESTEE(file_reader, size_t buf_size) {
is_done
(
self
),
is_done
(
self
),
[
=
](
expected
<
int
>
x
)
mutable
{
[
=
](
expected
<
int
>
x
)
mutable
{
CAF_MESSAGE
(
self
->
name
()
<<
" received the result"
);
CAF_MESSAGE
(
self
->
name
()
<<
" received the result"
);
if
(
x
)
rp
.
deliver
(
std
::
move
(
x
));
rp
.
deliver
(
*
x
);
else
rp
.
deliver
(
std
::
move
(
x
.
error
()));
}
}
);
);
return
rp
;
return
rp
;
...
...
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