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
4e9082f0
Commit
4e9082f0
authored
May 30, 2012
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
library cleanup: become_void => quit_normal, future_send => delayed_send
parent
699a371b
Changes
22
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
134 additions
and
105 deletions
+134
-105
benchmarks/actor_creation.cpp
benchmarks/actor_creation.cpp
+2
-2
benchmarks/distributed.cpp
benchmarks/distributed.cpp
+2
-2
benchmarks/mailbox_performance.cpp
benchmarks/mailbox_performance.cpp
+1
-1
benchmarks/mixed_case.cpp
benchmarks/mixed_case.cpp
+5
-5
cppa/actor.hpp
cppa/actor.hpp
+1
-1
cppa/cppa.hpp
cppa/cppa.hpp
+16
-12
cppa/detail/abstract_scheduled_actor.hpp
cppa/detail/abstract_scheduled_actor.hpp
+1
-1
cppa/event_based_actor.hpp
cppa/event_based_actor.hpp
+0
-5
cppa/local_actor.hpp
cppa/local_actor.hpp
+42
-40
cppa/scheduler.hpp
cppa/scheduler.hpp
+3
-3
cppa/stacked_event_based_actor.hpp
cppa/stacked_event_based_actor.hpp
+1
-1
examples/dancing_kirby.cpp
examples/dancing_kirby.cpp
+1
-1
examples/dining_philosophers.cpp
examples/dining_philosophers.cpp
+3
-3
examples/math_actor_example.cpp
examples/math_actor_example.cpp
+1
-1
src/actor.cpp
src/actor.cpp
+1
-1
src/event_based_actor.cpp
src/event_based_actor.cpp
+2
-6
src/local_actor.cpp
src/local_actor.cpp
+2
-1
src/scheduler.cpp
src/scheduler.cpp
+1
-1
src/stacked_event_based_actor.cpp
src/stacked_event_based_actor.cpp
+1
-1
src/thread_pool_scheduler.cpp
src/thread_pool_scheduler.cpp
+6
-6
unit_testing/ping_pong.cpp
unit_testing/ping_pong.cpp
+1
-1
unit_testing/test__spawn.cpp
unit_testing/test__spawn.cpp
+41
-10
No files found.
benchmarks/actor_creation.cpp
View file @
4e9082f0
...
...
@@ -51,7 +51,7 @@ struct testee : fsm_actor<testee> {
init_state
=
(
on
(
atom
(
"spread"
),
0
)
>>
[
=
]()
{
send
(
parent
,
atom
(
"result"
),
(
uint32_t
)
1
);
become_void
();
quit_normal
();
},
on
<
atom
(
"spread"
),
int
>
()
>>
[
=
](
int
x
)
{
any_tuple
msg
=
make_cow_tuple
(
atom
(
"spread"
),
x
-
1
);
...
...
@@ -62,7 +62,7 @@ struct testee : fsm_actor<testee> {
become
(
on
<
atom
(
"result"
),
uint32_t
>
()
>>
[
=
](
uint32_t
r2
)
{
send
(
parent
,
atom
(
"result"
),
r1
+
r2
);
become_void
();
quit_normal
();
}
);
}
...
...
benchmarks/distributed.cpp
View file @
4e9082f0
...
...
@@ -134,7 +134,7 @@ struct ping_actor : fsm_actor<ping_actor> {
become
(
on
<
atom
(
"pong"
),
uint32_t
>
().
when
(
_x2
==
uint32_t
(
0
))
>>
[
=
]()
{
send
(
parent
,
atom
(
"done"
));
become_void
();
quit_normal
();
},
on
(
atom
(
"pong"
),
arg_match
)
>>
[
=
](
uint32_t
value
)
{
reply
(
atom
(
"ping"
),
value
-
1
);
...
...
@@ -206,7 +206,7 @@ struct server_actor : fsm_actor<server_actor> {
},
on
(
atom
(
"shutdown"
))
>>
[
=
]()
{
m_pongs
.
clear
();
become_void
();
quit_normal
();
},
others
()
>>
[
=
]()
{
cout
<<
"unexpected: "
<<
to_string
(
last_dequeued
())
<<
endl
;
...
...
benchmarks/mailbox_performance.cpp
View file @
4e9082f0
...
...
@@ -53,7 +53,7 @@ struct fsm_receiver : fsm_actor<fsm_receiver> {
on
(
atom
(
"msg"
))
>>
[
=
]()
{
++
m_value
;
if
(
m_value
==
max
)
{
become_void
();
quit_normal
();
}
}
);
...
...
benchmarks/mixed_case.cpp
View file @
4e9082f0
...
...
@@ -73,7 +73,7 @@ struct fsm_worker : fsm_actor<fsm_worker> {
send
(
mc
,
atom
(
"result"
),
factorize
(
what
));
},
on
(
atom
(
"done"
))
>>
[
=
]()
{
become_void
();
quit_normal
();
}
);
}
...
...
@@ -86,7 +86,7 @@ struct fsm_chain_link : fsm_actor<fsm_chain_link> {
init_state
=
(
on
<
atom
(
"token"
),
int
>
()
>>
[
=
](
int
v
)
{
next
<<
std
::
move
(
last_dequeued
());
if
(
v
==
0
)
become_void
();
if
(
v
==
0
)
quit_normal
();
}
);
}
...
...
@@ -120,7 +120,7 @@ struct fsm_chain_master : fsm_actor<fsm_chain_master> {
else
{
send
(
worker
,
atom
(
"done"
));
send
(
mc
,
atom
(
"masterdone"
));
become_void
();
quit_normal
();
}
},
on
<
atom
(
"token"
),
int
>
()
>>
[
=
](
int
v
)
{
...
...
@@ -138,11 +138,11 @@ struct fsm_supervisor : fsm_actor<fsm_supervisor> {
fsm_supervisor
(
int
num_msgs
)
:
left
(
num_msgs
)
{
init_state
=
(
on
(
atom
(
"masterdone"
))
>>
[
=
]()
{
if
(
--
left
==
0
)
become_void
();
if
(
--
left
==
0
)
quit_normal
();
},
on
<
atom
(
"result"
),
factors
>
()
>>
[
=
](
const
factors
&
vec
)
{
check_factors
(
vec
);
if
(
--
left
==
0
)
become_void
();
if
(
--
left
==
0
)
quit_normal
();
}
);
}
...
...
cppa/actor.hpp
View file @
4e9082f0
...
...
@@ -63,7 +63,7 @@ class actor : public channel {
* this actor is an scheduled actor that successfully changed
* its state to @p pending.
*/
virtual
bool
pending
_enqueue
(
actor
*
sender
,
any_tuple
msg
);
virtual
bool
chained
_enqueue
(
actor
*
sender
,
any_tuple
msg
);
/**
* @brief Attaches @p ptr to this actor.
...
...
cppa/cppa.hpp
View file @
4e9082f0
...
...
@@ -32,6 +32,7 @@
#define CPPA_HPP
#include <tuple>
#include <chrono>
#include <cstdint>
#include <functional>
#include <type_traits>
...
...
@@ -342,12 +343,12 @@
*
* @section FutureSend Send delayed messages
*
* The function @p
future
_send provides a simple way to delay a message.
* The function @p
delayed
_send provides a simple way to delay a message.
* This is particularly useful for recurring events, e.g., periodical polling.
* Usage example:
*
* @code
*
future
_send(self, std::chrono::seconds(1), atom("poll"));
*
delayed
_send(self, std::chrono::seconds(1), atom("poll"));
* receive_loop
* (
* // ...
...
...
@@ -355,7 +356,7 @@
* {
* // ... poll something ...
* // and do it again after 1sec
*
future
_send(self, std::chrono::seconds(1), atom("poll"));
*
delayed
_send(self, std::chrono::seconds(1), atom("poll"));
* }
* );
* @endcode
...
...
@@ -411,7 +412,7 @@
*/
/**
* @brief A simple example for a
future
_send based application.
* @brief A simple example for a
delayed
_send based application.
* @example dancing_kirby.cpp
*/
...
...
@@ -665,7 +666,7 @@ const self_type& operator<<(const self_type& s, any_tuple&& what);
* @brief Sends a message to the sender of the last received message.
*/
template
<
typename
Arg0
,
typename
...
Args
>
void
reply
(
const
Arg0
&
arg0
,
const
Args
&
...
args
)
{
inline
void
reply
(
const
Arg0
&
arg0
,
const
Args
&
...
args
)
{
send
(
self
->
last_sender
(),
arg0
,
args
...);
}
...
...
@@ -676,19 +677,22 @@ void reply(const Arg0& arg0, const Args&... args) {
* @param rel_time Relative time duration to delay the message.
* @param data Any number of values for the message content.
*/
template
<
typename
Duration
,
typename
...
Data
>
void
future_send
(
actor_ptr
whom
,
const
Duration
&
rel_time
,
const
Data
&
...
data
)
{
get_scheduler
()
->
future_send
(
whom
,
rel_time
,
data
...);
template
<
class
Rep
,
class
Period
,
typename
...
Data
>
inline
void
delayed_send
(
actor_ptr
whom
,
const
std
::
chrono
::
duration
<
Rep
,
Period
>&
rel_time
,
const
Data
&
...
data
)
{
get_scheduler
()
->
delayed_send
(
whom
,
rel_time
,
data
...);
}
/**
* @ingroup MessageHandling
* @brief Sends a reply message that is delayed by @p rel_time.
* @see
future
_send()
* @see
delayed
_send()
*/
template
<
typename
Duration
,
typename
...
Data
>
void
delayed_reply
(
const
Duration
&
rel_time
,
Data
const
...
data
)
{
future_send
(
self
->
last_sender
(),
rel_time
,
data
...);
template
<
class
Rep
,
class
Period
,
typename
...
Data
>
inline
void
delayed_reply
(
const
std
::
chrono
::
duration
<
Rep
,
Period
>&
rel_time
,
const
Data
&
...
data
)
{
delayed_send
(
self
->
last_sender
(),
rel_time
,
data
...);
}
/**
...
...
cppa/detail/abstract_scheduled_actor.hpp
View file @
4e9082f0
...
...
@@ -92,7 +92,7 @@ class abstract_scheduled_actor : public abstract_actor<scheduled_actor> {
enqueue
(
nullptr
,
make_any_tuple
(
atom
(
"TIMEOUT"
),
++
m_active_timeout_id
));
}
else
{
get_scheduler
()
->
future
_send
(
this
,
d
,
atom
(
"TIMEOUT"
),
++
m_active_timeout_id
);
get_scheduler
()
->
delayed
_send
(
this
,
d
,
atom
(
"TIMEOUT"
),
++
m_active_timeout_id
);
m_has_pending_timeout_request
=
true
;
}
}
...
...
cppa/event_based_actor.hpp
View file @
4e9082f0
...
...
@@ -52,11 +52,6 @@ class event_based_actor : public event_based_actor_base<event_based_actor> {
event_based_actor
();
/**
* @brief Terminates this actor with normal exit reason.
*/
void
become_void
();
void
quit
(
std
::
uint32_t
reason
);
};
...
...
cppa/local_actor.hpp
View file @
4e9082f0
...
...
@@ -34,6 +34,7 @@
#include "cppa/actor.hpp"
#include "cppa/behavior.hpp"
#include "cppa/any_tuple.hpp"
#include "cppa/exit_reason.hpp"
#include "cppa/partial_function.hpp"
#include "cppa/intrusive/single_reader_queue.hpp"
...
...
@@ -50,9 +51,10 @@ class local_actor : public actor {
protected:
bool
m_chaining
;
bool
m_trap_exit
;
bool
m_is_scheduled
;
actor_ptr
m_
pending
;
actor_ptr
m_
chained
;
actor_ptr
m_last_sender
;
any_tuple
m_last_dequeued
;
...
...
@@ -71,6 +73,10 @@ class local_actor : public actor {
*/
virtual
void
quit
(
std
::
uint32_t
reason
)
=
0
;
inline
void
quit_normal
()
{
quit
(
exit_reason
::
normal
);
}
/**
* @brief
* @param rules
...
...
@@ -86,56 +92,52 @@ class local_actor : public actor {
*/
virtual
void
dequeue
(
partial_function
&
rules
)
=
0
;
inline
bool
trap_exit
()
const
;
inline
void
trap_exit
(
bool
new_value
);
inline
any_tuple
&
last_dequeued
();
inline
actor_ptr
&
last_sender
();
inline
actor_ptr
&
pending_actor
();
inline
void
send_message
(
channel
*
whom
,
any_tuple
what
);
inline
void
send_message
(
actor
*
whom
,
any_tuple
what
);
};
inline
bool
local_actor
::
trap_exit
()
const
{
inline
bool
trap_exit
()
const
{
return
m_trap_exit
;
}
}
inline
void
local_actor
::
trap_exit
(
bool
new_value
)
{
inline
void
trap_exit
(
bool
new_value
)
{
m_trap_exit
=
new_value
;
}
}
inline
any_tuple
&
local_actor
::
last_dequeued
()
{
inline
bool
chaining
()
const
{
return
m_chaining
;
}
inline
void
chaining
(
bool
new_value
)
{
if
(
m_is_scheduled
)
{
m_chaining
=
new_value
;
}
}
inline
any_tuple
&
last_dequeued
()
{
return
m_last_dequeued
;
}
}
inline
actor_ptr
&
local_actor
::
last_sender
()
{
inline
actor_ptr
&
last_sender
()
{
return
m_last_sender
;
}
}
inline
actor_ptr
&
local_actor
::
pending
_actor
()
{
return
m_pending
;
}
inline
actor_ptr
&
chained
_actor
()
{
return
m_chained
;
}
inline
void
local_actor
::
send_message
(
actor
*
whom
,
any_tuple
what
)
{
if
(
m_is_scheduled
&&
!
m_pending
)
{
if
(
whom
->
pending_enqueue
(
this
,
std
::
move
(
what
)))
{
m_pending
=
whom
;
inline
void
send_message
(
channel
*
whom
,
any_tuple
what
)
{
whom
->
enqueue
(
this
,
std
::
move
(
what
));
}
inline
void
send_message
(
actor
*
whom
,
any_tuple
what
)
{
if
(
m_chaining
&&
!
m_chained
)
{
if
(
whom
->
chained_enqueue
(
this
,
std
::
move
(
what
)))
{
m_chained
=
whom
;
}
}
else
{
whom
->
enqueue
(
this
,
std
::
move
(
what
));
}
}
}
inline
void
local_actor
::
send_message
(
channel
*
whom
,
any_tuple
what
)
{
whom
->
enqueue
(
this
,
std
::
move
(
what
));
}
};
typedef
intrusive_ptr
<
local_actor
>
local_actor_ptr
;
...
...
cppa/scheduler.hpp
View file @
4e9082f0
...
...
@@ -58,7 +58,7 @@ class scheduler {
scheduler_helper
*
m_helper
;
channel
*
future
_send_helper
();
channel
*
delayed
_send_helper
();
protected:
...
...
@@ -114,12 +114,12 @@ class scheduler {
virtual
attachable
*
register_hidden_context
();
template
<
typename
Duration
,
typename
...
Data
>
void
future
_send
(
const
actor_ptr
&
to
,
void
delayed
_send
(
const
actor_ptr
&
to
,
const
Duration
&
rel_time
,
const
Data
&
...
data
)
{
static_assert
(
sizeof
...(
Data
)
>
0
,
"no message to send"
);
any_tuple
data_tup
=
make_cow_tuple
(
data
...);
any_tuple
tup
=
make_cow_tuple
(
util
::
duration
(
rel_time
),
to
,
data_tup
);
future
_send_helper
()
->
enqueue
(
self
,
std
::
move
(
tup
));
delayed
_send_helper
()
->
enqueue
(
self
,
std
::
move
(
tup
));
}
};
...
...
cppa/stacked_event_based_actor.hpp
View file @
4e9082f0
...
...
@@ -56,7 +56,7 @@ class stacked_event_based_actor : public event_based_actor_base<stacked_event_ba
/**
* @brief Terminates this actor with normal exit reason.
*/
void
become_void
();
void
quit_normal
();
};
...
...
examples/dancing_kirby.cpp
View file @
4e9082f0
...
...
@@ -41,7 +41,7 @@ void dancing_kirby() {
on
<
atom
(
"Step"
)
>
()
>>
[
&
]()
{
draw_kirby
(
*
i
);
// animate next step in 150ms
future
_send
(
self
,
std
::
chrono
::
milliseconds
(
150
),
atom
(
"Step"
));
delayed
_send
(
self
,
std
::
chrono
::
milliseconds
(
150
),
atom
(
"Step"
));
}
);
}
...
...
examples/dining_philosophers.cpp
View file @
4e9082f0
...
...
@@ -102,7 +102,7 @@ struct philosopher : fsm_actor<philosopher> {
<<
" and starts to eat
\n
"
;
cout
<<
oss
.
str
();
// eat some time
future
_send
(
this
,
seconds
(
5
),
atom
(
"think"
));
delayed
_send
(
this
,
seconds
(
5
),
atom
(
"think"
));
become
(
&
eating
);
},
on
(
atom
(
"busy"
),
what
)
>>
[
=
]()
{
...
...
@@ -152,7 +152,7 @@ struct philosopher : fsm_actor<philosopher> {
on
(
atom
(
"think"
))
>>
[
=
]()
{
send
(
left
,
atom
(
"put"
),
this
);
send
(
right
,
atom
(
"put"
),
this
);
future
_send
(
this
,
seconds
(
5
),
atom
(
"eat"
));
delayed
_send
(
this
,
seconds
(
5
),
atom
(
"eat"
));
cout
<<
(
name
+
" puts down his chopsticks and starts to think
\n
"
);
become
(
&
thinking
);
...
...
@@ -162,7 +162,7 @@ struct philosopher : fsm_actor<philosopher> {
init_state
=
(
on
(
atom
(
"think"
))
>>
[
=
]()
{
cout
<<
(
name
+
" starts to think
\n
"
);
future
_send
(
this
,
seconds
(
5
),
atom
(
"eat"
));
delayed
_send
(
this
,
seconds
(
5
),
atom
(
"eat"
));
become
(
&
thinking
);
}
);
...
...
examples/math_actor_example.cpp
View file @
4e9082f0
...
...
@@ -45,7 +45,7 @@ struct math_actor : event_based_actor {
on
(
atom
(
"quit"
))
>>
[
=
]()
{
// set an empty behavior
// (terminates actor with normal exit reason)
become_void
();
quit_normal
();
}
);
}
...
...
src/actor.cpp
View file @
4e9082f0
...
...
@@ -61,7 +61,7 @@ actor::actor(std::uint32_t aid, const process_information_ptr& pptr)
}
}
bool
actor
::
pending
_enqueue
(
actor
*
sender
,
any_tuple
msg
)
{
bool
actor
::
chained
_enqueue
(
actor
*
sender
,
any_tuple
msg
)
{
enqueue
(
sender
,
std
::
move
(
msg
));
return
false
;
}
...
...
src/event_based_actor.cpp
View file @
4e9082f0
...
...
@@ -36,14 +36,10 @@ event_based_actor::event_based_actor() {
m_loop_stack
.
reserve
(
2
);
}
void
event_based_actor
::
become_void
()
{
cleanup
(
exit_reason
::
normal
);
m_loop_stack
.
clear
();
}
void
event_based_actor
::
quit
(
std
::
uint32_t
reason
)
{
if
(
reason
==
exit_reason
::
normal
)
{
become_void
();
cleanup
(
exit_reason
::
normal
);
m_loop_stack
.
clear
();
}
else
{
abstract_scheduled_actor
::
quit
(
reason
);
...
...
src/local_actor.cpp
View file @
4e9082f0
...
...
@@ -32,7 +32,8 @@
namespace
cppa
{
local_actor
::
local_actor
(
bool
sflag
)
:
m_trap_exit
(
false
),
m_is_scheduled
(
sflag
)
{
local_actor
::
local_actor
(
bool
sflag
)
:
m_chaining
(
sflag
),
m_trap_exit
(
false
),
m_is_scheduled
(
sflag
)
{
}
}
// namespace cppa
src/scheduler.cpp
View file @
4e9082f0
...
...
@@ -170,7 +170,7 @@ scheduler::~scheduler() {
delete
m_helper
;
}
channel
*
scheduler
::
future
_send_helper
()
{
channel
*
scheduler
::
delayed
_send_helper
()
{
return
m_helper
->
m_worker
.
get
();
}
...
...
src/stacked_event_based_actor.cpp
View file @
4e9082f0
...
...
@@ -32,7 +32,7 @@
namespace
cppa
{
void
stacked_event_based_actor
::
become_void
()
{
void
stacked_event_based_actor
::
quit_normal
()
{
m_loop_stack
.
clear
();
}
...
...
src/thread_pool_scheduler.cpp
View file @
4e9082f0
...
...
@@ -125,9 +125,9 @@ struct thread_pool_scheduler::worker {
scheduled_actor
*
pending_job
;
handler
()
:
job
(
nullptr
),
pending_job
(
nullptr
)
{
}
void
exec_done
()
{
if
(
job
->
pending
_actor
())
{
pending_job
=
static_cast
<
scheduled_actor
*>
(
job
->
pending
_actor
().
get
());
job
->
pending
_actor
().
reset
();
if
(
job
->
chained
_actor
())
{
pending_job
=
static_cast
<
scheduled_actor
*>
(
job
->
chained
_actor
().
get
());
job
->
chained
_actor
().
reset
();
}
if
(
!
job
->
deref
())
delete
job
;
CPPA_MEMORY_BARRIER
();
...
...
@@ -153,9 +153,9 @@ struct thread_pool_scheduler::worker {
do
{
h
.
job
->
resume
(
&
fself
,
&
h
);
if
(
h
.
job
)
{
if
(
h
.
job
->
pending
_actor
())
{
h
.
pending_job
=
static_cast
<
scheduled_actor
*>
(
h
.
job
->
pending
_actor
().
get
());
h
.
job
->
pending
_actor
().
reset
();
if
(
h
.
job
->
chained
_actor
())
{
h
.
pending_job
=
static_cast
<
scheduled_actor
*>
(
h
.
job
->
chained
_actor
().
get
());
h
.
job
->
chained
_actor
().
reset
();
}
else
{
h
.
job
=
nullptr
;
...
...
unit_testing/ping_pong.cpp
View file @
4e9082f0
...
...
@@ -46,7 +46,7 @@ actor_ptr spawn_event_based_ping(size_t num_pings) {
//cout << to_string(self->last_dequeued()) << endl;
if
(
++
s_pongs
>=
num_pings
)
{
reply
(
atom
(
"EXIT"
),
exit_reason
::
user_defined
);
become_void
();
quit_normal
();
}
else
{
reply
(
atom
(
"ping"
),
value
);
...
...
unit_testing/test__spawn.cpp
View file @
4e9082f0
#define CPPA_VERBOSE_CHECK
#include <stack>
#include <chrono>
#include <iostream>
...
...
@@ -24,6 +22,35 @@ using std::endl;
using
namespace
cppa
;
#if (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 7)
struct
simple_mirror
:
fsm_actor
<
simple_mirror
>
{
behavior
init_state
=
(
others
()
>>
[]()
{
self
->
last_sender
()
<<
self
->
last_dequeued
();
}
);
};
#else
struct
simple_mirror
:
event_based_actor
{
void
init
()
{
become
(
others
()
>>
[]()
{
self
->
last_sender
()
<<
self
->
last_dequeued
();
}
);
}
};
#endif
// GCC 4.7 supports non-static member initialization
#if 0 //(__GNUC__ >= 4) && (__GNUC_MINOR__ >= 7)
...
...
@@ -113,7 +140,7 @@ abstract_event_based_actor* event_testee2() {
behavior
wait4timeout
(
int
remaining
)
{
return
(
after
(
std
::
chrono
::
milliseconds
(
50
))
>>
[
=
]()
{
if
(
remaining
==
1
)
become_void
();
if
(
remaining
==
1
)
quit_normal
();
else
become
(
wait4timeout
(
remaining
-
1
));
}
);
...
...
@@ -137,7 +164,7 @@ struct chopstick : public fsm_actor<chopstick> {
become
(
&
init_state
);
},
on
(
atom
(
"break"
))
>>
[
=
]()
{
become_void
();
quit_normal
();
}
);
}
...
...
@@ -151,7 +178,7 @@ struct chopstick : public fsm_actor<chopstick> {
reply
(
atom
(
"taken"
));
},
on
(
atom
(
"break"
))
>>
[
=
]()
{
become_void
();
quit_normal
();
},
others
()
>>
[
=
]()
{
}
...
...
@@ -224,8 +251,8 @@ void testee2(actor_ptr other) {
}
void
testee3
(
actor_ptr
parent
)
{
// test a
future
_send / delayed_reply based loop
future
_send
(
self
,
std
::
chrono
::
milliseconds
(
50
),
atom
(
"Poll"
));
// test a
delayed
_send / delayed_reply based loop
delayed
_send
(
self
,
std
::
chrono
::
milliseconds
(
50
),
atom
(
"Poll"
));
int
polls
=
0
;
receive_for
(
polls
,
5
)
(
on
(
atom
(
"Poll"
))
>>
[
&
]()
{
...
...
@@ -387,11 +414,15 @@ size_t test__spawn() {
);
CPPA_IF_VERBOSE
(
cout
<<
"ok"
<<
endl
);
/*
auto mirror = actor_prototype (
others() >> []() {
self->last_sender() << self->last_dequeued();
}
).spawn();
*/
auto
mirror
=
spawn
(
new
simple_mirror
);
CPPA_IF_VERBOSE
(
cout
<<
"test mirror ... "
<<
std
::
flush
);
send
(
mirror
,
"hello mirror"
);
...
...
@@ -422,8 +453,8 @@ size_t test__spawn() {
}
);
CPPA_IF_VERBOSE
(
cout
<<
"test
future
_send() ... "
<<
std
::
flush
);
future
_send
(
self
,
std
::
chrono
::
seconds
(
1
),
1
,
2
,
3
);
CPPA_IF_VERBOSE
(
cout
<<
"test
delayed
_send() ... "
<<
std
::
flush
);
delayed
_send
(
self
,
std
::
chrono
::
seconds
(
1
),
1
,
2
,
3
);
receive
(
on
(
1
,
2
,
3
)
>>
[]()
{
});
CPPA_IF_VERBOSE
(
cout
<<
"ok"
<<
endl
);
...
...
@@ -497,7 +528,7 @@ size_t test__spawn() {
self
->
link_to
(
pong_actor
);
int
i
=
0
;
int
flags
=
0
;
future
_send
(
self
,
std
::
chrono
::
seconds
(
1
),
atom
(
"FooBar"
));
delayed
_send
(
self
,
std
::
chrono
::
seconds
(
1
),
atom
(
"FooBar"
));
// wait for DOWN and EXIT messages of pong
receive_for
(
i
,
4
)
(
on
<
atom
(
"EXIT"
),
std
::
uint32_t
>
()
>>
[
&
](
std
::
uint32_t
reason
)
{
...
...
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