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
2ebb7d6a
Commit
2ebb7d6a
authored
Nov 14, 2016
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make to_string for actors more readable
parent
5ef0b54c
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
92 additions
and
9 deletions
+92
-9
libcaf_core/caf/actor.hpp
libcaf_core/caf/actor.hpp
+10
-2
libcaf_core/caf/actor_addr.hpp
libcaf_core/caf/actor_addr.hpp
+8
-0
libcaf_core/caf/actor_control_block.hpp
libcaf_core/caf/actor_control_block.hpp
+8
-0
libcaf_core/caf/detail/stringification_inspector.hpp
libcaf_core/caf/detail/stringification_inspector.hpp
+1
-1
libcaf_core/caf/node_id.hpp
libcaf_core/caf/node_id.hpp
+6
-0
libcaf_core/caf/typed_actor.hpp
libcaf_core/caf/typed_actor.hpp
+8
-0
libcaf_core/src/actor_control_block.cpp
libcaf_core/src/actor_control_block.cpp
+36
-0
libcaf_core/src/node_id.cpp
libcaf_core/src/node_id.cpp
+15
-6
No files found.
libcaf_core/caf/actor.hpp
View file @
2ebb7d6a
...
@@ -164,13 +164,21 @@ public:
...
@@ -164,13 +164,21 @@ public:
actor
(
actor_control_block
*
,
bool
);
actor
(
actor_control_block
*
,
bool
);
/// @endcond
friend
inline
std
::
string
to_string
(
const
actor
&
x
)
{
return
to_string
(
x
.
ptr_
);
}
friend
inline
void
append_to_string
(
std
::
string
&
x
,
const
actor
&
y
)
{
return
append_to_string
(
x
,
y
.
ptr_
);
}
template
<
class
Inspector
>
template
<
class
Inspector
>
friend
typename
Inspector
::
result_type
inspect
(
Inspector
&
f
,
actor
&
x
)
{
friend
typename
Inspector
::
result_type
inspect
(
Inspector
&
f
,
actor
&
x
)
{
return
inspect
(
f
,
x
.
ptr_
);
return
inspect
(
f
,
x
.
ptr_
);
}
}
/// @endcond
/// Releases the reference held by handle `x`. Using the
/// Releases the reference held by handle `x`. Using the
/// handle after invalidating it is undefined behavior.
/// handle after invalidating it is undefined behavior.
friend
void
destroy
(
actor
&
x
)
{
friend
void
destroy
(
actor
&
x
)
{
...
...
libcaf_core/caf/actor_addr.hpp
View file @
2ebb7d6a
...
@@ -97,6 +97,14 @@ public:
...
@@ -97,6 +97,14 @@ public:
return
compare
(
other
.
get
());
return
compare
(
other
.
get
());
}
}
friend
inline
std
::
string
to_string
(
const
actor_addr
&
x
)
{
return
to_string
(
x
.
ptr_
);
}
friend
inline
void
append_to_string
(
std
::
string
&
x
,
const
actor_addr
&
y
)
{
return
append_to_string
(
x
,
y
.
ptr_
);
}
template
<
class
Inspector
>
template
<
class
Inspector
>
friend
typename
Inspector
::
result_type
inspect
(
Inspector
&
f
,
actor_addr
&
x
)
{
friend
typename
Inspector
::
result_type
inspect
(
Inspector
&
f
,
actor_addr
&
x
)
{
return
inspect
(
f
,
x
.
ptr_
);
return
inspect
(
f
,
x
.
ptr_
);
...
...
libcaf_core/caf/actor_control_block.hpp
View file @
2ebb7d6a
...
@@ -200,6 +200,14 @@ inline execution_unit* context_of(void*) {
...
@@ -200,6 +200,14 @@ inline execution_unit* context_of(void*) {
return
nullptr
;
return
nullptr
;
}
}
std
::
string
to_string
(
const
strong_actor_ptr
&
x
);
void
append_to_string
(
std
::
string
&
x
,
const
strong_actor_ptr
&
y
);
std
::
string
to_string
(
const
weak_actor_ptr
&
x
);
void
append_to_string
(
std
::
string
&
x
,
const
weak_actor_ptr
&
y
);
template
<
class
Inspector
>
template
<
class
Inspector
>
typename
Inspector
::
result_type
inspect
(
Inspector
&
f
,
strong_actor_ptr
&
x
)
{
typename
Inspector
::
result_type
inspect
(
Inspector
&
f
,
strong_actor_ptr
&
x
)
{
actor_id
aid
=
0
;
actor_id
aid
=
0
;
...
...
libcaf_core/caf/detail/stringification_inspector.hpp
View file @
2ebb7d6a
...
@@ -64,7 +64,6 @@ public:
...
@@ -64,7 +64,6 @@ public:
traverse
(
std
::
forward
<
Ts
>
(
xs
)...);
traverse
(
std
::
forward
<
Ts
>
(
xs
)...);
}
}
private:
/// Prints a separator to the result string.
/// Prints a separator to the result string.
void
sep
();
void
sep
();
...
@@ -237,6 +236,7 @@ private:
...
@@ -237,6 +236,7 @@ private:
traverse
(
std
::
forward
<
Ts
>
(
xs
)...);
traverse
(
std
::
forward
<
Ts
>
(
xs
)...);
}
}
private:
template
<
class
T
>
template
<
class
T
>
T
&
deconst
(
const
T
&
x
)
{
T
&
deconst
(
const
T
&
x
)
{
return
const_cast
<
T
&>
(
x
);
return
const_cast
<
T
&>
(
x
);
...
...
libcaf_core/caf/node_id.hpp
View file @
2ebb7d6a
...
@@ -194,8 +194,14 @@ inline bool operator<(const node_id& lhs, const node_id& rhs) {
...
@@ -194,8 +194,14 @@ inline bool operator<(const node_id& lhs, const node_id& rhs) {
return
lhs
.
compare
(
rhs
)
<
0
;
return
lhs
.
compare
(
rhs
)
<
0
;
}
}
/// Converts `x` into a human-readable string representation.
/// @relates node_id
std
::
string
to_string
(
const
node_id
&
x
);
std
::
string
to_string
(
const
node_id
&
x
);
/// Appends `y` in human-readable string representation to `x`.
/// @relates node_id
void
append_to_string
(
std
::
string
&
x
,
const
node_id
&
y
);
}
// namespace caf
}
// namespace caf
namespace
std
{
namespace
std
{
...
...
libcaf_core/caf/typed_actor.hpp
View file @
2ebb7d6a
...
@@ -237,6 +237,14 @@ class typed_actor : detail::comparable<typed_actor<Sigs...>>,
...
@@ -237,6 +237,14 @@ class typed_actor : detail::comparable<typed_actor<Sigs...>>,
// nop
// nop
}
}
friend
inline
std
::
string
to_string
(
const
typed_actor
&
x
)
{
return
to_string
(
x
.
ptr_
);
}
friend
inline
void
append_to_string
(
std
::
string
&
x
,
const
typed_actor
&
y
)
{
return
append_to_string
(
x
,
y
.
ptr_
);
}
template
<
class
Inspector
>
template
<
class
Inspector
>
friend
typename
Inspector
::
result_type
inspect
(
Inspector
&
f
,
typed_actor
&
x
)
{
friend
typename
Inspector
::
result_type
inspect
(
Inspector
&
f
,
typed_actor
&
x
)
{
return
f
(
x
.
ptr_
);
return
f
(
x
.
ptr_
);
...
...
libcaf_core/src/actor_control_block.cpp
View file @
2ebb7d6a
...
@@ -111,4 +111,40 @@ error save_actor(strong_actor_ptr& storage, execution_unit* ctx,
...
@@ -111,4 +111,40 @@ error save_actor(strong_actor_ptr& storage, execution_unit* ctx,
return
none
;
return
none
;
}
}
namespace
{
void
append_to_string_impl
(
std
::
string
&
x
,
const
actor_control_block
*
y
)
{
if
(
y
)
{
x
+=
std
::
to_string
(
y
->
aid
);
x
+=
'@'
;
append_to_string
(
x
,
y
->
nid
);
}
else
{
x
+=
"0@invalid-node"
;
}
}
std
::
string
to_string_impl
(
const
actor_control_block
*
x
)
{
std
::
string
result
;
append_to_string_impl
(
result
,
x
);
return
result
;
}
}
// namespace <anonymous>
std
::
string
to_string
(
const
strong_actor_ptr
&
x
)
{
return
to_string_impl
(
x
.
get
());
}
void
append_to_string
(
std
::
string
&
x
,
const
strong_actor_ptr
&
y
)
{
return
append_to_string_impl
(
x
,
y
.
get
());
}
std
::
string
to_string
(
const
weak_actor_ptr
&
x
)
{
return
to_string_impl
(
x
.
get
());
}
void
append_to_string
(
std
::
string
&
x
,
const
weak_actor_ptr
&
y
)
{
return
append_to_string_impl
(
x
,
y
.
get
());
}
}
// namespace caf
}
// namespace caf
libcaf_core/src/node_id.cpp
View file @
2ebb7d6a
...
@@ -180,12 +180,21 @@ void node_id::swap(node_id& x) {
...
@@ -180,12 +180,21 @@ void node_id::swap(node_id& x) {
}
}
std
::
string
to_string
(
const
node_id
&
x
)
{
std
::
string
to_string
(
const
node_id
&
x
)
{
if
(
!
x
)
std
::
string
result
;
return
"none"
;
append_to_string
(
result
,
x
);
return
deep_to_string
(
meta
::
type_name
(
"node_id"
),
return
result
;
x
.
process_id
(),
}
meta
::
hex_formatted
(),
x
.
host_id
());
void
append_to_string
(
std
::
string
&
x
,
const
node_id
&
y
)
{
if
(
!
y
)
{
x
+=
"invalid-node"
;
return
;
}
detail
::
stringification_inspector
si
{
x
};
si
.
consume_hex
(
reinterpret_cast
<
const
uint8_t
*>
(
y
.
host_id
().
data
()),
y
.
host_id
().
size
());
x
+=
'#'
;
x
+=
std
::
to_string
(
y
.
process_id
());
}
}
}
// namespace caf
}
// namespace caf
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