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
b3a37559
Unverified
Commit
b3a37559
authored
Dec 13, 2020
by
Dominik Charousset
Committed by
GitHub
Dec 13, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1190
Align typed_response_promise with response_promise
parents
548f9392
d00891e1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
2 deletions
+52
-2
libcaf_core/caf/response_promise.hpp
libcaf_core/caf/response_promise.hpp
+3
-2
libcaf_core/caf/typed_response_promise.hpp
libcaf_core/caf/typed_response_promise.hpp
+49
-0
No files found.
libcaf_core/caf/response_promise.hpp
View file @
b3a37559
...
...
@@ -73,6 +73,8 @@ public:
make_message
(
std
::
forward
<
T
>
(
x
),
std
::
forward
<
Ts
>
(
xs
)...));
}
/// Satisfies the promise by sending either an error or a non-error response
/// message.
template
<
class
T
>
void
deliver
(
expected
<
T
>
x
)
{
if
(
x
)
...
...
@@ -92,8 +94,7 @@ public:
typename
std
::
decay
<
Ts
>::
type
>::
type
...
>
;
static_assert
(
response_type_unbox
<
signatures_of_t
<
Handle
>
,
token
>::
valid
,
"receiver does not accept given message"
);
// TODO: use `if constexpr` when switching to C++17
if
(
P
==
message_priority
::
high
)
if
constexpr
(
P
==
message_priority
::
high
)
id_
=
id_
.
with_high_priority
();
if
constexpr
(
std
::
is_same
<
detail
::
type_list
<
message
>
,
detail
::
type_list
<
std
::
decay_t
<
Ts
>
...
>>::
value
)
...
...
libcaf_core/caf/typed_response_promise.hpp
View file @
b3a37559
...
...
@@ -30,9 +30,21 @@ namespace caf {
template
<
class
...
Ts
>
class
typed_response_promise
{
public:
using
forwarding_stack
=
response_promise
::
forwarding_stack
;
/// Constructs an invalid response promise.
typed_response_promise
()
=
default
;
typed_response_promise
(
none_t
x
)
:
promise_
(
x
)
{
// nop
}
typed_response_promise
(
strong_actor_ptr
self
,
strong_actor_ptr
source
,
forwarding_stack
stages
,
message_id
id
)
:
promise_
(
std
::
move
(
self
),
std
::
move
(
source
),
std
::
move
(
stages
),
id
)
{
// nop
}
typed_response_promise
(
strong_actor_ptr
self
,
mailbox_element
&
src
)
:
promise_
(
std
::
move
(
self
),
src
)
{
// nop
...
...
@@ -44,6 +56,7 @@ public:
typed_response_promise
&
operator
=
(
const
typed_response_promise
&
)
=
default
;
/// Implicitly convertible to untyped response promise.
[[
deprecated
(
"Use the typed_response_promise directly."
)]]
operator
response_promise
&
()
{
return
promise_
;
}
...
...
@@ -63,6 +76,16 @@ public:
return
*
this
;
}
/// Satisfies the promise by sending either an error or a non-error response
/// message.
template
<
class
T
>
void
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.
template
<
message_priority
P
=
message_priority
::
normal
,
class
Handle
=
actor
,
class
...
Us
>
typed_response_promise
delegate
(
const
Handle
&
dest
,
Us
&&
...
xs
)
{
...
...
@@ -77,11 +100,37 @@ public:
return
*
this
;
}
/// Returns whether this response promise replies to an asynchronous message.
bool
async
()
const
{
return
promise_
.
async
();
}
/// Queries whether this promise is a valid promise that is not satisfied yet.
bool
pending
()
const
{
return
promise_
.
pending
();
}
/// Returns the source of the corresponding request.
const
strong_actor_ptr
&
source
()
const
{
return
promise_
.
source
();
}
/// Returns the remaining stages for the corresponding request.
const
forwarding_stack
&
stages
()
const
{
return
promise_
.
stages
();
}
/// Returns the actor that will receive the response, i.e.,
/// `stages().front()` if `!stages().empty()` or `source()` otherwise.
strong_actor_ptr
next
()
const
{
return
promise_
.
next
();
}
/// Returns the message ID of the corresponding request.
message_id
id
()
const
{
return
promise_
.
id
();
}
private:
response_promise
promise_
;
};
...
...
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