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
07f5249e
Commit
07f5249e
authored
Jul 29, 2012
by
neverlord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improved sync_send test
parent
3043c8f8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
26 deletions
+33
-26
unit_testing/test__sync_send.cpp
unit_testing/test__sync_send.cpp
+33
-26
No files found.
unit_testing/test__sync_send.cpp
View file @
07f5249e
...
...
@@ -3,38 +3,40 @@
using
namespace
cppa
;
/*
test case:
A B C
| | |
| --(sync_send)--> | |
| | --(forward)----> |
| X |---\
| | |
| |<--/
| <-------------(reply)-------------- |
*/
/******************************************************************************\
* test case: *
* *
* A B C *
* | | | *
* | --(sync_send)--> | | *
* | | --(forward)----> | *
* | X |---\ *
* | | | *
* | |<--/ *
* | <-------------(reply)-------------- | *
* X X *
\******************************************************************************/
struct
A
:
event_based_actor
{
actor_ptr
m_parent
;
A
(
const
actor_ptr
&
parent
)
:
m_parent
(
parent
)
{
}
void
init
()
{
auto
report_failure
=
[
=
]
{
send
(
m_parent
,
atom
(
"failure"
));
quit
();
};
become
(
on
(
atom
(
"go"
),
arg_match
)
>>
[
=
](
const
actor_ptr
&
next
)
{
handle_response
(
sync_send
(
next
,
atom
(
"gogo"
)))
(
on
(
atom
(
"gogogo"
))
>>
[
=
]
{
cout
<<
"A received gogogo"
<<
endl
;
send
(
m_parent
,
atom
(
"success"
))
;
quit
();
},
after
(
std
::
chrono
::
seconds
(
1
))
>>
[
=
]
{
quit
(
exit_reason
::
user_defined
);
}
others
()
>>
report_failure
,
after
(
std
::
chrono
::
seconds
(
1
))
>>
report_failure
);
},
others
()
>>
[
=
]
{
cerr
<<
"UNEXPECTED: "
<<
to_string
(
last_dequeued
())
<<
endl
;
}
others
()
>>
report_failure
);
}
};
...
...
@@ -44,8 +46,7 @@ struct B : event_based_actor {
B
(
const
actor_ptr
&
buddy
)
:
m_buddy
(
buddy
)
{
}
void
init
()
{
become
(
others
()
>>
[
=
]()
{
cout
<<
"B forward_to C"
<<
endl
;
others
()
>>
[
=
]
{
forward_to
(
m_buddy
);
quit
();
}
...
...
@@ -57,7 +58,6 @@ struct C : event_based_actor {
void
init
()
{
become
(
on
(
atom
(
"gogo"
))
>>
[
=
]
{
cout
<<
"C received gogo (reply)"
<<
endl
;
reply
(
atom
(
"gogogo"
));
quit
();
}
...
...
@@ -66,7 +66,14 @@ cout << "C received gogo (reply)" << endl;
};
int
main
()
{
send
(
spawn
<
A
>
(),
atom
(
"go"
),
spawn
<
B
>
(
spawn
<
C
>
()));
CPPA_TEST
(
test__sync_send
);
send
(
spawn
<
A
>
(
self
),
atom
(
"go"
),
spawn
<
B
>
(
spawn
<
C
>
()));
receive
(
on
(
atom
(
"success"
))
>>
[
&
]
{
},
on
(
atom
(
"failure"
))
>>
[
&
]
{
CPPA_ERROR
(
"A didn't receive a sync response"
);
}
);
await_all_others_done
();
return
0
;
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