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
d89e4b20
Commit
d89e4b20
authored
Oct 16, 2014
by
Marian Triebe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new local_group test
parent
eb3ecd99
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
45 deletions
+18
-45
unit_testing/test_local_group.cpp
unit_testing/test_local_group.cpp
+18
-45
No files found.
unit_testing/test_local_group.cpp
View file @
d89e4b20
#include "caf/config.hpp"
#include <map>
#include <list>
#include <mutex>
#include <iostream>
#include <algorithm>
#include <chrono>
#include "test.hpp"
#include "caf/on.hpp"
#include "caf/all.hpp"
#include "caf/actor.hpp"
#include "caf/abstract_group.hpp"
#include "caf/ref_counted.hpp"
#include "caf/intrusive_ptr.hpp"
using
std
::
cout
;
using
std
::
endl
;
using
std
::
string
;
using
namespace
caf
;
void
testee
(
event_based_actor
*
self
,
int
current_value
,
int
final_result
)
{
void
testee
(
event_based_actor
*
self
)
{
auto
counter
=
std
::
make_shared
<
int
>
(
0
);
auto
grp
=
group
::
get
(
"local"
,
"test"
);
self
->
join
(
grp
);
CAF_CHECKPOINT
();
self
->
become
(
[
=
](
int
result
)
{
auto
next
=
result
+
current_value
;
if
(
next
>=
final_result
)
{
self
->
quit
();
}
else
{
testee
(
self
,
next
,
final_result
);
}
on
(
atom
(
"msg"
))
>>
[
=
]
{
CAF_CHECKPOINT
();
++*
counter
;
self
->
leave
(
grp
);
self
->
send
(
grp
,
atom
(
"msg"
));
},
after
(
std
::
chrono
::
seconds
(
2
))
>>
[
=
]
{
CAF_UNEXPECTED_TOUT
();
self
->
quit
(
exit_reason
::
user_shutdown
);
on
(
atom
(
"over"
))
>>
[
=
]
{
// this actor should receive only 1 message
CAF_CHECK
(
*
counter
==
1
);
self
->
quit
();
}
);
self
->
send
(
grp
,
atom
(
"msg"
));
self
->
delayed_send
(
self
,
std
::
chrono
::
seconds
(
1
),
atom
(
"over"
));
}
int
main
()
{
CAF_TEST
(
test_local_group
);
/*
auto foo_group = group::get("local", "foo");
auto master = spawn_in_group(foo_group, testee, 0, 10);
for (int i = 0; i < 5; ++i) {
// spawn five workers and let them join local/foo
spawn_in_group(foo_group, [master] {
become(
[master](int v) {
send(master, v);
self->quit();
}
);
});
}
send(foo_group, 2);
spawn
(
testee
);
await_all_actors_done
();
shutdown
();
*/
return
CAF_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