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
cde9ea72
Commit
cde9ea72
authored
May 26, 2015
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move chopstick class to test case
parent
9442b4b5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
35 deletions
+32
-35
libcaf_core/test/spawn.cpp
libcaf_core/test/spawn.cpp
+32
-35
No files found.
libcaf_core/test/spawn.cpp
View file @
cde9ea72
...
...
@@ -128,41 +128,6 @@ actor spawn_event_testee2(actor parent) {
return
spawn
<
impl
>
(
parent
);
}
class
chopstick
:
public
event_based_actor
{
public:
behavior
make_behavior
()
override
{
return
available
;
}
behavior
taken_by
(
actor
whom
)
{
return
{
[
=
](
get_atom
)
{
return
error_atom
::
value
;
},
on
(
put_atom
::
value
,
whom
)
>>
[
=
]()
{
become
(
available
);
}
};
}
chopstick
()
{
inc_actor_instances
();
available
.
assign
(
[
=
](
get_atom
,
actor
whom
)
->
atom_value
{
become
(
taken_by
(
whom
));
return
ok_atom
::
value
;
}
);
}
~
chopstick
()
{
dec_actor_instances
();
}
private:
behavior
available
;
};
class
testee_actor
:
public
blocking_actor
{
public:
testee_actor
();
...
...
@@ -560,6 +525,38 @@ CAF_TEST(spawn_event_testee2) {
}
CAF_TEST
(
chopsticks
)
{
struct
chopstick
:
event_based_actor
{
behavior
make_behavior
()
override
{
return
available
;
}
behavior
taken_by
(
actor
whom
)
{
return
{
[
=
](
get_atom
)
{
return
error_atom
::
value
;
},
on
(
put_atom
::
value
,
whom
)
>>
[
=
]()
{
become
(
available
);
}
};
}
chopstick
()
{
inc_actor_instances
();
available
.
assign
(
[
=
](
get_atom
,
actor
whom
)
->
atom_value
{
become
(
taken_by
(
whom
));
return
ok_atom
::
value
;
}
);
}
~
chopstick
()
{
dec_actor_instances
();
}
behavior
available
;
};
scoped_actor
self
;
auto
cstk
=
spawn
<
chopstick
>
();
self
->
send
(
cstk
,
get_atom
::
value
,
self
);
...
...
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