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
2c440b94
Commit
2c440b94
authored
Aug 31, 2012
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added forward_to() test to unit test
parent
647be736
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
0 deletions
+43
-0
unit_testing/test__remote_actor.cpp
unit_testing/test__remote_actor.cpp
+43
-0
No files found.
unit_testing/test__remote_actor.cpp
View file @
2c440b94
...
@@ -45,6 +45,17 @@ struct reflector : public event_based_actor {
...
@@ -45,6 +45,17 @@ struct reflector : public event_based_actor {
}
}
};
};
struct
replier
:
public
event_based_actor
{
void
init
()
{
become
(
others
()
>>
[
=
]
{
reply
(
42
);
quit
();
}
);
}
};
// receive seven reply messages (2 local, 5 remote)
// receive seven reply messages (2 local, 5 remote)
void
spawn5_server
(
actor_ptr
client
,
bool
inverted
)
{
void
spawn5_server
(
actor_ptr
client
,
bool
inverted
)
{
auto
default_case
=
others
()
>>
[]
{
auto
default_case
=
others
()
>>
[]
{
...
@@ -191,6 +202,13 @@ int client_part(const vector<string_pair>& args) {
...
@@ -191,6 +202,13 @@ int client_part(const vector<string_pair>& args) {
spawn5_client
();
spawn5_client
();
// wait for locally spawned reflectors
// wait for locally spawned reflectors
await_all_others_done
();
await_all_others_done
();
receive
(
on
(
atom
(
"fwd"
),
arg_match
)
>>
[
&
](
const
actor_ptr
&
fwd
,
const
string
&
)
{
forward_to
(
fwd
);
}
);
send
(
server
,
atom
(
"farewell"
));
send
(
server
,
atom
(
"farewell"
));
shutdown
();
shutdown
();
return
CPPA_TEST_RESULT
;
return
CPPA_TEST_RESULT
;
...
@@ -284,6 +302,31 @@ int main(int argc, char** argv) {
...
@@ -284,6 +302,31 @@ int main(int argc, char** argv) {
spawn5_client
();
spawn5_client
();
cout
<<
"test group communication via network (inverted setup)"
<<
endl
;
cout
<<
"test group communication via network (inverted setup)"
<<
endl
;
spawn5_server
(
remote_client
,
true
);
spawn5_server
(
remote_client
,
true
);
// test forward_to "over network and back"
cout
<<
"test forwarding over network 'and back'"
<<
endl
;
auto
ra
=
spawn
<
replier
>
();
sync_send
(
remote_client
,
atom
(
"fwd"
),
ra
,
"hello replier!"
).
await
(
on
(
42
)
>>
[
&
]
{
auto
from
=
self
->
last_sender
();
if
(
!
from
)
{
CPPA_ERROR
(
"from == nullptr"
);
}
else
if
(
from
!=
ra
)
{
CPPA_ERROR
(
"response came from wrong actor"
);
if
(
from
->
is_proxy
())
{
CPPA_ERROR
(
"received response from a remote actor"
);
}
}
},
others
()
>>
[
&
]
{
CPPA_ERROR
(
"unexpected: "
<<
to_string
(
self
->
last_dequeued
()));
},
after
(
chrono
::
seconds
(
5
))
>>
[
&
]
{
CPPA_ERROR
(
"fowarding failed; no message received within 5s"
);
}
);
cout
<<
"wait for a last goodbye"
<<
endl
;
cout
<<
"wait for a last goodbye"
<<
endl
;
receive
(
receive
(
on
(
atom
(
"farewell"
))
>>
[]
{
}
on
(
atom
(
"farewell"
))
>>
[]
{
}
...
...
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