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
59d42ce0
Commit
59d42ce0
authored
Apr 30, 2020
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up remaining calls to render()
parent
896e421b
Changes
20
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
43 additions
and
58 deletions
+43
-58
examples/broker/protobuf_broker.cpp
examples/broker/protobuf_broker.cpp
+5
-6
examples/broker/simple_broker.cpp
examples/broker/simple_broker.cpp
+3
-3
examples/broker/simple_http_broker.cpp
examples/broker/simple_http_broker.cpp
+2
-2
examples/dynamic_behavior/skip_messages.cpp
examples/dynamic_behavior/skip_messages.cpp
+1
-1
examples/message_passing/calculator.cpp
examples/message_passing/calculator.cpp
+1
-2
examples/message_passing/divider.cpp
examples/message_passing/divider.cpp
+1
-1
examples/message_passing/request.cpp
examples/message_passing/request.cpp
+1
-2
examples/message_passing/typed_calculator.cpp
examples/message_passing/typed_calculator.cpp
+2
-2
examples/qtsupport/chatwidget.cpp
examples/qtsupport/chatwidget.cpp
+2
-2
examples/qtsupport/qt_group_chat.cpp
examples/qtsupport/qt_group_chat.cpp
+2
-3
examples/remoting/distributed_calculator.cpp
examples/remoting/distributed_calculator.cpp
+2
-2
examples/remoting/group_chat.cpp
examples/remoting/group_chat.cpp
+2
-2
examples/remoting/remote_spawn.cpp
examples/remoting/remote_spawn.cpp
+3
-4
libcaf_core/caf/error.hpp
libcaf_core/caf/error.hpp
+4
-6
libcaf_core/test/serial_reply.cpp
libcaf_core/test/serial_reply.cpp
+1
-3
libcaf_test/caf/test/dsl.hpp
libcaf_test/caf/test/dsl.hpp
+2
-6
manual/ConfiguringActorApplications.rst
manual/ConfiguringActorApplications.rst
+2
-2
manual/GroupCommunication.rst
manual/GroupCommunication.rst
+2
-2
manual/NetworkTransparency.rst
manual/NetworkTransparency.rst
+3
-5
tools/caf-run.cpp
tools/caf-run.cpp
+2
-2
No files found.
examples/broker/protobuf_broker.cpp
View file @
59d42ce0
...
...
@@ -30,8 +30,7 @@ using kickoff_atom = atom_constant<atom("kickoff")>;
// utility function to print an exit message with custom name
void
print_on_exit
(
scheduled_actor
*
self
,
const
std
::
string
&
name
)
{
self
->
attach_functor
([
=
](
const
error
&
reason
)
{
aout
(
self
)
<<
name
<<
" exited: "
<<
self
->
home_system
().
render
(
reason
)
<<
endl
;
aout
(
self
)
<<
name
<<
" exited: "
<<
to_string
(
reason
)
<<
endl
;
});
}
...
...
@@ -174,8 +173,8 @@ void run_server(actor_system& system, const config& cfg) {
auto
server_actor
=
system
.
middleman
().
spawn_server
(
server
,
cfg
.
port
,
pong_actor
);
if
(
!
server_actor
)
cerr
<<
"unable to spawn server: "
<<
system
.
render
(
server_actor
.
error
())
<<
endl
;
cerr
<<
"unable to spawn server: "
<<
to_string
(
server_actor
.
error
())
<<
endl
;
}
void
run_client
(
actor_system
&
system
,
const
config
&
cfg
)
{
...
...
@@ -184,8 +183,8 @@ void run_client(actor_system& system, const config& cfg) {
auto
io_actor
=
system
.
middleman
().
spawn_client
(
protobuf_io
,
cfg
.
host
,
cfg
.
port
,
ping_actor
);
if
(
!
io_actor
)
{
cout
<<
"cannot connect to "
<<
cfg
.
host
<<
" at port "
<<
cfg
.
port
<<
": "
<<
system
.
render
(
io_actor
.
error
())
<<
endl
;
cout
<<
"cannot connect to "
<<
cfg
.
host
<<
" at port "
<<
cfg
.
port
<<
": "
<<
to_string
(
io_actor
.
error
())
<<
endl
;
return
;
}
send_as
(
*
io_actor
,
ping_actor
,
kickoff_atom
::
value
,
*
io_actor
);
...
...
examples/broker/simple_broker.cpp
View file @
59d42ce0
...
...
@@ -192,8 +192,8 @@ void run_server(actor_system& system, const config& cfg) {
auto
server_actor
=
system
.
middleman
().
spawn_server
(
server
,
cfg
.
port
,
pong_actor
);
if
(
!
server_actor
)
{
std
::
cerr
<<
"failed to spawn server: "
<<
system
.
render
(
server_actor
.
error
())
<<
endl
;
std
::
cerr
<<
"failed to spawn server: "
<<
to_string
(
server_actor
.
error
())
<<
endl
;
return
;
}
print_on_exit
(
*
server_actor
,
"server"
);
...
...
@@ -205,7 +205,7 @@ void run_client(actor_system& system, const config& cfg) {
auto
io_actor
=
system
.
middleman
().
spawn_client
(
broker_impl
,
cfg
.
host
,
cfg
.
port
,
ping_actor
);
if
(
!
io_actor
)
{
std
::
cerr
<<
"failed to spawn client: "
<<
system
.
render
(
io_actor
.
error
())
std
::
cerr
<<
"failed to spawn client: "
<<
to_string
(
io_actor
.
error
())
<<
endl
;
return
;
}
...
...
examples/broker/simple_http_broker.cpp
View file @
59d42ce0
...
...
@@ -77,8 +77,8 @@ public:
void
caf_main
(
actor_system
&
system
,
const
config
&
cfg
)
{
auto
server_actor
=
system
.
middleman
().
spawn_server
(
server
,
cfg
.
port
);
if
(
!
server_actor
)
{
cerr
<<
"*** cannot spawn server: "
<<
system
.
render
(
server_actor
.
error
())
<<
endl
;
cerr
<<
"*** cannot spawn server: "
<<
to_string
(
server_actor
.
error
())
<<
endl
;
return
;
}
cout
<<
"*** listening on port "
<<
cfg
.
port
<<
endl
;
...
...
examples/dynamic_behavior/skip_messages.cpp
View file @
59d42ce0
...
...
@@ -37,7 +37,7 @@ void caf_main(actor_system& system) {
:
"server
\n
"
);
},
[
&
](
error
&
err
)
{
aout
(
self
)
<<
"received error "
<<
system
.
render
(
err
)
<<
" from "
aout
(
self
)
<<
"received error "
<<
to_string
(
err
)
<<
" from "
<<
(
self
->
current_sender
()
==
worker
?
"worker
\n
"
:
"server
\n
"
);
});
...
...
examples/message_passing/calculator.cpp
View file @
59d42ce0
...
...
@@ -101,8 +101,7 @@ template <class Handle, class... Ts>
void
tester
(
scoped_actor
&
self
,
const
Handle
&
hdl
,
int32_t
x
,
int32_t
y
,
Ts
&&
...
xs
)
{
auto
handle_err
=
[
&
](
const
error
&
err
)
{
aout
(
self
)
<<
"AUT (actor under test) failed: "
<<
self
->
system
().
render
(
err
)
<<
endl
;
aout
(
self
)
<<
"AUT (actor under test) failed: "
<<
to_string
(
err
)
<<
endl
;
};
// first test: x + y = z
self
->
request
(
hdl
,
infinite
,
add_atom_v
,
x
,
y
)
...
...
examples/message_passing/divider.cpp
View file @
59d42ce0
...
...
@@ -72,7 +72,7 @@ void caf_main(actor_system& system, const config&) {
[
&
](
double
z
)
{
aout
(
self
)
<<
x
<<
" / "
<<
y
<<
" = "
<<
z
<<
endl
;
},
[
&
](
const
error
&
err
)
{
aout
(
self
)
<<
"*** cannot compute "
<<
x
<<
" / "
<<
y
<<
" => "
<<
system
.
render
(
err
)
<<
endl
;
<<
to_string
(
err
)
<<
endl
;
});
}
...
...
examples/message_passing/request.cpp
View file @
59d42ce0
...
...
@@ -56,8 +56,7 @@ void blocking_testee(blocking_actor* self, vector<cell> cells) {
aout
(
self
)
<<
"cell #"
<<
x
.
id
()
<<
" -> "
<<
y
<<
endl
;
},
[
&
](
error
&
err
)
{
aout
(
self
)
<<
"cell #"
<<
x
.
id
()
<<
" -> "
<<
self
->
system
().
render
(
err
)
<<
endl
;
aout
(
self
)
<<
"cell #"
<<
x
.
id
()
<<
" -> "
<<
to_string
(
err
)
<<
endl
;
});
}
...
...
examples/message_passing/typed_calculator.cpp
View file @
59d42ce0
...
...
@@ -54,8 +54,8 @@ void tester(event_based_actor* self, const calculator_type& testee) {
});
},
[
=
](
const
error
&
err
)
{
aout
(
self
)
<<
"AUT (actor under test) failed: "
<<
self
->
system
().
render
(
err
)
<<
endl
;
aout
(
self
)
<<
"AUT (actor under test) failed: "
<<
to_string
(
err
)
<<
endl
;
self
->
quit
(
exit_reason
::
user_shutdown
);
});
}
...
...
examples/qtsupport/chatwidget.cpp
View file @
59d42ce0
...
...
@@ -79,7 +79,7 @@ void ChatWidget::sendChatMessage() {
auto
x
=
system
().
groups
().
get
(
mod
,
g
);
if
(
!
x
)
print
(
"*** error: "
+
QString
::
fromUtf8
(
system
().
render
(
x
.
error
()).
c_str
()));
+
QString
::
fromUtf8
(
to_string
(
x
.
error
()).
c_str
()));
else
self
()
->
send
(
self
(),
atom
(
"join"
),
std
::
move
(
*
x
));
},
...
...
@@ -128,7 +128,7 @@ void ChatWidget::joinGroup() {
string
gid
=
gname
.
midRef
(
pos
+
1
).
toUtf8
().
constData
();
auto
x
=
system
().
groups
().
get
(
mod
,
gid
);
if
(
!
x
)
QMessageBox
::
critical
(
this
,
"Error"
,
system
().
render
(
x
.
error
()).
c_str
());
QMessageBox
::
critical
(
this
,
"Error"
,
to_string
(
x
.
error
()).
c_str
());
else
self
()
->
send
(
self
(),
join_atom
::
value
,
std
::
move
(
*
x
));
}
...
...
examples/qtsupport/qt_group_chat.cpp
View file @
59d42ce0
...
...
@@ -59,9 +59,8 @@ int main(int argc, char** argv) {
auto
group_uri
=
cfg
.
group_id
.
substr
(
p
+
1
);
auto
g
=
system
.
groups
().
get
(
module
,
group_uri
);
if
(
!
g
)
{
cerr
<<
"*** unable to get group "
<<
group_uri
<<
" from module "
<<
module
<<
": "
<<
system
.
render
(
g
.
error
())
<<
endl
;
cerr
<<
"*** unable to get group "
<<
group_uri
<<
" from module "
<<
module
<<
": "
<<
to_string
(
g
.
error
())
<<
endl
;
return
-
1
;
}
grp
=
std
::
move
(
*
g
);
...
...
examples/remoting/distributed_calculator.cpp
View file @
59d42ce0
...
...
@@ -145,7 +145,7 @@ void connecting(stateful_actor<state>* self, const std::string& host,
},
[
=
](
const
error
&
err
)
{
aout
(
self
)
<<
R"(*** cannot connect to ")"
<<
host
<<
R"(":)"
<<
port
<<
" => "
<<
self
->
system
().
render
(
err
)
<<
endl
;
<<
" => "
<<
to_string
(
err
)
<<
endl
;
self
->
become
(
unconnected
(
self
));
});
}
...
...
@@ -286,7 +286,7 @@ void run_server(actor_system& system, const config& cfg) {
cout
<<
"*** try publish at port "
<<
cfg
.
port
<<
endl
;
auto
expected_port
=
io
::
publish
(
calc
,
cfg
.
port
);
if
(
!
expected_port
)
{
std
::
cerr
<<
"*** publish failed: "
<<
system
.
render
(
expected_port
.
error
())
std
::
cerr
<<
"*** publish failed: "
<<
to_string
(
expected_port
.
error
())
<<
endl
;
return
;
}
...
...
examples/remoting/group_chat.cpp
View file @
59d42ce0
...
...
@@ -85,7 +85,7 @@ void run_server(actor_system& system, const config& cfg) {
auto
res
=
system
.
middleman
().
publish_local_groups
(
cfg
.
port
);
if
(
!
res
)
{
std
::
cerr
<<
"*** publishing local groups failed: "
<<
system
.
render
(
res
.
error
())
<<
std
::
endl
;
<<
to_string
(
res
.
error
())
<<
std
::
endl
;
return
;
}
std
::
cout
<<
"*** listening at port "
<<
*
res
<<
std
::
endl
...
...
@@ -112,7 +112,7 @@ void run_client(actor_system& system, const config& cfg) {
anon_send
(
client_actor
,
join_atom_v
,
std
::
move
(
*
tmp
));
else
std
::
cerr
<<
R"(*** failed to parse ")"
<<
uri
<<
R"(" as group URI: )"
<<
system
.
render
(
tmp
.
error
())
<<
std
::
endl
;
<<
to_string
(
tmp
.
error
())
<<
std
::
endl
;
}
std
::
istream_iterator
<
line
>
eof
;
std
::
vector
<
std
::
string
>
words
;
...
...
examples/remoting/remote_spawn.cpp
View file @
59d42ce0
...
...
@@ -115,7 +115,7 @@ struct config : actor_system_config {
void
server
(
actor_system
&
system
,
const
config
&
cfg
)
{
auto
res
=
system
.
middleman
().
open
(
cfg
.
port
);
if
(
!
res
)
{
cerr
<<
"*** cannot open port: "
<<
system
.
render
(
res
.
error
())
<<
endl
;
cerr
<<
"*** cannot open port: "
<<
to_string
(
res
.
error
())
<<
endl
;
return
;
}
cout
<<
"*** running on port: "
<<
*
res
<<
endl
...
...
@@ -127,7 +127,7 @@ void server(actor_system& system, const config& cfg) {
void
client
(
actor_system
&
system
,
const
config
&
cfg
)
{
auto
node
=
system
.
middleman
().
connect
(
cfg
.
host
,
cfg
.
port
);
if
(
!
node
)
{
cerr
<<
"*** connect failed: "
<<
system
.
render
(
node
.
error
())
<<
endl
;
cerr
<<
"*** connect failed: "
<<
to_string
(
node
.
error
())
<<
endl
;
return
;
}
auto
type
=
"calculator"
;
// type of the actor we wish to spawn
...
...
@@ -136,8 +136,7 @@ void client(actor_system& system, const config& cfg) {
auto
worker
=
system
.
middleman
().
remote_spawn
<
calculator
>
(
*
node
,
type
,
args
,
tout
);
if
(
!
worker
)
{
cerr
<<
"*** remote spawn failed: "
<<
system
.
render
(
worker
.
error
())
<<
endl
;
cerr
<<
"*** remote spawn failed: "
<<
to_string
(
worker
.
error
())
<<
endl
;
return
;
}
// start using worker in main loop
...
...
libcaf_core/caf/error.hpp
View file @
59d42ce0
...
...
@@ -61,12 +61,10 @@ namespace caf {
///
/// # Why is there no `string()` member function?
///
/// The C++ standard library uses category singletons and virtual dispatching
/// to correlate error codes to descriptive strings. However, singletons are
/// a poor choice when it comes to serialization. CAF uses atoms for
/// categories instead and requires users to register custom error categories
/// to the actor system. This makes the actor system the natural instance for
/// rendering error messages via `actor_system::render(const error&)`.
/// The C++ standard library uses category singletons and virtual dispatching to
/// correlate error codes to descriptive strings. However, singletons are a poor
/// choice when it comes to serialization. CAF uses type IDs and meta objects
/// instead.
class
CAF_CORE_EXPORT
error
:
detail
::
comparable
<
error
>
{
public:
// -- constructors, destructors, and assignment operators --------------------
...
...
libcaf_core/test/serial_reply.cpp
View file @
59d42ce0
...
...
@@ -71,8 +71,6 @@ CAF_TEST(test_serial_reply) {
CAF_MESSAGE
(
"ID of main: "
<<
self
->
id
());
self
->
request
(
master
,
infinite
,
hi_atom
::
value
)
.
receive
([](
ho_atom
)
{
CAF_MESSAGE
(
"received 'ho'"
);
},
[
&
](
const
error
&
err
)
{
CAF_ERROR
(
"Error: "
<<
self
->
system
().
render
(
err
));
});
[
&
](
const
error
&
err
)
{
CAF_ERROR
(
"Error: "
<<
to_string
(
err
));
});
CAF_REQUIRE
(
self
->
mailbox
().
empty
());
}
libcaf_test/caf/test/dsl.hpp
View file @
59d42ce0
...
...
@@ -646,9 +646,7 @@ struct test_coordinator_fixture_fetch_helper {
operator
()(
caf
::
response_handle
<
Self
,
Policy
<
Interface
>>&
from
)
const
{
std
::
tuple
<
Ts
...
>
result
;
from
.
receive
([
&
](
Ts
&
...
xs
)
{
result
=
std
::
make_tuple
(
std
::
move
(
xs
)...);
},
[
&
](
caf
::
error
&
err
)
{
FAIL
(
from
.
self
()
->
system
().
render
(
err
));
});
[
&
](
caf
::
error
&
err
)
{
CAF_FAIL
(
err
);
});
return
result
;
}
};
...
...
@@ -659,9 +657,7 @@ struct test_coordinator_fixture_fetch_helper<T> {
T
operator
()(
caf
::
response_handle
<
Self
,
Policy
<
Interface
>>&
from
)
const
{
T
result
;
from
.
receive
([
&
](
T
&
x
)
{
result
=
std
::
move
(
x
);
},
[
&
](
caf
::
error
&
err
)
{
FAIL
(
from
.
self
()
->
system
().
render
(
err
));
});
[
&
](
caf
::
error
&
err
)
{
CAF_FAIL
(
err
);
});
return
result
;
}
};
...
...
manual/ConfiguringActorApplications.rst
View file @
59d42ce0
...
...
@@ -274,8 +274,8 @@ construction arguments passed as message can mismatch, this version of
auto x = system.spawn<calculator>("calculator", make_message());
if (! x) {
std::cerr << "*** unable to spawn calculator: "
<< s
ystem.render(x.error()) << s
td::endl;
std::cerr << "*** unable to spawn calculator: "
<< to_string(x.error())
<< std::endl;
return;
}
calculator c = std::move(*x);
...
...
manual/GroupCommunication.rst
View file @
59d42ce0
...
...
@@ -14,8 +14,8 @@ name, joining, and leaving.
std::string id = "foo";
auto expected_grp = system.groups().get(module, id);
if (! expected_grp) {
std::cerr << "*** cannot load group: "
<< s
ystem.render(expected_grp.error()) << s
td::endl;
std::cerr << "*** cannot load group: "
<< to_string(expected_grp.error())
<< std::endl;
return;
}
auto grp = std::move(*expected_grp);
...
...
manual/NetworkTransparency.rst
View file @
59d42ce0
...
...
@@ -92,12 +92,10 @@ connect to the published actor by calling ``remote_actor``:
// node B
auto ping = system.middleman().remote_actor("node A", 4242);
if (! ping) {
cerr << "unable to connect to node A: "
<< system.render(ping.error()) << std::endl;
} else {
if (!ping)
cerr << "unable to connect to node A: " << to_string(ping.error()) << '\n';
else
self->send(*ping, ping_atom::value);
}
There is no difference between server and client after the connection phase.
Remote actors use the same handle types as local actors and are thus fully
...
...
tools/caf-run.cpp
View file @
59d42ce0
...
...
@@ -161,8 +161,8 @@ void bootstrap(actor_system& system, const string& wdir,
// possible addresses slaves can use to connect to us
auto
port_res
=
system
.
middleman
().
publish
(
self
,
0
);
if
(
!
port_res
)
{
cerr
<<
"fatal: unable to publish actor: "
<<
system
.
render
(
port_res
.
error
())
<<
endl
;
cerr
<<
"fatal: unable to publish actor: "
<<
to_string
(
port_res
.
error
())
<<
endl
;
return
;
}
auto
port
=
*
port_res
;
...
...
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