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
42035bf4
Commit
42035bf4
authored
Feb 03, 2015
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use type flag in `channel` to carry subtype
parent
eeea70b4
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
48 additions
and
28 deletions
+48
-28
libcaf_core/caf/abstract_actor.hpp
libcaf_core/caf/abstract_actor.hpp
+0
-2
libcaf_core/caf/abstract_channel.hpp
libcaf_core/caf/abstract_channel.hpp
+25
-5
libcaf_core/src/abstract_actor.cpp
libcaf_core/src/abstract_actor.cpp
+6
-6
libcaf_core/src/abstract_channel.cpp
libcaf_core/src/abstract_channel.cpp
+6
-2
libcaf_core/src/abstract_group.cpp
libcaf_core/src/abstract_group.cpp
+3
-1
libcaf_core/src/uniform_type_info_map.cpp
libcaf_core/src/uniform_type_info_map.cpp
+8
-12
No files found.
libcaf_core/caf/abstract_actor.hpp
View file @
42035bf4
...
...
@@ -276,8 +276,6 @@ class abstract_actor : public abstract_channel {
// identifies the execution unit this actor is currently executed by
execution_unit
*
m_host
;
// stores several actor-related flags
int
m_flags
;
};
}
// namespace caf
...
...
libcaf_core/caf/abstract_channel.hpp
View file @
42035bf4
...
...
@@ -34,6 +34,9 @@ namespace caf {
*/
class
abstract_channel
:
public
ref_counted
{
public:
friend
class
abstract_actor
;
friend
class
abstract_group
;
virtual
~
abstract_channel
();
/**
...
...
@@ -54,17 +57,34 @@ class abstract_channel : public ref_counted {
*/
bool
is_remote
()
const
;
protected:
enum
channel_type_flag
{
is_abstract_actor_flag
=
0x100000
,
is_abstract_group_flag
=
0x200000
};
abstract_channel
(
size_t
initial_ref_count
=
0
);
inline
bool
is_abstract_actor
()
const
{
return
m_flags
&
static_cast
<
int
>
(
is_abstract_actor_flag
);
}
abstract_channel
(
node_id
nid
,
size_t
initial_ref_count
=
0
);
inline
bool
is_abstract_group
()
const
{
return
m_flags
&
static_cast
<
int
>
(
is_abstract_group_flag
);
}
private:
protected:
/**
* Accumulates several state and type flags. Subtypes may use only the
* first 20 bits, i.e., the bitmask 0xFFF00000 is reserved for
* channel-related flags.
*/
int
m_flags
;
private:
// can only be called from abstract_actor and abstract_group
abstract_channel
(
channel_type_flag
subtype
,
size_t
initial_ref_count
=
0
);
abstract_channel
(
channel_type_flag
subtype
,
node_id
nid
,
size_t
initial_ref_count
=
0
);
// identifies the node of this channel
node_id
m_node
;
};
/**
...
...
libcaf_core/src/abstract_actor.cpp
View file @
42035bf4
...
...
@@ -48,20 +48,20 @@ using guard_type = std::unique_lock<std::mutex>;
// by std::atomic<> constructor
abstract_actor
::
abstract_actor
(
actor_id
aid
,
node_id
nid
,
size_t
initial_count
)
:
super
(
std
::
move
(
nid
),
initial_count
),
:
super
(
abstract_channel
::
is_abstract_actor_flag
,
std
::
move
(
nid
),
initial_count
),
m_id
(
aid
),
m_exit_reason
(
exit_reason
::
not_exited
),
m_host
(
nullptr
),
m_flags
(
0
)
{
m_host
(
nullptr
)
{
// nop
}
abstract_actor
::
abstract_actor
(
size_t
initial_count
)
:
super
(
detail
::
singletons
::
get_node_id
(),
initial_count
),
:
super
(
abstract_channel
::
is_abstract_actor_flag
,
detail
::
singletons
::
get_node_id
(),
initial_count
),
m_id
(
detail
::
singletons
::
get_actor_registry
()
->
next_id
()),
m_exit_reason
(
exit_reason
::
not_exited
),
m_host
(
nullptr
),
m_flags
(
0
)
{
m_host
(
nullptr
)
{
// nop
}
...
...
libcaf_core/src/abstract_channel.cpp
View file @
42035bf4
...
...
@@ -24,14 +24,18 @@ namespace caf {
using
detail
::
singletons
;
abstract_channel
::
abstract_channel
(
size_t
initial_ref_count
)
abstract_channel
::
abstract_channel
(
channel_type_flag
subtype
,
size_t
initial_ref_count
)
:
ref_counted
(
initial_ref_count
),
m_flags
(
static_cast
<
int
>
(
subtype
)),
m_node
(
singletons
::
get_node_id
())
{
// nop
}
abstract_channel
::
abstract_channel
(
node_id
nid
,
size_t
initial_ref_count
)
abstract_channel
::
abstract_channel
(
channel_type_flag
subtype
,
node_id
nid
,
size_t
initial_ref_count
)
:
ref_counted
(
initial_ref_count
),
m_flags
(
static_cast
<
int
>
(
subtype
)),
m_node
(
std
::
move
(
nid
))
{
// nop
}
...
...
libcaf_core/src/abstract_group.cpp
View file @
42035bf4
...
...
@@ -56,7 +56,9 @@ const std::string& abstract_group::module::name() {
}
abstract_group
::
abstract_group
(
abstract_group
::
module_ptr
mod
,
std
::
string
id
)
:
m_module
(
mod
),
m_identifier
(
std
::
move
(
id
))
{
:
abstract_channel
(
abstract_channel
::
is_abstract_group_flag
),
m_module
(
mod
),
m_identifier
(
std
::
move
(
id
))
{
// nop
}
...
...
libcaf_core/src/uniform_type_info_map.cpp
View file @
42035bf4
...
...
@@ -182,23 +182,19 @@ void serialize_impl(const channel& chref, serializer* sink) {
}
else
{
// raw pointer
auto
rptr
=
actor_cast
<
abstract_channel
*>
(
chref
);
CAF_REQUIRE
(
rptr
->
is_abstract_actor
()
||
rptr
->
is_abstract_group
());
if
(
rptr
->
is_abstract_actor
())
{
// raw actor pointer
abstract_actor_ptr
aptr
=
dynamic_cast
<
abstract_actor
*>
(
rptr
);
if
(
aptr
!=
nullptr
)
{
abstract_actor_ptr
aptr
=
static_cast
<
abstract_actor
*>
(
rptr
);
flag
=
1
;
sink
->
write_value
(
flag
);
serialize_impl
(
actor_cast
<
actor
>
(
aptr
),
sink
);
}
else
{
// get raw group pointer and store it inside a group handle
group
tmp
{
dynamic_cast
<
abstract_group
*>
(
rptr
)};
if
(
tmp
)
{
group
tmp
{
static_cast
<
abstract_group
*>
(
rptr
)};
flag
=
2
;
sink
->
write_value
(
flag
);
serialize_impl
(
tmp
,
sink
);
}
else
{
CAF_LOGF_ERROR
(
"ptr is neither an actor nor a group"
);
wr_nullptr
();
}
}
}
}
...
...
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