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
e520075d
Commit
e520075d
authored
Jul 27, 2017
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use self ptr to retrieve context in promise
parent
625ff651
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
14 deletions
+21
-14
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
+6
-4
libcaf_core/caf/typed_response_promise.hpp
libcaf_core/caf/typed_response_promise.hpp
+2
-3
libcaf_core/src/response_promise.cpp
libcaf_core/src/response_promise.cpp
+12
-6
No files found.
libcaf_core/caf/local_actor.hpp
View file @
e520075d
...
@@ -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
->
c
ontext
(),
this
->
c
trl
(),
*
ptr
};
return
{
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 @
e520075d
...
@@ -41,8 +41,9 @@ public:
...
@@ -41,8 +41,9 @@ public:
/// Constructs an invalid response promise.
/// Constructs an invalid response promise.
response_promise
();
response_promise
();
response_promise
(
execution_unit
*
ctx
,
strong_actor_ptr
self
,
response_promise
(
none_t
);
mailbox_element
&
src
);
response_promise
(
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
;
...
@@ -81,7 +82,7 @@ public:
...
@@ -81,7 +82,7 @@ public:
dest
->
enqueue
(
make_mailbox_element
(
std
::
move
(
source_
),
mid
,
dest
->
enqueue
(
make_mailbox_element
(
std
::
move
(
source_
),
mid
,
std
::
move
(
stages_
),
std
::
move
(
stages_
),
std
::
forward
<
Ts
>
(
xs
)...),
std
::
forward
<
Ts
>
(
xs
)...),
c
tx_
);
c
ontext
()
);
}
}
return
{};
return
{};
}
}
...
@@ -114,9 +115,10 @@ public:
...
@@ -114,9 +115,10 @@ public:
}
}
private:
private:
execution_unit
*
context
();
response_promise
deliver_impl
(
message
msg
);
response_promise
deliver_impl
(
message
msg
);
execution_unit
*
ctx_
;
strong_actor_ptr
self_
;
strong_actor_ptr
self_
;
strong_actor_ptr
source_
;
strong_actor_ptr
source_
;
forwarding_stack
stages_
;
forwarding_stack
stages_
;
...
...
libcaf_core/caf/typed_response_promise.hpp
View file @
e520075d
...
@@ -35,9 +35,8 @@ public:
...
@@ -35,9 +35,8 @@ public:
/// Constructs an invalid response promise.
/// Constructs an invalid response promise.
typed_response_promise
()
=
default
;
typed_response_promise
()
=
default
;
inline
typed_response_promise
(
execution_unit
*
ctx
,
strong_actor_ptr
self
,
inline
typed_response_promise
(
strong_actor_ptr
self
,
mailbox_element
&
src
)
mailbox_element
&
src
)
:
promise_
(
std
::
move
(
self
),
src
)
{
:
promise_
(
ctx
,
std
::
move
(
self
),
src
)
{
// nop
// nop
}
}
...
...
libcaf_core/src/response_promise.cpp
View file @
e520075d
...
@@ -32,10 +32,8 @@ response_promise::response_promise()
...
@@ -32,10 +32,8 @@ response_promise::response_promise()
// nop
// nop
}
}
response_promise
::
response_promise
(
execution_unit
*
ctx
,
strong_actor_ptr
self
,
response_promise
::
response_promise
(
strong_actor_ptr
self
,
mailbox_element
&
src
)
mailbox_element
&
src
)
:
self_
(
std
::
move
(
self
)),
:
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
...
@@ -54,18 +52,26 @@ bool response_promise::async() const {
...
@@ -54,18 +52,26 @@ bool response_promise::async() const {
return
id_
.
is_async
();
return
id_
.
is_async
();
}
}
execution_unit
*
response_promise
::
context
()
{
return
self_
==
nullptr
?
nullptr
:
static_cast
<
local_actor
*>
(
actor_cast
<
abstract_actor
*>
(
self_
))
->
context
();
}
response_promise
response_promise
::
deliver_impl
(
message
msg
)
{
response_promise
response_promise
::
deliver_impl
(
message
msg
)
{
if
(
!
stages_
.
empty
())
{
if
(
!
stages_
.
empty
())
{
auto
next
=
std
::
move
(
stages_
.
back
());
auto
next
=
std
::
move
(
stages_
.
back
());
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
)),
c
tx_
);
c
ontext
()
);
return
*
this
;
return
*
this
;
}
}
if
(
source_
)
{
if
(
source_
)
{
source_
->
enqueue
(
std
::
move
(
self_
),
id_
.
response_id
(),
source_
->
enqueue
(
std
::
move
(
self_
),
id_
.
response_id
(),
std
::
move
(
msg
),
c
tx_
);
std
::
move
(
msg
),
c
ontext
()
);
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