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
b89c7db8
Commit
b89c7db8
authored
Oct 09, 2017
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up linking state properly
parent
582605a2
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
8 deletions
+19
-8
libcaf_core/caf/monitorable_actor.hpp
libcaf_core/caf/monitorable_actor.hpp
+1
-5
libcaf_core/src/forwarding_actor_proxy.cpp
libcaf_core/src/forwarding_actor_proxy.cpp
+2
-0
libcaf_core/src/monitorable_actor.cpp
libcaf_core/src/monitorable_actor.cpp
+16
-3
No files found.
libcaf_core/caf/monitorable_actor.hpp
View file @
b89c7db8
...
@@ -71,11 +71,7 @@ public:
...
@@ -71,11 +71,7 @@ public:
}
}
/// Unlinks this actor from `x`.
/// Unlinks this actor from `x`.
void
unlink_from
(
const
actor_addr
&
x
)
{
void
unlink_from
(
const
actor_addr
&
x
);
auto
ptr
=
actor_cast
<
strong_actor_ptr
>
(
x
);
if
(
ptr
&&
ptr
->
get
()
!=
this
)
remove_link
(
ptr
->
get
());
}
/// Links this actor to `x`.
/// Links this actor to `x`.
template
<
class
ActorHandle
>
template
<
class
ActorHandle
>
...
...
libcaf_core/src/forwarding_actor_proxy.cpp
View file @
b89c7db8
...
@@ -44,6 +44,8 @@ void forwarding_actor_proxy::forward_msg(strong_actor_ptr sender,
...
@@ -44,6 +44,8 @@ void forwarding_actor_proxy::forward_msg(strong_actor_ptr sender,
const
forwarding_stack
*
fwd
)
{
const
forwarding_stack
*
fwd
)
{
CAF_LOG_TRACE
(
CAF_ARG
(
id
())
<<
CAF_ARG
(
sender
)
CAF_LOG_TRACE
(
CAF_ARG
(
id
())
<<
CAF_ARG
(
sender
)
<<
CAF_ARG
(
mid
)
<<
CAF_ARG
(
msg
));
<<
CAF_ARG
(
mid
)
<<
CAF_ARG
(
msg
));
if
(
msg
.
match_elements
<
exit_msg
>
())
unlink_from
(
msg
.
get_as
<
exit_msg
>
(
0
).
source
);
forwarding_stack
tmp
;
forwarding_stack
tmp
;
shared_lock
<
detail
::
shared_spinlock
>
guard
(
mtx_
);
shared_lock
<
detail
::
shared_spinlock
>
guard
(
mtx_
);
if
(
broker_
)
if
(
broker_
)
...
...
libcaf_core/src/monitorable_actor.cpp
View file @
b89c7db8
...
@@ -39,7 +39,7 @@ const char* monitorable_actor::name() const {
...
@@ -39,7 +39,7 @@ const char* monitorable_actor::name() const {
void
monitorable_actor
::
attach
(
attachable_ptr
ptr
)
{
void
monitorable_actor
::
attach
(
attachable_ptr
ptr
)
{
CAF_LOG_TRACE
(
""
);
CAF_LOG_TRACE
(
""
);
CAF_ASSERT
(
ptr
);
CAF_ASSERT
(
ptr
!=
nullptr
);
error
fail_state
;
error
fail_state
;
auto
attached
=
exclusive_critical_section
([
&
]
{
auto
attached
=
exclusive_critical_section
([
&
]
{
if
(
getf
(
is_terminated_flag
))
{
if
(
getf
(
is_terminated_flag
))
{
...
@@ -60,6 +60,19 @@ size_t monitorable_actor::detach(const attachable::token& what) {
...
@@ -60,6 +60,19 @@ size_t monitorable_actor::detach(const attachable::token& what) {
return
detach_impl
(
what
);
return
detach_impl
(
what
);
}
}
void
monitorable_actor
::
unlink_from
(
const
actor_addr
&
x
)
{
auto
ptr
=
actor_cast
<
strong_actor_ptr
>
(
x
);
if
(
ptr
!=
nullptr
)
{
if
(
ptr
->
get
()
!=
this
)
remove_link
(
ptr
->
get
());
}
else
{
default_attachable
::
observe_token
tk
{
x
,
default_attachable
::
link
};
exclusive_critical_section
([
&
]
{
detach_impl
(
tk
,
true
);
});
}
}
bool
monitorable_actor
::
cleanup
(
error
&&
reason
,
execution_unit
*
host
)
{
bool
monitorable_actor
::
cleanup
(
error
&&
reason
,
execution_unit
*
host
)
{
CAF_LOG_TRACE
(
CAF_ARG
(
reason
));
CAF_LOG_TRACE
(
CAF_ARG
(
reason
));
attachable_ptr
head
;
attachable_ptr
head
;
...
@@ -140,7 +153,7 @@ void monitorable_actor::remove_link(abstract_actor* x) {
...
@@ -140,7 +153,7 @@ void monitorable_actor::remove_link(abstract_actor* x) {
CAF_LOG_TRACE
(
CAF_ARG
(
x
));
CAF_LOG_TRACE
(
CAF_ARG
(
x
));
default_attachable
::
observe_token
tk
{
x
->
address
(),
default_attachable
::
link
};
default_attachable
::
observe_token
tk
{
x
->
address
(),
default_attachable
::
link
};
joined_exclusive_critical_section
(
this
,
x
,
[
&
]
{
joined_exclusive_critical_section
(
this
,
x
,
[
&
]
{
if
(
x
->
remove_backlink
(
this
))
x
->
remove_backlink
(
this
);
detach_impl
(
tk
,
true
);
detach_impl
(
tk
,
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