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
52409b7e
Commit
52409b7e
authored
Jul 31, 2019
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reimplement node_id as opaque identifier
parent
c58b6a08
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
313 additions
and
256 deletions
+313
-256
libcaf_core/caf/actor_control_block.hpp
libcaf_core/caf/actor_control_block.hpp
+6
-6
libcaf_core/caf/atom.hpp
libcaf_core/caf/atom.hpp
+4
-1
libcaf_core/caf/node_id.hpp
libcaf_core/caf/node_id.hpp
+136
-121
libcaf_core/src/atom.cpp
libcaf_core/src/atom.cpp
+4
-0
libcaf_core/src/node_id.cpp
libcaf_core/src/node_id.cpp
+147
-114
libcaf_io/src/basp_broker.cpp
libcaf_io/src/basp_broker.cpp
+1
-1
libcaf_io/src/middleman.cpp
libcaf_io/src/middleman.cpp
+2
-2
libcaf_io/src/routing_table.cpp
libcaf_io/src/routing_table.cpp
+5
-5
libcaf_io/test/basp.cpp
libcaf_io/test/basp.cpp
+5
-4
libcaf_io/test/worker.cpp
libcaf_io/test/worker.cpp
+3
-2
No files found.
libcaf_core/caf/actor_control_block.hpp
View file @
52409b7e
...
@@ -20,16 +20,16 @@
...
@@ -20,16 +20,16 @@
#include <atomic>
#include <atomic>
#include "caf/
fwd
.hpp"
#include "caf/
config
.hpp"
#include "caf/error.hpp"
#include "caf/error.hpp"
#include "caf/
node_i
d.hpp"
#include "caf/
fw
d.hpp"
#include "caf/intrusive_ptr.hpp"
#include "caf/intrusive_ptr.hpp"
#include "caf/weak_intrusive_ptr.hpp"
#include "caf/meta/type_name.hpp"
#include "caf/meta/save_callback.hpp"
#include "caf/meta/load_callback.hpp"
#include "caf/meta/load_callback.hpp"
#include "caf/meta/omittable_if_none.hpp"
#include "caf/meta/omittable_if_none.hpp"
#include "caf/meta/save_callback.hpp"
#include "caf/meta/type_name.hpp"
#include "caf/node_id.hpp"
#include "caf/weak_intrusive_ptr.hpp"
namespace
caf
{
namespace
caf
{
...
...
libcaf_core/caf/atom.hpp
View file @
52409b7e
...
@@ -40,8 +40,12 @@ std::string to_string(const atom_value& what);
...
@@ -40,8 +40,12 @@ std::string to_string(const atom_value& what);
/// @relates atom_value
/// @relates atom_value
atom_value
to_lowercase
(
atom_value
x
);
atom_value
to_lowercase
(
atom_value
x
);
/// @relates atom_value
atom_value
atom_from_string
(
string_view
x
);
atom_value
atom_from_string
(
string_view
x
);
/// @relates atom_value
int
compare
(
atom_value
x
,
atom_value
y
);
/// Creates an atom from given string literal.
/// Creates an atom from given string literal.
template
<
size_t
Size
>
template
<
size_t
Size
>
constexpr
atom_value
atom
(
char
const
(
&
str
)[
Size
])
{
constexpr
atom_value
atom
(
char
const
(
&
str
)[
Size
])
{
...
@@ -219,4 +223,3 @@ struct hash<caf::atom_value> {
...
@@ -219,4 +223,3 @@ struct hash<caf::atom_value> {
};
};
}
// namespace std
}
// namespace std
libcaf_core/caf/node_id.hpp
View file @
52409b7e
This diff is collapsed.
Click to expand it.
libcaf_core/src/atom.cpp
View file @
52409b7e
...
@@ -71,4 +71,8 @@ std::string to_string(const atom_value& x) {
...
@@ -71,4 +71,8 @@ std::string to_string(const atom_value& x) {
return
std
::
string
(
str
.
begin
(),
str
.
begin
()
+
len
);
return
std
::
string
(
str
.
begin
(),
str
.
begin
()
+
len
);
}
}
int
compare
(
atom_value
x
,
atom_value
y
)
{
return
memcmp
(
&
x
,
&
y
,
sizeof
(
atom_value
));
}
}
// namespace caf
}
// namespace caf
libcaf_core/src/node_id.cpp
View file @
52409b7e
This diff is collapsed.
Click to expand it.
libcaf_io/src/basp_broker.cpp
View file @
52409b7e
...
@@ -541,7 +541,7 @@ void basp_broker::set_context(connection_handle hdl) {
...
@@ -541,7 +541,7 @@ void basp_broker::set_context(connection_handle hdl) {
invalid_actor_id
};
invalid_actor_id
};
i
=
ctx
i
=
ctx
.
emplace
(
hdl
,
basp
::
endpoint_context
{
basp
::
await_header
,
hdr
,
hdl
,
.
emplace
(
hdl
,
basp
::
endpoint_context
{
basp
::
await_header
,
hdr
,
hdl
,
no
ne
,
0
,
0
,
none
})
no
de_id
{}
,
0
,
0
,
none
})
.
first
;
.
first
;
}
}
this_context
=
&
i
->
second
;
this_context
=
&
i
->
second
;
...
...
libcaf_io/src/middleman.cpp
View file @
52409b7e
...
@@ -384,8 +384,8 @@ void middleman::init(actor_system_config& cfg) {
...
@@ -384,8 +384,8 @@ void middleman::init(actor_system_config& cfg) {
.
add_message_type
<
connection_handle
>
(
"@connection_handle"
)
.
add_message_type
<
connection_handle
>
(
"@connection_handle"
)
.
add_message_type
<
connection_passivated_msg
>
(
"@connection_passivated_msg"
)
.
add_message_type
<
connection_passivated_msg
>
(
"@connection_passivated_msg"
)
.
add_message_type
<
acceptor_passivated_msg
>
(
"@acceptor_passivated_msg"
);
.
add_message_type
<
acceptor_passivated_msg
>
(
"@acceptor_passivated_msg"
);
//
compute and set ID for this network node
//
Compute and set ID for this network node.
node_id
this_node
{
node_id
::
data
::
create_singleton
()}
;
auto
this_node
=
node_id
::
default_data
::
local
(
cfg
)
;
system
().
node_
.
swap
(
this_node
);
system
().
node_
.
swap
(
this_node
);
// give config access to slave mode implementation
// give config access to slave mode implementation
cfg
.
slave_mode_fun
=
&
middleman
::
exec_slave_mode
;
cfg
.
slave_mode_fun
=
&
middleman
::
exec_slave_mode
;
...
...
libcaf_io/src/routing_table.cpp
View file @
52409b7e
...
@@ -62,7 +62,7 @@ node_id routing_table::lookup_direct(const connection_handle& hdl) const {
...
@@ -62,7 +62,7 @@ node_id routing_table::lookup_direct(const connection_handle& hdl) const {
auto
i
=
direct_by_hdl_
.
find
(
hdl
);
auto
i
=
direct_by_hdl_
.
find
(
hdl
);
if
(
i
!=
direct_by_hdl_
.
end
())
if
(
i
!=
direct_by_hdl_
.
end
())
return
i
->
second
;
return
i
->
second
;
return
none
;
return
{}
;
}
}
optional
<
connection_handle
>
optional
<
connection_handle
>
...
@@ -71,24 +71,24 @@ routing_table::lookup_direct(const node_id& nid) const {
...
@@ -71,24 +71,24 @@ routing_table::lookup_direct(const node_id& nid) const {
auto
i
=
direct_by_nid_
.
find
(
nid
);
auto
i
=
direct_by_nid_
.
find
(
nid
);
if
(
i
!=
direct_by_nid_
.
end
())
if
(
i
!=
direct_by_nid_
.
end
())
return
i
->
second
;
return
i
->
second
;
return
none
;
return
{}
;
}
}
node_id
routing_table
::
lookup_indirect
(
const
node_id
&
nid
)
const
{
node_id
routing_table
::
lookup_indirect
(
const
node_id
&
nid
)
const
{
std
::
unique_lock
<
std
::
mutex
>
guard
{
mtx_
};
std
::
unique_lock
<
std
::
mutex
>
guard
{
mtx_
};
auto
i
=
indirect_
.
find
(
nid
);
auto
i
=
indirect_
.
find
(
nid
);
if
(
i
==
indirect_
.
end
())
if
(
i
==
indirect_
.
end
())
return
none
;
return
{}
;
if
(
!
i
->
second
.
empty
())
if
(
!
i
->
second
.
empty
())
return
*
i
->
second
.
begin
();
return
*
i
->
second
.
begin
();
return
none
;
return
{}
;
}
}
node_id
routing_table
::
erase_direct
(
const
connection_handle
&
hdl
)
{
node_id
routing_table
::
erase_direct
(
const
connection_handle
&
hdl
)
{
std
::
unique_lock
<
std
::
mutex
>
guard
{
mtx_
};
std
::
unique_lock
<
std
::
mutex
>
guard
{
mtx_
};
auto
i
=
direct_by_hdl_
.
find
(
hdl
);
auto
i
=
direct_by_hdl_
.
find
(
hdl
);
if
(
i
==
direct_by_hdl_
.
end
())
if
(
i
==
direct_by_hdl_
.
end
())
return
none
;
return
{}
;
direct_by_nid_
.
erase
(
i
->
second
);
direct_by_nid_
.
erase
(
i
->
second
);
node_id
result
=
std
::
move
(
i
->
second
);
node_id
result
=
std
::
move
(
i
->
second
);
direct_by_hdl_
.
erase
(
i
->
first
);
direct_by_hdl_
.
erase
(
i
->
first
);
...
...
libcaf_io/test/basp.cpp
View file @
52409b7e
...
@@ -129,12 +129,13 @@ public:
...
@@ -129,12 +129,13 @@ public:
registry_
=
&
sys
.
registry
();
registry_
=
&
sys
.
registry
();
registry_
->
put
((
*
self_
)
->
id
(),
actor_cast
<
strong_actor_ptr
>
(
*
self_
));
registry_
->
put
((
*
self_
)
->
id
(),
actor_cast
<
strong_actor_ptr
>
(
*
self_
));
// first remote node is everything of this_node + 1, then +2, etc.
// first remote node is everything of this_node + 1, then +2, etc.
auto
pid
=
static_cast
<
node_id
::
default_data
&>
(
*
this_node_
).
process_id
();
auto
hid
=
static_cast
<
node_id
::
default_data
&>
(
*
this_node_
).
host_id
();
for
(
uint32_t
i
=
0
;
i
<
num_remote_nodes
;
++
i
)
{
for
(
uint32_t
i
=
0
;
i
<
num_remote_nodes
;
++
i
)
{
auto
&
n
=
nodes_
[
i
];
auto
&
n
=
nodes_
[
i
];
node_id
::
host_id_type
tmp
=
this_node_
.
host_id
();
for
(
auto
&
c
:
hid
)
for
(
auto
&
c
:
tmp
)
++
c
;
c
=
static_cast
<
uint8_t
>
(
c
+
i
+
1
);
n
.
id
=
make_node_id
(
++
pid
,
hid
);
n
.
id
=
node_id
{
this_node_
.
process_id
()
+
i
+
1
,
tmp
};
n
.
connection
=
connection_handle
::
from_int
(
i
+
1
);
n
.
connection
=
connection_handle
::
from_int
(
i
+
1
);
new
(
&
n
.
dummy_actor
)
scoped_actor
(
sys
);
new
(
&
n
.
dummy_actor
)
scoped_actor
(
sys
);
// register all pseudo remote actors in the registry
// register all pseudo remote actors in the registry
...
...
libcaf_io/test/worker.cpp
View file @
52409b7e
...
@@ -84,8 +84,9 @@ struct fixture : test_coordinator_fixture<> {
...
@@ -84,8 +84,9 @@ struct fixture : test_coordinator_fixture<> {
fixture
()
fixture
()
:
proxies_backend
(
sys
),
:
proxies_backend
(
sys
),
proxies
(
sys
,
proxies_backend
),
proxies
(
sys
,
proxies_backend
)
{
last_hop
(
123
,
"0011223344556677889900112233445566778899"
)
{
auto
tmp
=
make_node_id
(
123
,
"0011223344556677889900112233445566778899"
);
last_hop
=
unbox
(
std
::
move
(
tmp
));
testee
=
sys
.
spawn
<
lazy_init
>
(
testee_impl
);
testee
=
sys
.
spawn
<
lazy_init
>
(
testee_impl
);
sys
.
registry
().
put
(
testee
.
id
(),
testee
);
sys
.
registry
().
put
(
testee
.
id
(),
testee
);
}
}
...
...
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