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
6cbdec38
Commit
6cbdec38
authored
Jun 26, 2012
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
maintenance
parent
e9731720
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
10 deletions
+25
-10
cppa/cppa.hpp
cppa/cppa.hpp
+11
-1
unit_testing/test__spawn.cpp
unit_testing/test__spawn.cpp
+14
-9
No files found.
cppa/cppa.hpp
View file @
6cbdec38
...
...
@@ -46,10 +46,10 @@
#include "cppa/factory.hpp"
#include "cppa/behavior.hpp"
#include "cppa/announce.hpp"
#include "cppa/sb_actor.hpp"
#include "cppa/scheduler.hpp"
#include "cppa/to_string.hpp"
#include "cppa/any_tuple.hpp"
#include "cppa/sb_actor.hpp"
#include "cppa/cow_tuple.hpp"
#include "cppa/exit_reason.hpp"
#include "cppa/local_actor.hpp"
...
...
@@ -503,6 +503,11 @@ inline actor_ptr spawn(Fun&& fun, Arg0&& arg0, Args&&... args) {
std
::
forward
<
Args
>
(
args
)...);
}
template
<
class
ActorImpl
,
typename
...
Args
>
inline
actor_ptr
spawn
(
Args
&&
...
args
)
{
return
spawn
(
new
ActorImpl
(
std
::
forward
<
Args
>
(
args
)...));
}
inline
actor_ptr
spawn_in_group
(
const
group_ptr
&
grp
,
event_based_actor
*
impl
)
{
return
get_scheduler
()
->
spawn
(
impl
,
[
grp
](
local_actor
*
ptr
)
{
ptr
->
join
(
grp
);
...
...
@@ -540,6 +545,11 @@ inline actor_ptr spawn_in_group(const group_ptr& grp,
std
::
forward
<
Args
>
(
args
)...);
}
template
<
class
ActorImpl
,
typename
...
Args
>
inline
actor_ptr
spawn_in_group
(
const
group_ptr
&
grp
,
Args
&&
...
args
)
{
return
spawn_in_group
(
grp
,
new
ActorImpl
(
std
::
forward
<
Args
>
(
args
)...));
}
#ifdef CPPA_DOCUMENTATION
/**
...
...
unit_testing/test__spawn.cpp
View file @
6cbdec38
...
...
@@ -307,7 +307,7 @@ class fixed_stack : public sb_actor<fixed_stack> {
friend
class
sb_actor
<
fixed_stack
>
;
s
tatic
constexpr
size_t
max_size
=
10
;
s
ize_t
max_size
;
std
::
vector
<
int
>
data
;
...
...
@@ -346,13 +346,17 @@ class fixed_stack : public sb_actor<fixed_stack> {
behavior
&
init_state
=
empty
;
public:
fixed_stack
(
size_t
max
)
:
max_size
(
max
)
{
}
};
#else
class
fixed_stack
:
public
sb_actor
<
fixed_stack
>
{
friend
class
sb_actor
<
fixed_stack
>
;
s
tatic
constexpr
s
ize_t
max_size
=
10
;
size_t
max_size
=
10
;
std
::
vector
<
int
>
data
;
...
...
@@ -363,7 +367,7 @@ class fixed_stack : public sb_actor<fixed_stack> {
public:
fixed_stack
(
)
:
init_state
(
empty
)
{
fixed_stack
(
size_t
max
)
:
max_size
(
max
),
init_state
(
empty
)
{
full
=
(
on
(
atom
(
"push"
),
arg_match
)
>>
[
=
](
int
)
{
},
...
...
@@ -431,7 +435,7 @@ size_t test__spawn() {
await_all_others_done
();
CPPA_IF_VERBOSE
(
cout
<<
"ok"
<<
endl
);
auto
mirror
=
spawn
(
new
simple_mirror
);
auto
mirror
=
spawn
<
simple_mirror
>
(
);
CPPA_IF_VERBOSE
(
cout
<<
"test mirror ... "
<<
std
::
flush
);
send
(
mirror
,
"hello mirror"
);
...
...
@@ -459,7 +463,7 @@ size_t test__spawn() {
CPPA_IF_VERBOSE
(
cout
<<
"ok"
<<
endl
);
CPPA_IF_VERBOSE
(
cout
<<
"chopstick ... "
<<
std
::
flush
);
auto
cstk
=
spawn
(
new
chopstick
);
auto
cstk
=
spawn
<
chopstick
>
(
);
send
(
cstk
,
atom
(
"take"
),
self
);
receive
(
on
(
atom
(
"taken"
))
>>
[
&
]()
{
...
...
@@ -503,7 +507,7 @@ size_t test__spawn() {
CPPA_IF_VERBOSE
(
cout
<<
"ok"
<<
endl
);
CPPA_IF_VERBOSE
(
cout
<<
"test fixed_stack ... "
<<
std
::
flush
);
auto
st
=
spawn
(
new
fixed_stack
);
auto
st
=
spawn
<
fixed_stack
>
(
10
);
// push 20 values
for
(
int
i
=
0
;
i
<
20
;
++
i
)
send
(
st
,
atom
(
"push"
),
i
);
// pop 20 times
...
...
@@ -591,14 +595,15 @@ size_t test__spawn() {
a2
<<
kill_msg
;
await_all_others_done
();
CPPA_CHECK_EQUAL
(
behavior_test
<
testee_actor
>
(
spawn
(
testee_actor
{})),
"wait4int"
);
CPPA_CHECK_EQUAL
(
behavior_test
<
event_testee
>
(
spawn
(
new
event_testee
)),
"wait4int"
);
auto
res1
=
behavior_test
<
testee_actor
>
(
spawn
(
testee_actor
{}));
CPPA_CHECK_EQUAL
(
res1
,
"wait4int"
);
CPPA_CHECK_EQUAL
(
behavior_test
<
event_testee
>
(
spawn
<
event_testee
>
()),
"wait4int"
);
// create 20,000 actors linked to one single actor
// and kill them all through killing the link
auto
twenty_thousand
=
spawn
([]()
{
for
(
int
i
=
0
;
i
<
20000
;
++
i
)
{
self
->
link_to
(
spawn
(
new
event_testee
));
self
->
link_to
(
spawn
<
event_testee
>
(
));
}
receive_loop
(
others
()
>>
[]()
{
...
...
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