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
eeea70b4
Commit
eeea70b4
authored
Feb 03, 2015
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid `dynamic_cast` in `joined_groups()`
parent
1f3e8d3c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
5 deletions
+9
-5
libcaf_core/src/abstract_group.cpp
libcaf_core/src/abstract_group.cpp
+5
-2
libcaf_core/src/local_actor.cpp
libcaf_core/src/local_actor.cpp
+4
-3
No files found.
libcaf_core/src/abstract_group.cpp
View file @
eeea70b4
...
@@ -40,8 +40,11 @@ bool abstract_group::subscription::matches(const token& what) {
...
@@ -40,8 +40,11 @@ bool abstract_group::subscription::matches(const token& what) {
if
(
what
.
subtype
!=
attachable
::
token
::
subscription
)
{
if
(
what
.
subtype
!=
attachable
::
token
::
subscription
)
{
return
false
;
return
false
;
}
}
auto
&
ot
=
*
reinterpret_cast
<
const
subscription_token
*>
(
what
.
ptr
);
if
(
what
.
ptr
)
{
return
ot
.
group
==
m_group
;
auto
&
ot
=
*
reinterpret_cast
<
const
subscription_token
*>
(
what
.
ptr
);
return
ot
.
group
==
m_group
;
}
return
true
;
}
}
abstract_group
::
module
::
module
(
std
::
string
mname
)
:
m_name
(
std
::
move
(
mname
))
{
abstract_group
::
module
::
module
(
std
::
string
mname
)
:
m_name
(
std
::
move
(
mname
))
{
...
...
libcaf_core/src/local_actor.cpp
View file @
eeea70b4
...
@@ -88,11 +88,12 @@ void local_actor::leave(const group& what) {
...
@@ -88,11 +88,12 @@ void local_actor::leave(const group& what) {
std
::
vector
<
group
>
local_actor
::
joined_groups
()
const
{
std
::
vector
<
group
>
local_actor
::
joined_groups
()
const
{
std
::
vector
<
group
>
result
;
std
::
vector
<
group
>
result
;
result
.
reserve
(
20
);
result
.
reserve
(
20
);
attachable
::
token
stk
{
attachable
::
token
::
subscription
,
nullptr
};
std
::
unique_lock
<
std
::
mutex
>
guard
{
m_mtx
};
std
::
unique_lock
<
std
::
mutex
>
guard
{
m_mtx
};
for
(
attachable
*
i
=
m_attachables_head
.
get
();
i
!=
0
;
i
=
i
->
next
.
get
())
{
for
(
attachable
*
i
=
m_attachables_head
.
get
();
i
!=
0
;
i
=
i
->
next
.
get
())
{
auto
sptr
=
dynamic_cast
<
abstract_group
::
subscription
*>
(
i
);
if
(
i
->
matches
(
stk
))
{
if
(
sptr
)
{
auto
ptr
=
static_cast
<
abstract_group
::
subscription
*>
(
i
);
result
.
emplace_back
(
s
ptr
->
group
());
result
.
emplace_back
(
ptr
->
group
());
}
}
}
}
return
result
;
return
result
;
...
...
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