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
ecb9ab91
Commit
ecb9ab91
authored
Jan 09, 2014
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reimplemented delayed send, fixed logging
parent
5bd0f51d
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
121 additions
and
84 deletions
+121
-84
cppa/behavior_stack_based.hpp
cppa/behavior_stack_based.hpp
+6
-10
cppa/blocking_untyped_actor.hpp
cppa/blocking_untyped_actor.hpp
+3
-6
cppa/detail/proper_actor.hpp
cppa/detail/proper_actor.hpp
+24
-4
cppa/local_actor.hpp
cppa/local_actor.hpp
+0
-15
cppa/logging.hpp
cppa/logging.hpp
+1
-1
cppa/match_expr.hpp
cppa/match_expr.hpp
+1
-1
cppa/partial_function.hpp
cppa/partial_function.hpp
+6
-0
cppa/policy/invoke_policy.hpp
cppa/policy/invoke_policy.hpp
+11
-6
cppa/policy/no_scheduling.hpp
cppa/policy/no_scheduling.hpp
+7
-1
cppa/scheduler.hpp
cppa/scheduler.hpp
+2
-2
cppa/scoped_actor.hpp
cppa/scoped_actor.hpp
+5
-0
src/empty_tuple.cpp
src/empty_tuple.cpp
+1
-1
src/local_actor.cpp
src/local_actor.cpp
+4
-6
src/scheduler.cpp
src/scheduler.cpp
+2
-0
src/scoped_actor.cpp
src/scoped_actor.cpp
+20
-5
src/thread_pool_scheduler.cpp
src/thread_pool_scheduler.cpp
+1
-1
src/uniform_type_info_map.cpp
src/uniform_type_info_map.cpp
+4
-2
unit_testing/test_spawn.cpp
unit_testing/test_spawn.cpp
+23
-23
No files found.
cppa/behavior_stack_based.hpp
View file @
ecb9ab91
...
@@ -102,17 +102,9 @@ class behavior_stack_based : public Base {
...
@@ -102,17 +102,9 @@ class behavior_stack_based : public Base {
do_become
(
match_expr_convert
(
std
::
forward
<
Ts
>
(
args
)...),
Discard
);
do_become
(
match_expr_convert
(
std
::
forward
<
Ts
>
(
args
)...),
Discard
);
}
}
void
become_waiting_for
(
behavior
bhvr
,
message_id
mf
)
{
virtual
void
become_waiting_for
(
behavior
bhvr
,
message_id
mf
)
=
0
;
if
(
bhvr
.
timeout
().
valid
())
{
//FIXME
}
m_bhvr_stack
.
push_back
(
std
::
move
(
bhvr
),
mf
);
}
void
do_become
(
behavior
&&
bhvr
,
bool
discard_old
)
{
virtual
void
do_become
(
behavior
&&
bhvr
,
bool
discard_old
)
=
0
;
if
(
discard_old
)
m_bhvr_stack
.
pop_async_back
();
m_bhvr_stack
.
push_back
(
std
::
move
(
bhvr
));
}
inline
bool
has_behavior
()
const
{
inline
bool
has_behavior
()
const
{
return
m_bhvr_stack
.
empty
()
==
false
;
return
m_bhvr_stack
.
empty
()
==
false
;
...
@@ -135,6 +127,10 @@ class behavior_stack_based : public Base {
...
@@ -135,6 +127,10 @@ class behavior_stack_based : public Base {
return
m_bhvr_stack
.
sync_handler
(
msg_id
);
return
m_bhvr_stack
.
sync_handler
(
msg_id
);
}
}
inline
void
remove_handler
(
message_id
mid
)
{
m_bhvr_stack
.
erase
(
mid
);
}
protected:
protected:
// allows actors to keep previous behaviors and enables unbecome()
// allows actors to keep previous behaviors and enables unbecome()
...
...
cppa/blocking_untyped_actor.hpp
View file @
ecb9ab91
...
@@ -307,6 +307,9 @@ class blocking_untyped_actor : public extend<local_actor>::with<mailbox_based> {
...
@@ -307,6 +307,9 @@ class blocking_untyped_actor : public extend<local_actor>::with<mailbox_based> {
return
none
;
return
none
;
}
}
// unused in blocking actors
inline
void
remove_handler
(
message_id
)
{
}
inline
void
dequeue
(
behavior
&&
bhvr
)
{
inline
void
dequeue
(
behavior
&&
bhvr
)
{
behavior
tmp
{
std
::
move
(
bhvr
)};
behavior
tmp
{
std
::
move
(
bhvr
)};
dequeue
(
tmp
);
dequeue
(
tmp
);
...
@@ -336,12 +339,6 @@ class blocking_untyped_actor : public extend<local_actor>::with<mailbox_based> {
...
@@ -336,12 +339,6 @@ class blocking_untyped_actor : public extend<local_actor>::with<mailbox_based> {
return
[
=
](
behavior
&
bhvr
)
{
dequeue
(
bhvr
);
};
return
[
=
](
behavior
&
bhvr
)
{
dequeue
(
bhvr
);
};
}
}
/*
void dequeue_response(behavior& bhvr, message_id request_id) {
m_recv_policy.receive(util::dptr<Subtype>(this), bhvr, request_id);
}
*/
};
};
}
// namespace cppa
}
// namespace cppa
...
...
cppa/detail/proper_actor.hpp
View file @
ecb9ab91
...
@@ -98,8 +98,6 @@ class proper_actor : public proper_actor_base<Base, SchedulingPolicy,
...
@@ -98,8 +98,6 @@ class proper_actor : public proper_actor_base<Base, SchedulingPolicy,
template
<
typename
...
Ts
>
template
<
typename
...
Ts
>
proper_actor
(
Ts
&&
...
args
)
:
super
(
std
::
forward
<
Ts
>
(
args
)...)
{
}
proper_actor
(
Ts
&&
...
args
)
:
super
(
std
::
forward
<
Ts
>
(
args
)...)
{
}
detail
::
behavior_stack
&
bhvr_stack
()
{
return
this
->
m_bhvr_stack
;
}
inline
void
launch
()
{
inline
void
launch
()
{
auto
bhvr
=
this
->
make_behavior
();
auto
bhvr
=
this
->
make_behavior
();
if
(
bhvr
)
this
->
bhvr_stack
().
push_back
(
std
::
move
(
bhvr
));
if
(
bhvr
)
this
->
bhvr_stack
().
push_back
(
std
::
move
(
bhvr
));
...
@@ -107,8 +105,30 @@ class proper_actor : public proper_actor_base<Base, SchedulingPolicy,
...
@@ -107,8 +105,30 @@ class proper_actor : public proper_actor_base<Base, SchedulingPolicy,
}
}
bool
invoke
(
mailbox_element
*
msg
)
{
bool
invoke
(
mailbox_element
*
msg
)
{
return
this
->
m_invoke_policy
.
invoke
(
this
,
msg
,
bhvr_stack
().
back
(),
return
this
->
m_invoke_policy
.
invoke
(
this
,
msg
,
this
->
bhvr_stack
().
back
(),
bhvr_stack
().
back_id
());
this
->
bhvr_stack
().
back_id
());
}
void
become_waiting_for
(
behavior
bhvr
,
message_id
mf
)
override
{
if
(
bhvr
.
timeout
().
valid
())
{
if
(
bhvr
.
timeout
().
valid
())
{
this
->
invoke_policy
().
reset_timeout
();
this
->
invoke_policy
().
request_timeout
(
this
,
bhvr
.
timeout
());
}
this
->
bhvr_stack
().
push_back
(
std
::
move
(
bhvr
),
mf
);
}
this
->
bhvr_stack
().
push_back
(
std
::
move
(
bhvr
),
mf
);
}
void
do_become
(
behavior
&&
bhvr
,
bool
discard_old
)
override
{
//if (discard_old) m_bhvr_stack.pop_async_back();
//m_bhvr_stack.push_back(std::move(bhvr));
this
->
invoke_policy
().
reset_timeout
();
if
(
bhvr
.
timeout
().
valid
())
{
this
->
invoke_policy
().
request_timeout
(
this
,
bhvr
.
timeout
());
}
if
(
discard_old
)
this
->
m_bhvr_stack
.
pop_async_back
();
this
->
m_bhvr_stack
.
push_back
(
std
::
move
(
bhvr
));
}
}
};
};
...
...
cppa/local_actor.hpp
View file @
ecb9ab91
...
@@ -374,8 +374,6 @@ class local_actor : public extend<abstract_actor>::with<memory_cached> {
...
@@ -374,8 +374,6 @@ class local_actor : public extend<abstract_actor>::with<memory_cached> {
return
mailbox_element
::
create
(
std
::
forward
<
Ts
>
(
args
)...);
return
mailbox_element
::
create
(
std
::
forward
<
Ts
>
(
args
)...);
}
}
void
remove_handler
(
message_id
id
);
void
cleanup
(
std
::
uint32_t
reason
);
void
cleanup
(
std
::
uint32_t
reason
);
// true if this actor receives EXIT messages as ordinary messages
// true if this actor receives EXIT messages as ordinary messages
...
@@ -461,19 +459,6 @@ inline void local_actor::mark_arrived(message_id response_id) {
...
@@ -461,19 +459,6 @@ inline void local_actor::mark_arrived(message_id response_id) {
if
(
i
!=
last
)
m_pending_responses
.
erase
(
i
);
if
(
i
!=
last
)
m_pending_responses
.
erase
(
i
);
}
}
//inline detail::behavior_stack& local_actor::bhvr_stack() {
// return m_bhvr_stack;
//}
//inline void local_actor::do_become(const behavior& bhvr, bool discard_old) {
// behavior copy{bhvr};
// do_become(std::move(copy), discard_old);
//}
//inline void local_actor::remove_handler(message_id id) {
// m_bhvr_stack.erase(id);
//}
inline
std
::
uint32_t
local_actor
::
planned_exit_reason
()
const
{
inline
std
::
uint32_t
local_actor
::
planned_exit_reason
()
const
{
return
m_planned_exit_reason
;
return
m_planned_exit_reason
;
}
}
...
...
cppa/logging.hpp
View file @
ecb9ab91
...
@@ -162,7 +162,7 @@ oss_wr operator<<(oss_wr&& lhs, T rhs) {
...
@@ -162,7 +162,7 @@ oss_wr operator<<(oss_wr&& lhs, T rhs) {
#define CPPA_LVL_NAME4() "TRACE"
#define CPPA_LVL_NAME4() "TRACE"
#ifndef CPPA_LOG_LEVEL
#ifndef CPPA_LOG_LEVEL
# define CPPA_LOG_IMPL(lvlname, classname, funname,
unused,
message) { \
# define CPPA_LOG_IMPL(lvlname, classname, funname, message) { \
std::cerr << "[" << lvlname << "] " << classname << "::" \
std::cerr << "[" << lvlname << "] " << classname << "::" \
<< funname << ": " << message << "\nStack trace:\n"; \
<< funname << ": " << message << "\nStack trace:\n"; \
void *array[10]; \
void *array[10]; \
...
...
cppa/match_expr.hpp
View file @
ecb9ab91
...
@@ -862,7 +862,7 @@ struct match_expr_from_type_list<util::type_list<Ts...> > {
...
@@ -862,7 +862,7 @@ struct match_expr_from_type_list<util::type_list<Ts...> > {
template
<
typename
...
Lhs
,
typename
...
Rhs
>
template
<
typename
...
Lhs
,
typename
...
Rhs
>
inline
match_expr
<
Lhs
...,
Rhs
...
>
operator
,(
const
match_expr
<
Lhs
...
>&
lhs
,
inline
match_expr
<
Lhs
...,
Rhs
...
>
operator
,(
const
match_expr
<
Lhs
...
>&
lhs
,
const
match_expr
<
Rhs
...
>&
rhs
)
{
const
match_expr
<
Rhs
...
>&
rhs
)
{
return
lhs
.
or_else
(
rhs
);
return
lhs
.
or_else
(
rhs
);
}
}
...
...
cppa/partial_function.hpp
View file @
ecb9ab91
...
@@ -145,6 +145,12 @@ partial_function operator,(const match_expr<Cases...>& mexpr,
...
@@ -145,6 +145,12 @@ partial_function operator,(const match_expr<Cases...>& mexpr,
return
mexpr
.
as_behavior_impl
()
->
or_else
(
pfun
.
as_behavior_impl
());
return
mexpr
.
as_behavior_impl
()
->
or_else
(
pfun
.
as_behavior_impl
());
}
}
template
<
typename
...
Cases
>
partial_function
operator
,(
const
partial_function
&
pfun
,
const
match_expr
<
Cases
...
>&
mexpr
)
{
return
pfun
.
as_behavior_impl
()
->
or_else
(
mexpr
.
as_behavior_impl
());
}
/******************************************************************************
/******************************************************************************
* inline and template member function implementations *
* inline and template member function implementations *
******************************************************************************/
******************************************************************************/
...
...
cppa/policy/invoke_policy.hpp
View file @
ecb9ab91
...
@@ -262,9 +262,8 @@ class invoke_policy {
...
@@ -262,9 +262,8 @@ class invoke_policy {
}
}
else
if
(
v0
==
atom
(
"SYNC_TOUT"
))
{
else
if
(
v0
==
atom
(
"SYNC_TOUT"
))
{
CPPA_REQUIRE
(
!
mid
.
valid
());
CPPA_REQUIRE
(
!
mid
.
valid
());
//FIXME
return
dptr
()
->
waits_for_timeout
(
v1
)
?
timeout_message
//return self->waits_for_timeout(v1) ? timeout_message
:
expired_timeout_message
;
// : expired_timeout_message;
}
}
}
}
else
if
(
msg
.
size
()
==
1
else
if
(
msg
.
size
()
==
1
...
@@ -301,6 +300,8 @@ class invoke_policy {
...
@@ -301,6 +300,8 @@ class invoke_policy {
Fun
&
fun
,
Fun
&
fun
,
MaybeResponseHandle
hdl
=
MaybeResponseHandle
{})
{
MaybeResponseHandle
hdl
=
MaybeResponseHandle
{})
{
auto
res
=
fun
(
msg
);
// might change mid
auto
res
=
fun
(
msg
);
// might change mid
CPPA_LOG_DEBUG_IF
(
res
,
"actor did consume message"
);
CPPA_LOG_DEBUG_IF
(
!
res
,
"actor did ignore message"
);
if
(
res
)
{
if
(
res
)
{
//message_header hdr{self, sender, mid.is_request() ? mid.response_id()
//message_header hdr{self, sender, mid.is_request() ? mid.response_id()
// : message_id{}};
// : message_id{}};
...
@@ -382,7 +383,8 @@ class invoke_policy {
...
@@ -382,7 +383,8 @@ class invoke_policy {
Fun
&
fun
,
Fun
&
fun
,
message_id
awaited_response
)
{
message_id
awaited_response
)
{
bool
handle_sync_failure_on_mismatch
=
true
;
bool
handle_sync_failure_on_mismatch
=
true
;
if
(
dptr
()
->
hm_should_skip
(
node
))
{
return
hm_skip_msg
;
if
(
dptr
()
->
hm_should_skip
(
node
))
{
return
hm_skip_msg
;
}
}
switch
(
this
->
filter_msg
(
self
,
node
))
{
switch
(
this
->
filter_msg
(
self
,
node
))
{
default:
{
default:
{
...
@@ -412,7 +414,7 @@ class invoke_policy {
...
@@ -412,7 +414,7 @@ class invoke_policy {
dptr
()
->
handle_timeout
(
self
,
fun
);
dptr
()
->
handle_timeout
(
self
,
fun
);
if
(
awaited_response
.
valid
())
{
if
(
awaited_response
.
valid
())
{
self
->
mark_arrived
(
awaited_response
);
self
->
mark_arrived
(
awaited_response
);
//FIXME:
self->remove_handler(awaited_response);
self
->
remove_handler
(
awaited_response
);
}
}
return
hm_msg_handled
;
return
hm_msg_handled
;
}
}
...
@@ -437,7 +439,7 @@ class invoke_policy {
...
@@ -437,7 +439,7 @@ class invoke_policy {
self
->
handle_sync_failure
();
self
->
handle_sync_failure
();
}
}
self
->
mark_arrived
(
awaited_response
);
self
->
mark_arrived
(
awaited_response
);
//FIXME:
self->remove_handler(awaited_response);
self
->
remove_handler
(
awaited_response
);
dptr
()
->
hm_cleanup
(
self
,
previous_node
);
dptr
()
->
hm_cleanup
(
self
,
previous_node
);
return
hm_msg_handled
;
return
hm_msg_handled
;
}
}
...
@@ -459,6 +461,9 @@ class invoke_policy {
...
@@ -459,6 +461,9 @@ class invoke_policy {
// no match (restore self members)
// no match (restore self members)
dptr
()
->
hm_revert
(
self
,
previous_node
);
dptr
()
->
hm_revert
(
self
,
previous_node
);
}
}
CPPA_LOG_DEBUG_IF
(
awaited_response
.
valid
(),
"ignored message; await response: "
<<
awaited_response
.
integer_value
());
return
hm_cache_msg
;
return
hm_cache_msg
;
}
}
}
}
...
...
cppa/policy/no_scheduling.hpp
View file @
ecb9ab91
...
@@ -130,7 +130,13 @@ class no_scheduling {
...
@@ -130,7 +130,13 @@ class no_scheduling {
});
});
util
::
fiber
fself
;
util
::
fiber
fself
;
for
(;;)
{
for
(;;)
{
await_data
(
self
);
try
{
await_data
(
self
);
}
catch
(
std
::
exception
&
e
)
{
std
::
cerr
<<
detail
::
demangle
(
typeid
(
e
))
<<
", what: "
<<
e
.
what
()
<<
std
::
endl
;
throw
;
}
if
(
self
->
resume
(
&
fself
)
==
resumable
::
done
)
{
if
(
self
->
resume
(
&
fself
)
==
resumable
::
done
)
{
CPPA_LOG_DEBUG
(
"resume returned resumable::done"
);
CPPA_LOG_DEBUG
(
"resume returned resumable::done"
);
self
->
planned_exit_reason
(
exit_reason
::
normal
);
self
->
planned_exit_reason
(
exit_reason
::
normal
);
...
...
cppa/scheduler.hpp
View file @
ecb9ab91
...
@@ -112,7 +112,7 @@ class scheduler {
...
@@ -112,7 +112,7 @@ class scheduler {
util
::
duration
{
rel_time
},
util
::
duration
{
rel_time
},
std
::
move
(
hdr
),
std
::
move
(
hdr
),
std
::
move
(
data
));
std
::
move
(
data
));
//TODO: delayed_send_helper()->enqueue(nullptr
, std::move(tup));
delayed_send_helper
().
enqueue
(
message_header
{}
,
std
::
move
(
tup
));
}
}
template
<
typename
Duration
,
typename
...
Data
>
template
<
typename
Duration
,
typename
...
Data
>
...
@@ -124,7 +124,7 @@ class scheduler {
...
@@ -124,7 +124,7 @@ class scheduler {
util
::
duration
{
rel_time
},
util
::
duration
{
rel_time
},
std
::
move
(
hdr
),
std
::
move
(
hdr
),
std
::
move
(
data
));
std
::
move
(
data
));
//TODO: delayed_send_helper()->enqueue(nullptr
, std::move(tup));
delayed_send_helper
().
enqueue
(
message_header
{}
,
std
::
move
(
tup
));
}
}
private:
private:
...
...
cppa/scoped_actor.hpp
View file @
ecb9ab91
...
@@ -42,6 +42,8 @@ class scoped_actor {
...
@@ -42,6 +42,8 @@ class scoped_actor {
scoped_actor
();
scoped_actor
();
explicit
scoped_actor
(
bool
hidden
);
~
scoped_actor
();
~
scoped_actor
();
inline
blocking_untyped_actor
*
operator
->
()
const
{
inline
blocking_untyped_actor
*
operator
->
()
const
{
...
@@ -70,6 +72,9 @@ class scoped_actor {
...
@@ -70,6 +72,9 @@ class scoped_actor {
private:
private:
void
init
(
bool
hidden
);
bool
m_hidden
;
actor_id
m_prev
;
actor_id
m_prev
;
intrusive_ptr
<
blocking_untyped_actor
>
m_self
;
intrusive_ptr
<
blocking_untyped_actor
>
m_self
;
...
...
src/empty_tuple.cpp
View file @
ecb9ab91
...
@@ -64,7 +64,7 @@ const std::type_info* empty_tuple::type_token() const {
...
@@ -64,7 +64,7 @@ const std::type_info* empty_tuple::type_token() const {
}
}
const
std
::
string
*
empty_tuple
::
tuple_type_names
()
const
{
const
std
::
string
*
empty_tuple
::
tuple_type_names
()
const
{
static
std
::
string
result
=
""
;
static
std
::
string
result
=
"
@<>
"
;
return
&
result
;
return
&
result
;
}
}
...
...
src/local_actor.cpp
View file @
ecb9ab91
...
@@ -153,12 +153,10 @@ void local_actor::send_exit(const actor_addr& whom, std::uint32_t reason) {
...
@@ -153,12 +153,10 @@ void local_actor::send_exit(const actor_addr& whom, std::uint32_t reason) {
send
(
detail
::
raw_access
::
get
(
whom
),
atom
(
"EXIT"
),
reason
);
send
(
detail
::
raw_access
::
get
(
whom
),
atom
(
"EXIT"
),
reason
);
}
}
void
local_actor
::
remove_handler
(
message_id
)
{
void
local_actor
::
delayed_send_tuple
(
const
channel
&
dest
,
const
util
::
duration
&
rel_time
,
}
cppa
::
any_tuple
msg
)
{
get_scheduler
()
->
delayed_send
({
address
(),
dest
},
rel_time
,
std
::
move
(
msg
));
void
local_actor
::
delayed_send_tuple
(
const
channel
&
,
const
util
::
duration
&
,
cppa
::
any_tuple
)
{
}
}
response_promise
local_actor
::
make_response_promise
()
{
response_promise
local_actor
::
make_response_promise
()
{
...
...
src/scheduler.cpp
View file @
ecb9ab91
...
@@ -89,6 +89,8 @@ class scheduler_helper {
...
@@ -89,6 +89,8 @@ class scheduler_helper {
public:
public:
scheduler_helper
()
:
m_timer
(
true
),
m_printer
(
true
)
{
}
void
start
()
{
void
start
()
{
// launch threads
// launch threads
m_timer_thread
=
std
::
thread
{
&
scheduler_helper
::
timer_loop
,
m_timer
.
get
()};
m_timer_thread
=
std
::
thread
{
&
scheduler_helper
::
timer_loop
,
m_timer
.
get
()};
...
...
src/scoped_actor.cpp
View file @
ecb9ab91
...
@@ -54,14 +54,29 @@ blocking_untyped_actor* alloc() {
...
@@ -54,14 +54,29 @@ blocking_untyped_actor* alloc() {
}
// namespace <anonymous>
}
// namespace <anonymous>
scoped_actor
::
scoped_actor
()
:
m_self
(
alloc
())
{
void
scoped_actor
::
init
(
bool
hidden
)
{
m_prev
=
CPPA_SET_AID
(
m_self
->
id
());
m_hidden
=
hidden
;
get_actor_registry
()
->
inc_running
();
m_self
.
reset
(
alloc
());
if
(
!
hidden
)
{
m_prev
=
CPPA_SET_AID
(
m_self
->
id
());
get_actor_registry
()
->
inc_running
();
}
}
scoped_actor
::
scoped_actor
()
{
init
(
false
);
}
scoped_actor
::
scoped_actor
(
bool
hidden
)
{
init
(
hidden
);
}
}
scoped_actor
::~
scoped_actor
()
{
scoped_actor
::~
scoped_actor
()
{
get_actor_registry
()
->
dec_running
();
if
(
!
m_hidden
)
{
CPPA_SET_AID
(
m_prev
);
get_actor_registry
()
->
dec_running
();
CPPA_SET_AID
(
m_prev
);
}
}
}
}
// namespace cppa
}
// namespace cppa
src/thread_pool_scheduler.cpp
View file @
ecb9ab91
...
@@ -62,7 +62,7 @@ struct thread_pool_scheduler::worker {
...
@@ -62,7 +62,7 @@ struct thread_pool_scheduler::worker {
worker
(
job_queue
*
jq
,
job_ptr
dummy
)
:
m_job_queue
(
jq
),
m_dummy
(
dummy
)
{
}
worker
(
job_queue
*
jq
,
job_ptr
dummy
)
:
m_job_queue
(
jq
),
m_dummy
(
dummy
)
{
}
void
start
()
{
void
start
()
{
//
m_thread = std::thread(&thread_pool_scheduler::worker_loop, this);
m_thread
=
std
::
thread
(
&
thread_pool_scheduler
::
worker_loop
,
this
);
}
}
worker
(
const
worker
&
)
=
delete
;
worker
(
const
worker
&
)
=
delete
;
...
...
src/uniform_type_info_map.cpp
View file @
ecb9ab91
...
@@ -271,8 +271,10 @@ void serialize_impl(const any_tuple& tup, serializer* sink) {
...
@@ -271,8 +271,10 @@ void serialize_impl(const any_tuple& tup, serializer* sink) {
auto
tname
=
tup
.
tuple_type_names
();
auto
tname
=
tup
.
tuple_type_names
();
auto
uti
=
get_uniform_type_info_map
()
->
by_uniform_name
(
tname
?
*
tname
:
detail
::
get_tuple_type_names
(
*
tup
.
vals
()));
auto
uti
=
get_uniform_type_info_map
()
->
by_uniform_name
(
tname
?
*
tname
:
detail
::
get_tuple_type_names
(
*
tup
.
vals
()));
if
(
uti
==
nullptr
)
{
if
(
uti
==
nullptr
)
{
std
::
string
err
=
"could not get uniform type info for "
;
std
::
string
err
=
"could not get uniform type info for
\"
"
;
err
+=
tname
?
*
tname
:
detail
::
get_tuple_type_names
(
*
tup
.
vals
());
err
+=
tname
?
*
tname
:
detail
::
get_tuple_type_names
(
*
tup
.
vals
());
err
+=
"
\"
"
;
CPPA_LOGF_ERROR
(
err
);
throw
std
::
runtime_error
(
err
);
throw
std
::
runtime_error
(
err
);
}
}
sink
->
begin_object
(
uti
);
sink
->
begin_object
(
uti
);
...
@@ -790,7 +792,7 @@ class utim_impl : public uniform_type_info_map {
...
@@ -790,7 +792,7 @@ class utim_impl : public uniform_type_info_map {
result
=
find_name
(
m_builtin_types
,
name
);
result
=
find_name
(
m_builtin_types
,
name
);
result
=
(
result
)
?
result
:
find_name
(
m_user_types
,
name
);
result
=
(
result
)
?
result
:
find_name
(
m_user_types
,
name
);
}
}
if
(
!
result
&&
name
.
compare
(
0
,
4
,
"@<>+
"
)
==
0
)
{
if
(
!
result
&&
name
.
compare
(
0
,
3
,
"@<>
"
)
==
0
)
{
// create tuple UTI on-the-fly
// create tuple UTI on-the-fly
result
=
insert
(
create_unique
<
default_meta_tuple
>
(
name
));
result
=
insert
(
create_unique
<
default_meta_tuple
>
(
name
));
}
}
...
...
unit_testing/test_spawn.cpp
View file @
ecb9ab91
...
@@ -413,11 +413,13 @@ void test_or_else() {
...
@@ -413,11 +413,13 @@ void test_or_else() {
self
->
await_all_other_actors_done
();
self
->
await_all_other_actors_done
();
});
});
CPPA_LOGF_INFO
(
"run_testee: handle_a.or_else(handle_b).or_else(handle_c)"
);
run_testee
(
run_testee
(
spawn
([
=
]
{
spawn
([
=
]
{
return
handle_a
.
or_else
(
handle_b
).
or_else
(
handle_c
);
return
handle_a
.
or_else
(
handle_b
).
or_else
(
handle_c
);
})
})
);
);
CPPA_LOGF_INFO
(
"run_testee: handle_a.or_else(handle_b), on(
\"
c
\"
) ..."
);
run_testee
(
run_testee
(
spawn
([
=
]
{
spawn
([
=
]
{
return
(
return
(
...
@@ -426,6 +428,7 @@ void test_or_else() {
...
@@ -426,6 +428,7 @@ void test_or_else() {
);
);
})
})
);
);
CPPA_LOGF_INFO
(
"run_testee: on(
\"
a
\"
) ..., handle_b.or_else(handle_c)"
);
run_testee
(
run_testee
(
spawn
([
=
]
{
spawn
([
=
]
{
return
(
return
(
...
@@ -482,7 +485,6 @@ void test_simple_reply_response() {
...
@@ -482,7 +485,6 @@ void test_simple_reply_response() {
void
test_spawn
()
{
void
test_spawn
()
{
test_simple_reply_response
();
test_simple_reply_response
();
test_serial_reply
();
test_serial_reply
();
return
;
test_or_else
();
test_or_else
();
test_continuation
();
test_continuation
();
...
@@ -492,19 +494,16 @@ void test_spawn() {
...
@@ -492,19 +494,16 @@ void test_spawn() {
spawn
<
slave
>
(
m
);
spawn
<
slave
>
(
m
);
spawn
<
slave
>
(
m
);
spawn
<
slave
>
(
m
);
self
->
send
(
m
,
atom
(
"done"
));
self
->
send
(
m
,
atom
(
"done"
));
await_all
_actors_done
();
self
->
await_all_other
_actors_done
();
CPPA_CHECKPOINT
();
CPPA_CHECKPOINT
();
CPPA_PRINT
(
"test self->send()"
);
CPPA_PRINT
(
"test self->send()"
);
self
->
send
(
self
,
1
,
2
,
3
,
true
);
self
->
send
(
self
,
1
,
2
,
3
,
true
);
self
->
receive
(
on
(
1
,
2
,
3
,
true
)
>>
[]
{
});
self
->
receive
(
on
(
1
,
2
,
3
,
true
)
>>
[]
{
});
self
->
send
(
self
,
any_tuple
{});
self
->
send
_tuple
(
self
,
any_tuple
{});
self
->
receive
(
on
()
>>
[]
{
});
self
->
receive
(
on
()
>>
[]
{
});
CPPA_CHECKPOINT
();
CPPA_CHECKPOINT
();
self
->
send
(
self
,
any_tuple
{});
self
->
receive
(
on
()
>>
[]
{
});
CPPA_PRINT
(
"test self->receive with zero timeout"
);
CPPA_PRINT
(
"test self->receive with zero timeout"
);
self
->
receive
(
self
->
receive
(
others
()
>>
CPPA_UNEXPECTED_MSG_CB
(),
others
()
>>
CPPA_UNEXPECTED_MSG_CB
(),
...
@@ -524,7 +523,7 @@ void test_spawn() {
...
@@ -524,7 +523,7 @@ void test_spawn() {
on
(
atom
(
"DOWN"
),
exit_reason
::
user_shutdown
)
>>
CPPA_CHECKPOINT_CB
(),
on
(
atom
(
"DOWN"
),
exit_reason
::
user_shutdown
)
>>
CPPA_CHECKPOINT_CB
(),
others
()
>>
CPPA_UNEXPECTED_MSG_CB
()
others
()
>>
CPPA_UNEXPECTED_MSG_CB
()
);
);
await_all
_actors_done
();
self
->
await_all_other
_actors_done
();
CPPA_CHECKPOINT
();
CPPA_CHECKPOINT
();
}
}
...
@@ -540,7 +539,7 @@ void test_spawn() {
...
@@ -540,7 +539,7 @@ void test_spawn() {
on
(
atom
(
"DOWN"
),
exit_reason
::
user_shutdown
)
>>
CPPA_CHECKPOINT_CB
(),
on
(
atom
(
"DOWN"
),
exit_reason
::
user_shutdown
)
>>
CPPA_CHECKPOINT_CB
(),
others
()
>>
CPPA_UNEXPECTED_MSG_CB
()
others
()
>>
CPPA_UNEXPECTED_MSG_CB
()
);
);
await_all
_actors_done
();
self
->
await_all_other
_actors_done
();
CPPA_CHECKPOINT
();
CPPA_CHECKPOINT
();
}
}
...
@@ -557,7 +556,7 @@ void test_spawn() {
...
@@ -557,7 +556,7 @@ void test_spawn() {
on
(
atom
(
"DOWN"
),
exit_reason
::
user_shutdown
)
>>
CPPA_CHECKPOINT_CB
(),
on
(
atom
(
"DOWN"
),
exit_reason
::
user_shutdown
)
>>
CPPA_CHECKPOINT_CB
(),
others
()
>>
CPPA_UNEXPECTED_MSG_CB
()
others
()
>>
CPPA_UNEXPECTED_MSG_CB
()
);
);
await_all
_actors_done
();
self
->
await_all_other
_actors_done
();
CPPA_CHECKPOINT
();
CPPA_CHECKPOINT
();
}
}
...
@@ -568,12 +567,13 @@ void test_spawn() {
...
@@ -568,12 +567,13 @@ void test_spawn() {
on
(
"hello echo"
)
>>
[]
{
},
on
(
"hello echo"
)
>>
[]
{
},
others
()
>>
CPPA_UNEXPECTED_MSG_CB
()
others
()
>>
CPPA_UNEXPECTED_MSG_CB
()
);
);
await_all
_actors_done
();
self
->
await_all_other
_actors_done
();
CPPA_CHECKPOINT
();
CPPA_CHECKPOINT
();
CPPA_PRINT
(
"test delayed_send()"
);
CPPA_PRINT
(
"test delayed_send()"
);
self
->
delayed_send
(
self
,
chrono
::
seconds
(
1
),
1
,
2
,
3
);
self
->
delayed_send
(
self
,
chrono
::
seconds
(
1
),
1
,
2
,
3
);
self
->
receive
(
on
(
1
,
2
,
3
)
>>
[]
{
});
self
->
receive
(
on
(
1
,
2
,
3
)
>>
[]
{
});
self
->
await_all_other_actors_done
();
CPPA_CHECKPOINT
();
CPPA_CHECKPOINT
();
CPPA_PRINT
(
"test timeout"
);
CPPA_PRINT
(
"test timeout"
);
...
@@ -581,11 +581,11 @@ void test_spawn() {
...
@@ -581,11 +581,11 @@ void test_spawn() {
CPPA_CHECKPOINT
();
CPPA_CHECKPOINT
();
spawn
(
testee1
);
spawn
(
testee1
);
await_all
_actors_done
();
self
->
await_all_other
_actors_done
();
CPPA_CHECKPOINT
();
CPPA_CHECKPOINT
();
spawn_event_testee2
();
spawn_event_testee2
();
await_all
_actors_done
();
self
->
await_all_other
_actors_done
();
CPPA_CHECKPOINT
();
CPPA_CHECKPOINT
();
auto
cstk
=
spawn
<
chopstick
>
();
auto
cstk
=
spawn
<
chopstick
>
();
...
@@ -596,7 +596,7 @@ void test_spawn() {
...
@@ -596,7 +596,7 @@ void test_spawn() {
self
->
send
(
cstk
,
atom
(
"break"
));
self
->
send
(
cstk
,
atom
(
"break"
));
}
}
);
);
await_all
_actors_done
();
self
->
await_all_other
_actors_done
();
CPPA_CHECKPOINT
();
CPPA_CHECKPOINT
();
auto
st
=
spawn
<
fixed_stack
>
(
10
);
auto
st
=
spawn
<
fixed_stack
>
(
10
);
...
@@ -626,7 +626,7 @@ void test_spawn() {
...
@@ -626,7 +626,7 @@ void test_spawn() {
}
}
// terminate st
// terminate st
self
->
send_exit
(
st
,
exit_reason
::
user_shutdown
);
self
->
send_exit
(
st
,
exit_reason
::
user_shutdown
);
await_all
_actors_done
();
self
->
await_all_other
_actors_done
();
CPPA_CHECKPOINT
();
CPPA_CHECKPOINT
();
auto
sync_testee1
=
spawn
<
blocking_api
>
([](
blocking_untyped_actor
*
self
)
{
auto
sync_testee1
=
spawn
<
blocking_api
>
([](
blocking_untyped_actor
*
self
)
{
...
@@ -664,7 +664,7 @@ void test_spawn() {
...
@@ -664,7 +664,7 @@ void test_spawn() {
others
()
>>
CPPA_UNEXPECTED_MSG_CB
(),
others
()
>>
CPPA_UNEXPECTED_MSG_CB
(),
after
(
chrono
::
seconds
(
0
))
>>
[]
{
}
after
(
chrono
::
seconds
(
0
))
>>
[]
{
}
);
);
await_all
_actors_done
();
self
->
await_all_other
_actors_done
();
CPPA_CHECKPOINT
();
CPPA_CHECKPOINT
();
CPPA_PRINT
(
"test sync send"
);
CPPA_PRINT
(
"test sync send"
);
...
@@ -708,7 +708,7 @@ void test_spawn() {
...
@@ -708,7 +708,7 @@ void test_spawn() {
CPPA_CHECK_EQUAL
(
self
->
last_sender
(),
sync_testee
);
CPPA_CHECK_EQUAL
(
self
->
last_sender
(),
sync_testee
);
}
}
);
);
await_all
_actors_done
();
self
->
await_all_other
_actors_done
();
CPPA_CHECKPOINT
();
CPPA_CHECKPOINT
();
self
->
sync_send
(
sync_testee
,
"!?"
).
await
(
self
->
sync_send
(
sync_testee
,
"!?"
).
await
(
...
@@ -738,7 +738,7 @@ void test_spawn() {
...
@@ -738,7 +738,7 @@ void test_spawn() {
auto
poison_pill
=
make_any_tuple
(
atom
(
"done"
));
auto
poison_pill
=
make_any_tuple
(
atom
(
"done"
));
anon_send
(
joe
,
poison_pill
);
anon_send
(
joe
,
poison_pill
);
anon_send
(
bob
,
poison_pill
);
anon_send
(
bob
,
poison_pill
);
await_all
_actors_done
();
self
->
await_all_other
_actors_done
();
function
<
actor
(
const
string
&
,
const
actor
&
)
>
spawn_next
;
function
<
actor
(
const
string
&
,
const
actor
&
)
>
spawn_next
;
// it's safe to capture spawn_next as reference here, because
// it's safe to capture spawn_next as reference here, because
...
@@ -763,7 +763,7 @@ void test_spawn() {
...
@@ -763,7 +763,7 @@ void test_spawn() {
};
};
auto
joe_the_second
=
spawn
(
kr34t0r
,
"Joe"
,
invalid_actor
);
auto
joe_the_second
=
spawn
(
kr34t0r
,
"Joe"
,
invalid_actor
);
self
->
send
(
joe_the_second
,
atom
(
"done"
));
self
->
send
(
joe_the_second
,
atom
(
"done"
));
await_all
_actors_done
();
self
->
await_all_other
_actors_done
();
auto
f
=
[](
const
string
&
name
)
->
behavior
{
auto
f
=
[](
const
string
&
name
)
->
behavior
{
return
(
return
(
...
@@ -788,7 +788,7 @@ void test_spawn() {
...
@@ -788,7 +788,7 @@ void test_spawn() {
);
);
self
->
send_exit
(
a1
,
exit_reason
::
user_shutdown
);
self
->
send_exit
(
a1
,
exit_reason
::
user_shutdown
);
self
->
send_exit
(
a2
,
exit_reason
::
user_shutdown
);
self
->
send_exit
(
a2
,
exit_reason
::
user_shutdown
);
await_all
_actors_done
();
self
->
await_all_other
_actors_done
();
auto
res1
=
behavior_test
<
testee_actor
>
(
spawn
<
blocking_api
>
(
testee_actor
{}));
auto
res1
=
behavior_test
<
testee_actor
>
(
spawn
<
blocking_api
>
(
testee_actor
{}));
CPPA_CHECK_EQUAL
(
"wait4int"
,
res1
);
CPPA_CHECK_EQUAL
(
"wait4int"
,
res1
);
...
@@ -804,7 +804,7 @@ void test_spawn() {
...
@@ -804,7 +804,7 @@ void test_spawn() {
self
->
become
(
others
()
>>
CPPA_UNEXPECTED_MSG_CB
());
self
->
become
(
others
()
>>
CPPA_UNEXPECTED_MSG_CB
());
});
});
self
->
send_exit
(
legion
,
exit_reason
::
user_shutdown
);
self
->
send_exit
(
legion
,
exit_reason
::
user_shutdown
);
await_all
_actors_done
();
self
->
await_all_other
_actors_done
();
CPPA_CHECKPOINT
();
CPPA_CHECKPOINT
();
self
->
trap_exit
(
true
);
self
->
trap_exit
(
true
);
auto
ping_actor
=
self
->
spawn
<
monitored
+
blocking_api
>
(
ping
,
10
);
auto
ping_actor
=
self
->
spawn
<
monitored
+
blocking_api
>
(
ping
,
10
);
...
@@ -843,16 +843,16 @@ void test_spawn() {
...
@@ -843,16 +843,16 @@ void test_spawn() {
}
}
);
);
// wait for termination of all spawned actors
// wait for termination of all spawned actors
await_all
_actors_done
();
self
->
await_all_other
_actors_done
();
CPPA_CHECK_EQUAL
(
flags
,
0x0F
);
CPPA_CHECK_EQUAL
(
flags
,
0x0F
);
// verify pong messages
// verify pong messages
CPPA_CHECK_EQUAL
(
pongs
(),
10
);
CPPA_CHECK_EQUAL
(
pongs
(),
10
);
CPPA_CHECKPOINT
();
CPPA_CHECKPOINT
();
spawn
<
priority_aware
>
(
high_priority_testee
);
spawn
<
priority_aware
>
(
high_priority_testee
);
await_all
_actors_done
();
self
->
await_all_other
_actors_done
();
CPPA_CHECKPOINT
();
CPPA_CHECKPOINT
();
spawn
<
high_priority_testee_class
,
priority_aware
>
();
spawn
<
high_priority_testee_class
,
priority_aware
>
();
await_all
_actors_done
();
self
->
await_all_other
_actors_done
();
// don't try this at home, kids
// don't try this at home, kids
self
->
send
(
self
,
atom
(
"check"
));
self
->
send
(
self
,
atom
(
"check"
));
self
->
receive
(
self
->
receive
(
...
...
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