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
d729bd2a
Commit
d729bd2a
authored
Nov 09, 2016
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add to_u64 as syntactic sugar to switch on atoms
parent
57faf14c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
6 deletions
+13
-6
libcaf_core/caf/atom.hpp
libcaf_core/caf/atom.hpp
+11
-4
libcaf_io/src/basp_broker.cpp
libcaf_io/src/basp_broker.cpp
+2
-2
No files found.
libcaf_core/caf/atom.hpp
View file @
d729bd2a
...
...
@@ -38,6 +38,11 @@ enum class atom_value : uint64_t {
/// @relates atom_value
std
::
string
to_string
(
const
atom_value
&
x
);
/// @relates atom_value
constexpr
uint64_t
to_u64
(
atom_value
x
)
{
return
static_cast
<
uint64_t
>
(
x
);
}
atom_value
atom_from_string
(
const
std
::
string
&
x
);
/// Creates an atom from given string literal.
...
...
@@ -58,9 +63,6 @@ struct atom_constant {
constexpr
operator
atom_value
()
const
{
return
V
;
}
static
constexpr
uint64_t
uint_value
()
{
return
static_cast
<
uint64_t
>
(
V
);
}
/// Returns an instance *of this constant* (*not* an `atom_value`).
static
const
atom_constant
value
;
};
...
...
@@ -76,10 +78,15 @@ struct is_atom_constant<atom_constant<X>> {
};
template
<
atom_value
V
>
std
::
string
to_string
(
const
atom_constant
<
V
>&
)
{
std
::
string
to_string
(
atom_constant
<
V
>
)
{
return
to_string
(
V
);
}
template
<
atom_value
V
>
constexpr
uint64_t
to_u64
(
atom_constant
<
V
>
)
{
return
static_cast
<
uint64_t
>
(
V
);
}
template
<
atom_value
V
>
const
atom_constant
<
V
>
atom_constant
<
V
>::
value
=
atom_constant
<
V
>
{};
...
...
libcaf_io/src/basp_broker.cpp
View file @
d729bd2a
...
...
@@ -239,7 +239,7 @@ void basp_broker_state::deliver(const node_id& src_nid, actor_id src_aid,
switch
(
static_cast
<
uint64_t
>
(
msg
.
get_as
<
atom_value
>
(
0
)))
{
default:
break
;
case
link_atom
:
:
value
.
uint_value
(
)
:
{
case
to_u64
(
link_atom
:
:
value
)
:
{
if
(
src_nid
!=
this_node
())
{
CAF_LOG_WARNING
(
"received link message for an other node"
);
return
;
...
...
@@ -258,7 +258,7 @@ void basp_broker_state::deliver(const node_id& src_nid, actor_id src_aid,
static_cast
<
actor_proxy
*>
(
ptr
->
get
())
->
local_link_to
(
src
->
get
());
return
;
}
case
unlink_atom
:
:
value
.
uint_value
(
)
:
{
case
to_u64
(
unlink_atom
:
:
value
)
:
{
if
(
src_nid
!=
this_node
())
{
CAF_LOG_WARNING
(
"received unlink message for an other node"
);
return
;
...
...
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