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
eaf70871
Commit
eaf70871
authored
Sep 09, 2016
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Generalize response promise
parent
f9e52814
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
19 deletions
+17
-19
libcaf_core/caf/local_actor.hpp
libcaf_core/caf/local_actor.hpp
+1
-1
libcaf_core/caf/response_promise.hpp
libcaf_core/caf/response_promise.hpp
+5
-10
libcaf_core/caf/typed_response_promise.hpp
libcaf_core/caf/typed_response_promise.hpp
+3
-2
libcaf_core/src/response_promise.cpp
libcaf_core/src/response_promise.cpp
+8
-6
No files found.
libcaf_core/caf/local_actor.hpp
View file @
eaf70871
...
@@ -256,7 +256,7 @@ public:
...
@@ -256,7 +256,7 @@ public:
auto
&
mid
=
ptr
->
mid
;
auto
&
mid
=
ptr
->
mid
;
if
(
mid
.
is_answered
())
if
(
mid
.
is_answered
())
return
{};
return
{};
return
{
this
,
*
ptr
};
return
{
this
->
context
(),
this
->
ctrl
()
,
*
ptr
};
}
}
/// Creates a `response_promise` to respond to a request later on.
/// Creates a `response_promise` to respond to a request later on.
...
...
libcaf_core/caf/response_promise.hpp
View file @
eaf70871
...
@@ -36,7 +36,9 @@ class response_promise {
...
@@ -36,7 +36,9 @@ class response_promise {
public:
public:
/// Constructs an invalid response promise.
/// Constructs an invalid response promise.
response_promise
();
response_promise
();
response_promise
(
local_actor
*
self
,
mailbox_element
&
src
);
response_promise
(
execution_unit
*
ctx
,
strong_actor_ptr
self
,
mailbox_element
&
src
);
response_promise
(
response_promise
&&
)
=
default
;
response_promise
(
response_promise
&&
)
=
default
;
response_promise
(
const
response_promise
&
)
=
default
;
response_promise
(
const
response_promise
&
)
=
default
;
...
@@ -65,20 +67,13 @@ public:
...
@@ -65,20 +67,13 @@ public:
return
!
stages_
.
empty
()
||
source_
;
return
!
stages_
.
empty
()
||
source_
;
}
}
/// @cond PRIVATE
inline
local_actor
*
self
()
{
return
self_
;
}
/// @endcond
private:
private:
using
forwarding_stack
=
std
::
vector
<
strong_actor_ptr
>
;
using
forwarding_stack
=
std
::
vector
<
strong_actor_ptr
>
;
response_promise
deliver_impl
(
message
response_message
);
response_promise
deliver_impl
(
message
response_message
);
local_actor
*
self_
;
execution_unit
*
ctx_
;
strong_actor_ptr
self_
;
strong_actor_ptr
source_
;
strong_actor_ptr
source_
;
forwarding_stack
stages_
;
forwarding_stack
stages_
;
message_id
id_
;
message_id
id_
;
...
...
libcaf_core/caf/typed_response_promise.hpp
View file @
eaf70871
...
@@ -35,8 +35,9 @@ public:
...
@@ -35,8 +35,9 @@ public:
/// Constructs an invalid response promise.
/// Constructs an invalid response promise.
typed_response_promise
()
=
default
;
typed_response_promise
()
=
default
;
inline
typed_response_promise
(
local_actor
*
self
,
mailbox_element
&
src
)
inline
typed_response_promise
(
execution_unit
*
ctx
,
strong_actor_ptr
self
,
:
promise_
(
self
,
src
)
{
mailbox_element
&
src
)
:
promise_
(
ctx
,
std
::
move
(
self
),
src
)
{
// nop
// nop
}
}
...
...
libcaf_core/src/response_promise.cpp
View file @
eaf70871
...
@@ -30,8 +30,10 @@ response_promise::response_promise()
...
@@ -30,8 +30,10 @@ response_promise::response_promise()
// nop
// nop
}
}
response_promise
::
response_promise
(
local_actor
*
ptr
,
mailbox_element
&
src
)
response_promise
::
response_promise
(
execution_unit
*
ctx
,
strong_actor_ptr
self
,
:
self_
(
ptr
),
mailbox_element
&
src
)
:
ctx_
(
ctx
),
self_
(
std
::
move
(
self
)),
id_
(
src
.
mid
)
{
id_
(
src
.
mid
)
{
// form an invalid request promise when initialized from a
// form an invalid request promise when initialized from a
// response ID, since CAF always drops messages in this case
// response ID, since CAF always drops messages in this case
...
@@ -56,12 +58,12 @@ response_promise response_promise::deliver_impl(message msg) {
...
@@ -56,12 +58,12 @@ response_promise response_promise::deliver_impl(message msg) {
stages_
.
pop_back
();
stages_
.
pop_back
();
next
->
enqueue
(
make_mailbox_element
(
std
::
move
(
source_
),
id_
,
next
->
enqueue
(
make_mailbox_element
(
std
::
move
(
source_
),
id_
,
std
::
move
(
stages_
),
std
::
move
(
msg
)),
std
::
move
(
stages_
),
std
::
move
(
msg
)),
self_
->
context
()
);
ctx_
);
return
*
this
;
return
*
this
;
}
}
if
(
source_
)
{
if
(
source_
)
{
source_
->
enqueue
(
s
elf_
->
ctrl
(
),
id_
.
response_id
(),
source_
->
enqueue
(
s
td
::
move
(
self_
),
id_
.
response_id
(),
std
::
move
(
msg
),
self_
->
context
()
);
std
::
move
(
msg
),
ctx_
);
source_
.
reset
();
source_
.
reset
();
return
*
this
;
return
*
this
;
}
}
...
...
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