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
ad406f57
Commit
ad406f57
authored
Aug 17, 2012
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implemented serialization of local groups with a broker-based forwarding strategy
parent
c65f4cd3
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
224 additions
and
53 deletions
+224
-53
cppa/group.hpp
cppa/group.hpp
+0
-9
src/group.cpp
src/group.cpp
+0
-4
src/group_manager.cpp
src/group_manager.cpp
+170
-39
unit_testing/test__remote_actor.cpp
unit_testing/test__remote_actor.cpp
+54
-1
No files found.
cppa/group.hpp
View file @
ad406f57
...
@@ -183,15 +183,6 @@ class group : public channel {
...
@@ -183,15 +183,6 @@ class group : public channel {
virtual
void
unsubscribe
(
const
channel_ptr
&
who
)
=
0
;
virtual
void
unsubscribe
(
const
channel_ptr
&
who
)
=
0
;
/**
* @brief Called whenever a message was received via network. If @p this
* is a proxy, it should not send the message
* back to the original group but forward the message to its local
* subscribers. This member function should call @p enqueue for
* all non-proxy instances.
*/
virtual
void
remote_enqueue
(
actor
*
sender
,
any_tuple
msg
);
module_ptr
m_module
;
module_ptr
m_module
;
std
::
string
m_identifier
;
std
::
string
m_identifier
;
...
...
src/group.cpp
View file @
ad406f57
...
@@ -93,8 +93,4 @@ const std::string& group::module_name() const {
...
@@ -93,8 +93,4 @@ const std::string& group::module_name() const {
return
get_module
()
->
name
();
return
get_module
()
->
name
();
}
}
void
group
::
remote_enqueue
(
actor
*
sender
,
any_tuple
msg
)
{
enqueue
(
sender
,
std
::
move
(
msg
));
}
}
// namespace cppa
}
// namespace cppa
src/group_manager.cpp
View file @
ad406f57
This diff is collapsed.
Click to expand it.
unit_testing/test__remote_actor.cpp
View file @
ad406f57
...
@@ -35,6 +35,17 @@ std::vector<string_pair> get_kv_pairs(int argc, char** argv, int begin = 1) {
...
@@ -35,6 +35,17 @@ std::vector<string_pair> get_kv_pairs(int argc, char** argv, int begin = 1) {
return
result
;
return
result
;
}
}
struct
reflector
:
public
event_based_actor
{
void
init
()
{
become
(
others
()
>>
[
=
]
{
reply_tuple
(
last_dequeued
());
quit
();
}
);
}
};
int
client_part
(
const
std
::
vector
<
string_pair
>&
args
)
{
int
client_part
(
const
std
::
vector
<
string_pair
>&
args
)
{
CPPA_TEST
(
test__remote_actor_client_part
);
CPPA_TEST
(
test__remote_actor_client_part
);
auto
i
=
std
::
find_if
(
args
.
begin
(),
args
.
end
(),
auto
i
=
std
::
find_if
(
args
.
begin
(),
args
.
end
(),
...
@@ -93,13 +104,38 @@ int client_part(const std::vector<string_pair>& args) {
...
@@ -93,13 +104,38 @@ int client_part(const std::vector<string_pair>& args) {
}
}
);
);
}
}
// test group communication
auto
grp
=
group
::
anonymous
();
spawn_in_group
<
reflector
>
(
grp
);
spawn_in_group
<
reflector
>
(
grp
);
receive_response
(
sync_send
(
server
,
atom
(
"Spawn5"
),
grp
))
(
on
(
atom
(
"ok"
))
>>
[
&
]
{
send
(
grp
,
"Hello reflectors!"
,
5.0
);
},
after
(
std
::
chrono
::
seconds
(
10
))
>>
[
&
]
{
CPPA_ERROR
(
"unexpected timeout!"
);
}
);
// receive seven reply messages (2 local, 5 remote)
int
x
=
0
;
receive_for
(
x
,
7
)
(
on
(
"Hello reflectors!"
,
5.0
)
>>
[]
{
},
others
()
>>
[
&
]
{
CPPA_ERROR
(
"unexpected message; "
<<
__FILE__
<<
" line "
<<
__LINE__
<<
": "
<<
to_string
(
self
->
last_dequeued
()));
}
);
// wait for locally spawned reflectors
await_all_others_done
();
send
(
server
,
atom
(
"farewell"
));
shutdown
();
return
CPPA_TEST_RESULT
;
return
CPPA_TEST_RESULT
;
}
}
}
// namespace <anonymous>
}
// namespace <anonymous>
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
cout
<<
"argv[0] = "
<<
argv
[
0
]
<<
endl
;
std
::
string
app_path
=
argv
[
0
];
std
::
string
app_path
=
argv
[
0
];
bool
run_remote_actor
=
true
;
bool
run_remote_actor
=
true
;
if
(
argc
>
1
)
{
if
(
argc
>
1
)
{
...
@@ -169,13 +205,30 @@ cout << "argv[0] = " << argv[0] << endl;
...
@@ -169,13 +205,30 @@ cout << "argv[0] = " << argv[0] << endl;
}
}
);
);
// test 100 sync messages
// test 100 sync messages
cout
<<
"test 100 synchronous messages"
<<
endl
;
int
i
=
0
;
int
i
=
0
;
receive_for
(
i
,
100
)
(
receive_for
(
i
,
100
)
(
others
()
>>
[]
{
others
()
>>
[]
{
reply_tuple
(
self
->
last_dequeued
());
reply_tuple
(
self
->
last_dequeued
());
}
}
);
);
cout
<<
"test group communication via network"
<<
endl
;
// group test
receive
(
on
(
atom
(
"Spawn5"
),
arg_match
)
>>
[](
const
group_ptr
&
grp
)
{
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
spawn_in_group
<
reflector
>
(
grp
);
}
reply
(
atom
(
"ok"
));
}
);
await_all_others_done
();
cout
<<
"wait for a last goodbye"
<<
endl
;
receive
(
on
(
atom
(
"farewell"
))
>>
[]
{
}
);
// wait until separate process (in sep. thread) finished execution
// wait until separate process (in sep. thread) finished execution
if
(
run_remote_actor
)
child
.
join
();
if
(
run_remote_actor
)
child
.
join
();
shutdown
();
return
CPPA_TEST_RESULT
;
return
CPPA_TEST_RESULT
;
}
}
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