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
f5649fc5
Commit
f5649fc5
authored
Apr 10, 2018
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Shutdown actors when removing final stream manager
parent
4a7db979
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
8 deletions
+14
-8
libcaf_core/caf/scheduled_actor.hpp
libcaf_core/caf/scheduled_actor.hpp
+0
-1
libcaf_core/src/scheduled_actor.cpp
libcaf_core/src/scheduled_actor.cpp
+14
-7
No files found.
libcaf_core/caf/scheduled_actor.hpp
View file @
f5649fc5
...
@@ -214,7 +214,6 @@ public:
...
@@ -214,7 +214,6 @@ public:
/// Consumes messages from the mailbox.
/// Consumes messages from the mailbox.
struct
mailbox_visitor
{
struct
mailbox_visitor
{
scheduled_actor
*
self
;
scheduled_actor
*
self
;
resume_result
&
result
;
size_t
&
handled_msgs
;
size_t
&
handled_msgs
;
size_t
max_throughput
;
size_t
max_throughput
;
...
...
libcaf_core/src/scheduled_actor.cpp
View file @
f5649fc5
...
@@ -341,7 +341,6 @@ scheduled_actor::mailbox_visitor::operator()(mailbox_element& x) {
...
@@ -341,7 +341,6 @@ scheduled_actor::mailbox_visitor::operator()(mailbox_element& x) {
CAF_LOG_TRACE
(
CAF_ARG
(
x
)
<<
CAF_ARG
(
handled_msgs
));
CAF_LOG_TRACE
(
CAF_ARG
(
x
)
<<
CAF_ARG
(
handled_msgs
));
switch
(
self
->
reactivate
(
x
))
{
switch
(
self
->
reactivate
(
x
))
{
case
activation_result
:
:
terminated
:
case
activation_result
:
:
terminated
:
result
=
resume_result
::
done
;
return
intrusive
::
task_result
::
stop
;
return
intrusive
::
task_result
::
stop
;
case
activation_result
:
:
success
:
case
activation_result
:
:
success
:
return
++
handled_msgs
<
max_throughput
return
++
handled_msgs
<
max_throughput
...
@@ -359,7 +358,7 @@ scheduled_actor::resume(execution_unit* ctx, size_t max_throughput) {
...
@@ -359,7 +358,7 @@ scheduled_actor::resume(execution_unit* ctx, size_t max_throughput) {
CAF_PUSH_AID
(
id
());
CAF_PUSH_AID
(
id
());
CAF_LOG_TRACE
(
CAF_ARG
(
max_throughput
));
CAF_LOG_TRACE
(
CAF_ARG
(
max_throughput
));
if
(
!
activate
(
ctx
))
if
(
!
activate
(
ctx
))
return
resum
e_result
::
done
;
return
resum
able
::
done
;
size_t
handled_msgs
=
0
;
size_t
handled_msgs
=
0
;
actor_clock
::
time_point
tout
{
actor_clock
::
duration_type
{
0
}};
actor_clock
::
time_point
tout
{
actor_clock
::
duration_type
{
0
}};
auto
reset_timeouts_if_needed
=
[
&
]
{
auto
reset_timeouts_if_needed
=
[
&
]
{
...
@@ -374,8 +373,7 @@ scheduled_actor::resume(execution_unit* ctx, size_t max_throughput) {
...
@@ -374,8 +373,7 @@ scheduled_actor::resume(execution_unit* ctx, size_t max_throughput) {
set_stream_timeout
(
tout
);
set_stream_timeout
(
tout
);
}
}
};
};
auto
result
=
resume_result
::
awaiting_message
;
mailbox_visitor
f
{
this
,
handled_msgs
,
max_throughput
};
mailbox_visitor
f
{
this
,
result
,
handled_msgs
,
max_throughput
};
mailbox_element_ptr
ptr
;
mailbox_element_ptr
ptr
;
// Timeout for calling `advance_streams`.
// Timeout for calling `advance_streams`.
while
(
handled_msgs
<
max_throughput
)
{
while
(
handled_msgs
<
max_throughput
)
{
...
@@ -387,9 +385,11 @@ scheduled_actor::resume(execution_unit* ctx, size_t max_throughput) {
...
@@ -387,9 +385,11 @@ scheduled_actor::resume(execution_unit* ctx, size_t max_throughput) {
if
(
mailbox
().
try_block
())
if
(
mailbox
().
try_block
())
return
resumable
::
awaiting_message
;
return
resumable
::
awaiting_message
;
}
}
// Immediately stop if the visitor reports an error.
// Check whether the visitor left the actor without behavior.
if
(
result
!=
awaiting_message
)
if
(
finalize
())
{
return
result
;
return
resumable
::
done
;
}
// Advance streams, i.e., try to generating credit or to emit batches.
auto
now
=
clock
().
now
();
auto
now
=
clock
().
now
();
if
(
now
>=
tout
)
if
(
now
>=
tout
)
tout
=
advance_streams
(
now
);
tout
=
advance_streams
(
now
);
...
@@ -771,6 +771,12 @@ void scheduled_actor::do_become(behavior bhvr, bool discard_old) {
...
@@ -771,6 +771,12 @@ void scheduled_actor::do_become(behavior bhvr, bool discard_old) {
}
}
bool
scheduled_actor
::
finalize
()
{
bool
scheduled_actor
::
finalize
()
{
CAF_LOG_TRACE
(
""
);
// Repeated calls always return `true` but have no side effects.
if
(
getf
(
is_cleaned_up_flag
))
return
true
;
// An actor is considered alive as long as it has a behavior and didn't set
// the terminated flag.
if
(
has_behavior
()
&&
!
getf
(
is_terminated_flag
))
if
(
has_behavior
()
&&
!
getf
(
is_terminated_flag
))
return
false
;
return
false
;
CAF_LOG_DEBUG
(
"actor either has no behavior or has set an exit reason"
);
CAF_LOG_DEBUG
(
"actor either has no behavior or has set an exit reason"
);
...
@@ -778,6 +784,7 @@ bool scheduled_actor::finalize() {
...
@@ -778,6 +784,7 @@ bool scheduled_actor::finalize() {
bhvr_stack_
.
clear
();
bhvr_stack_
.
clear
();
bhvr_stack_
.
cleanup
();
bhvr_stack_
.
cleanup
();
cleanup
(
std
::
move
(
fail_state_
),
context
());
cleanup
(
std
::
move
(
fail_state_
),
context
());
CAF_ASSERT
(
getf
(
is_cleaned_up_flag
));
return
true
;
return
true
;
}
}
...
...
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