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
c2f9b167
Commit
c2f9b167
authored
Feb 18, 2013
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added `quit_actor` function
parent
6d7bb479
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
13 deletions
+24
-13
cppa/cppa.hpp
cppa/cppa.hpp
+9
-0
examples/remote_actors/group_chat.cpp
examples/remote_actors/group_chat.cpp
+1
-1
unit_testing/ping_pong.cpp
unit_testing/ping_pong.cpp
+1
-1
unit_testing/test_spawn.cpp
unit_testing/test_spawn.cpp
+8
-9
unit_testing/test_sync_send.cpp
unit_testing/test_sync_send.cpp
+5
-2
No files found.
cppa/cppa.hpp
View file @
c2f9b167
...
...
@@ -989,6 +989,15 @@ actor_ptr remote_actor(network::io_stream_ptr_pair connection);
*/
void
shutdown
();
// note: implemented in singleton_manager.cpp
/**
* @brief Causes @p whom to quit with @p reason.
* @note Does nothing if <tt>reason == exit_reason::normal</tt>.
*/
inline
void
quit_actor
(
const
actor_ptr
&
whom
,
std
::
uint32_t
reason
)
{
CPPA_REQUIRE
(
reason
!=
exit_reason
::
normal
);
send
(
whom
,
atom
(
"EXIT"
),
reason
);
}
struct
actor_ostream
{
typedef
const
actor_ostream
&
(
*
fun_type
)(
const
actor_ostream
&
);
...
...
examples/remote_actors/group_chat.cpp
View file @
c2f9b167
...
...
@@ -156,7 +156,7 @@ int main(int argc, char** argv) {
}
);
// force actor to quit
send
(
client_actor
,
atom
(
"EXIT"
)
,
exit_reason
::
user_defined
);
quit_actor
(
client_actor
,
exit_reason
::
user_defined
);
await_all_others_done
();
shutdown
();
return
0
;
...
...
unit_testing/ping_pong.cpp
View file @
c2f9b167
...
...
@@ -21,7 +21,7 @@ behavior ping_behavior(size_t num_pings) {
CPPA_LOGF_ERROR_IF
(
!
self
->
last_sender
(),
"last_sender() == nullptr"
);
//cout << to_string(self->last_dequeued()) << endl;
if
(
++
s_pongs
>=
num_pings
)
{
reply
(
atom
(
"EXIT"
),
exit_reason
::
user_defined
);
quit_actor
(
self
->
last_sender
(
),
exit_reason
::
user_defined
);
self
->
quit
();
}
else
reply
(
atom
(
"ping"
),
value
);
...
...
unit_testing/test_spawn.cpp
View file @
c2f9b167
...
...
@@ -216,7 +216,7 @@ string behavior_test(actor_ptr et) {
throw
runtime_error
(
testee_name
+
" does not reply"
);
}
);
send
(
et
,
atom
(
"EXIT"
)
,
exit_reason
::
user_defined
);
quit_actor
(
et
,
exit_reason
::
user_defined
);
await_all_others_done
();
return
result
;
}
...
...
@@ -320,7 +320,7 @@ int main() {
CPPA_PRINT
(
"test mirror"
);
send
(
mirror
,
"hello mirror"
);
receive
(
on
(
"hello mirror"
)
>>
[]()
{
});
send
(
mirror
,
atom
(
"EXIT"
)
,
exit_reason
::
user_defined
);
quit_actor
(
mirror
,
exit_reason
::
user_defined
);
await_all_others_done
();
CPPA_CHECKPOINT
();
...
...
@@ -419,7 +419,7 @@ int main() {
CPPA_CHECK
(
values
==
expected
);
}
// terminate st
send
(
st
,
atom
(
"EXIT"
)
,
exit_reason
::
user_defined
);
quit_actor
(
st
,
exit_reason
::
user_defined
);
await_all_others_done
();
CPPA_CHECKPOINT
();
...
...
@@ -615,9 +615,8 @@ int main() {
CPPA_CHECK_EQUAL
(
name
,
"bob"
);
}
);
auto
kill_msg
=
make_any_tuple
(
atom
(
"EXIT"
),
exit_reason
::
user_defined
);
a1
<<
kill_msg
;
a2
<<
kill_msg
;
quit_actor
(
a1
,
exit_reason
::
user_defined
);
quit_actor
(
a2
,
exit_reason
::
user_defined
);
await_all_others_done
();
factory
::
event_based
([](
int
*
i
)
{
...
...
@@ -646,7 +645,7 @@ int main() {
}
);
});
send
(
twenty_thousand
,
atom
(
"EXIT"
)
,
exit_reason
::
user_defined
);
quit_actor
(
twenty_thousand
,
exit_reason
::
user_defined
);
await_all_others_done
();
self
->
trap_exit
(
true
);
auto
ping_actor
=
spawn_monitor
(
ping
,
10
);
...
...
@@ -657,12 +656,12 @@ int main() {
delayed_send
(
self
,
chrono
::
seconds
(
1
),
atom
(
"FooBar"
));
// wait for DOWN and EXIT messages of pong
receive_for
(
i
,
4
)
(
on
<
atom
(
"EXIT"
),
uint32_t
>
(
)
>>
[
&
](
uint32_t
reason
)
{
on
(
atom
(
"EXIT"
),
arg_match
)
>>
[
&
](
uint32_t
reason
)
{
CPPA_CHECK_EQUAL
(
exit_reason
::
user_defined
,
reason
);
CPPA_CHECK
(
self
->
last_sender
()
==
pong_actor
);
flags
|=
0x01
;
},
on
<
atom
(
"DOWN"
),
uint32_t
>
(
)
>>
[
&
](
uint32_t
reason
)
{
on
(
atom
(
"DOWN"
),
arg_match
)
>>
[
&
](
uint32_t
reason
)
{
auto
who
=
self
->
last_sender
();
if
(
who
==
pong_actor
)
{
flags
|=
0x02
;
...
...
unit_testing/test_sync_send.cpp
View file @
c2f9b167
...
...
@@ -127,7 +127,7 @@ int main() {
);
self
->
exec_behavior_stack
();
CPPA_CHECK_EQUAL
(
continuation_called
,
true
);
send
(
mirror
,
atom
(
"EXIT"
)
,
exit_reason
::
user_defined
);
quit_actor
(
mirror
,
exit_reason
::
user_defined
);
await_all_others_done
();
CPPA_CHECKPOINT
();
auto
await_success_message
=
[
&
]
{
...
...
@@ -180,7 +180,10 @@ int main() {
sync_send
(
c
,
atom
(
"gogo"
)).
then
(
CPPA_CHECKPOINT_CB
())
.
continue_with
(
CPPA_CHECKPOINT_CB
());
self
->
exec_behavior_stack
();
send
(
c
,
atom
(
"EXIT"
),
exit_reason
::
user_defined
);
quit_actor
(
c
,
exit_reason
::
user_defined
);
await_all_others_done
();
CPPA_CHECKPOINT
();
await_all_others_done
();
CPPA_CHECKPOINT
();
shutdown
();
...
...
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