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
d9c92d31
Commit
d9c92d31
authored
Jan 07, 2013
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'unstable' of github.com:Neverlord/libcppa into unstable
parents
07b27254
bfc843db
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
62 additions
and
29 deletions
+62
-29
CMakeLists.txt
CMakeLists.txt
+1
-1
ChangeLog.md
ChangeLog.md
+11
-0
Doxyfile.in
Doxyfile.in
+1
-1
cppa/actor_companion_mixin.hpp
cppa/actor_companion_mixin.hpp
+1
-1
cppa/detail/event_based_actor_factory.hpp
cppa/detail/event_based_actor_factory.hpp
+3
-2
cppa/match_expr.hpp
cppa/match_expr.hpp
+6
-6
cppa/util/apply_args.hpp
cppa/util/apply_args.hpp
+6
-6
manual.pdf
manual.pdf
+0
-0
src/scheduler.cpp
src/scheduler.cpp
+6
-3
src/self.cpp
src/self.cpp
+1
-1
src/thread_pool_scheduler.cpp
src/thread_pool_scheduler.cpp
+4
-3
unit_testing/test__spawn.cpp
unit_testing/test__spawn.cpp
+22
-5
No files found.
CMakeLists.txt
View file @
d9c92d31
...
@@ -3,7 +3,7 @@ project(cppa CXX)
...
@@ -3,7 +3,7 @@ project(cppa CXX)
set
(
LIBCPPA_VERSION_MAJOR 0
)
set
(
LIBCPPA_VERSION_MAJOR 0
)
set
(
LIBCPPA_VERSION_MINOR 5
)
set
(
LIBCPPA_VERSION_MINOR 5
)
set
(
LIBCPPA_VERSION_PATCH
4
)
set
(
LIBCPPA_VERSION_PATCH
5
)
# prohibit in-source builds
# prohibit in-source builds
if
(
"
${
CMAKE_SOURCE_DIR
}
"
STREQUAL
"
${
CMAKE_BINARY_DIR
}
"
)
if
(
"
${
CMAKE_SOURCE_DIR
}
"
STREQUAL
"
${
CMAKE_BINARY_DIR
}
"
)
...
...
ChangeLog.md
View file @
d9c92d31
Version 0.5.5
-------------
__2013_01_07__
-
Cover
`aout`
in manual
-
Solved bug in chaining implementation
-
Added support for Boost.Context 1.51
-
Use
`memory::create`
rather than
`new`
for all actors
-
Simplified invoke process of
`match_expr`
Version 0.5.4
Version 0.5.4
-------------
-------------
...
...
Doxyfile.in
View file @
d9c92d31
...
@@ -31,7 +31,7 @@ PROJECT_NAME = libcppa
...
@@ -31,7 +31,7 @@ PROJECT_NAME = libcppa
# This could be handy for archiving the generated documentation or
# This could be handy for archiving the generated documentation or
# if some version control system is used.
# if some version control system is used.
PROJECT_NUMBER = "Version 0.5.
4
"
PROJECT_NUMBER = "Version 0.5.
5
"
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
# base path where the generated documentation will be put.
...
...
cppa/actor_companion_mixin.hpp
View file @
d9c92d31
...
@@ -62,7 +62,7 @@ class actor_companion_mixin : public Base {
...
@@ -62,7 +62,7 @@ class actor_companion_mixin : public Base {
template
<
typename
...
Args
>
template
<
typename
...
Args
>
actor_companion_mixin
(
Args
&&
...
args
)
:
super
(
std
::
forward
<
Args
>
(
args
)...)
{
actor_companion_mixin
(
Args
&&
...
args
)
:
super
(
std
::
forward
<
Args
>
(
args
)...)
{
m_self
.
reset
(
new
companion
(
this
));
m_self
.
reset
(
detail
::
memory
::
create
<
companion
>
(
this
));
}
}
~
actor_companion_mixin
()
{
~
actor_companion_mixin
()
{
...
...
cppa/detail/event_based_actor_factory.hpp
View file @
d9c92d31
...
@@ -37,6 +37,7 @@
...
@@ -37,6 +37,7 @@
#include "cppa/event_based_actor.hpp"
#include "cppa/event_based_actor.hpp"
#include "cppa/detail/tdata.hpp"
#include "cppa/detail/tdata.hpp"
#include "cppa/detail/memory.hpp"
#include "cppa/util/type_list.hpp"
#include "cppa/util/type_list.hpp"
namespace
cppa
{
namespace
detail
{
namespace
cppa
{
namespace
detail
{
...
@@ -103,8 +104,8 @@ class event_based_actor_factory {
...
@@ -103,8 +104,8 @@ class event_based_actor_factory {
template
<
typename
...
Args
>
template
<
typename
...
Args
>
actor_ptr
spawn
(
Args
&&
...
args
)
{
actor_ptr
spawn
(
Args
&&
...
args
)
{
return
get_scheduler
()
->
spawn
(
new
impl
(
m_init
,
m_on_exit
,
return
get_scheduler
()
->
spawn
(
memory
::
create
<
impl
>
(
m_init
,
m_on_exit
,
std
::
forward
<
Args
>
(
args
)...));
std
::
forward
<
Args
>
(
args
)...));
}
}
private:
private:
...
...
cppa/match_expr.hpp
View file @
d9c92d31
...
@@ -633,15 +633,15 @@ class match_expr {
...
@@ -633,15 +633,15 @@ class match_expr {
init
();
init
();
}
}
bool
invoke
(
const
any_tuple
&
tup
)
{
inline
bool
invoke
(
const
any_tuple
&
tup
)
{
return
invoke_impl
(
tup
);
return
invoke_impl
(
tup
);
}
}
bool
invoke
(
any_tuple
&
tup
)
{
inline
bool
invoke
(
any_tuple
&
tup
)
{
return
invoke_impl
(
tup
);
return
invoke_impl
(
tup
);
}
}
bool
invoke
(
any_tuple
&&
tup
)
{
inline
bool
invoke
(
any_tuple
&&
tup
)
{
any_tuple
tmp
{
tup
};
any_tuple
tmp
{
tup
};
return
invoke_impl
(
tmp
);
return
invoke_impl
(
tmp
);
}
}
...
@@ -658,15 +658,15 @@ class match_expr {
...
@@ -658,15 +658,15 @@ class match_expr {
tup
);
tup
);
}
}
bool
operator
()(
const
any_tuple
&
tup
)
{
inline
bool
operator
()(
const
any_tuple
&
tup
)
{
return
invoke_impl
(
tup
);
return
invoke_impl
(
tup
);
}
}
bool
operator
()(
any_tuple
&
tup
)
{
inline
bool
operator
()(
any_tuple
&
tup
)
{
return
invoke_impl
(
tup
);
return
invoke_impl
(
tup
);
}
}
bool
operator
()(
any_tuple
&&
tup
)
{
inline
bool
operator
()(
any_tuple
&&
tup
)
{
any_tuple
tmp
{
tup
};
any_tuple
tmp
{
tup
};
return
invoke_impl
(
tmp
);
return
invoke_impl
(
tmp
);
}
}
...
...
cppa/util/apply_args.hpp
View file @
d9c92d31
...
@@ -39,19 +39,19 @@
...
@@ -39,19 +39,19 @@
namespace
cppa
{
namespace
util
{
namespace
cppa
{
namespace
util
{
template
<
typename
F
,
class
Tuple
,
long
...
Is
>
template
<
typename
F
,
class
Tuple
,
long
...
Is
>
auto
apply_args
(
F
&
f
,
Tuple
&
tup
,
util
::
int_list
<
Is
...
>
)
inline
auto
apply_args
(
F
&
f
,
Tuple
&
tup
,
util
::
int_list
<
Is
...
>
)
->
decltype
(
f
(
get_cv_aware
<
Is
>
(
tup
)...))
{
->
decltype
(
f
(
get_cv_aware
<
Is
>
(
tup
)...))
{
return
f
(
get_cv_aware
<
Is
>
(
tup
)...);
return
f
(
get_cv_aware
<
Is
>
(
tup
)...);
}
}
template
<
typename
F
,
class
Tuple
,
long
...
Is
,
typename
...
Args
>
template
<
typename
F
,
class
Tuple
,
long
...
Is
,
typename
...
Args
>
auto
apply_args_prefixed
(
F
&
f
,
Tuple
&
tup
,
util
::
int_list
<
Is
...
>
,
Args
&&
...
args
)
inline
auto
apply_args_prefixed
(
F
&
f
,
Tuple
&
tup
,
util
::
int_list
<
Is
...
>
,
Args
&&
...
args
)
->
decltype
(
f
(
std
::
forward
<
Args
>
(
args
)...,
get_cv_aware
<
Is
>
(
tup
)...))
{
->
decltype
(
f
(
std
::
forward
<
Args
>
(
args
)...,
get_cv_aware
<
Is
>
(
tup
)...))
{
return
f
(
std
::
forward
<
Args
>
(
args
)...,
get_cv_aware
<
Is
>
(
tup
)...);
return
f
(
std
::
forward
<
Args
>
(
args
)...,
get_cv_aware
<
Is
>
(
tup
)...);
}
}
template
<
typename
F
,
class
Tuple
,
long
...
Is
,
typename
...
Args
>
template
<
typename
F
,
class
Tuple
,
long
...
Is
,
typename
...
Args
>
auto
apply_args_suffxied
(
F
&
f
,
Tuple
&
tup
,
util
::
int_list
<
Is
...
>
,
Args
&&
...
args
)
inline
auto
apply_args_suffxied
(
F
&
f
,
Tuple
&
tup
,
util
::
int_list
<
Is
...
>
,
Args
&&
...
args
)
->
decltype
(
f
(
get_cv_aware
<
Is
>
(
tup
)...,
std
::
forward
<
Args
>
(
args
)...))
{
->
decltype
(
f
(
get_cv_aware
<
Is
>
(
tup
)...,
std
::
forward
<
Args
>
(
args
)...))
{
return
f
(
get_cv_aware
<
Is
>
(
tup
)...,
std
::
forward
<
Args
>
(
args
)...);
return
f
(
get_cv_aware
<
Is
>
(
tup
)...,
std
::
forward
<
Args
>
(
args
)...);
}
}
...
@@ -59,7 +59,7 @@ auto apply_args_suffxied(F& f, Tuple& tup, util::int_list<Is...>, Args&&... args
...
@@ -59,7 +59,7 @@ auto apply_args_suffxied(F& f, Tuple& tup, util::int_list<Is...>, Args&&... args
template
<
typename
Result
,
size_t
NumFunctorArgs
,
size_t
NumArgs
>
template
<
typename
Result
,
size_t
NumFunctorArgs
,
size_t
NumArgs
>
struct
partially_apply_helper
{
struct
partially_apply_helper
{
template
<
class
Fun
,
typename
Arg0
,
typename
...
Args
>
template
<
class
Fun
,
typename
Arg0
,
typename
...
Args
>
static
Result
_
(
const
Fun
&
fun
,
Arg0
&&
,
Args
&&
...
args
)
{
static
inline
Result
_
(
const
Fun
&
fun
,
Arg0
&&
,
Args
&&
...
args
)
{
return
partially_apply_helper
<
Result
,
NumFunctorArgs
,
sizeof
...(
Args
)
>
return
partially_apply_helper
<
Result
,
NumFunctorArgs
,
sizeof
...(
Args
)
>
::
_
(
fun
,
std
::
forward
<
Args
>
(
args
)...);
::
_
(
fun
,
std
::
forward
<
Args
>
(
args
)...);
}
}
...
@@ -68,13 +68,13 @@ struct partially_apply_helper {
...
@@ -68,13 +68,13 @@ struct partially_apply_helper {
template
<
typename
Result
,
size_t
X
>
template
<
typename
Result
,
size_t
X
>
struct
partially_apply_helper
<
Result
,
X
,
X
>
{
struct
partially_apply_helper
<
Result
,
X
,
X
>
{
template
<
class
Fun
,
typename
...
Args
>
template
<
class
Fun
,
typename
...
Args
>
static
Result
_
(
const
Fun
&
fun
,
Args
&&
...
args
)
{
static
inline
Result
_
(
const
Fun
&
fun
,
Args
&&
...
args
)
{
return
fun
(
std
::
forward
<
Args
>
(
args
)...);
return
fun
(
std
::
forward
<
Args
>
(
args
)...);
}
}
};
};
template
<
typename
Result
,
size_t
Num
,
typename
F
,
typename
...
Args
>
template
<
typename
Result
,
size_t
Num
,
typename
F
,
typename
...
Args
>
Result
partially_apply
(
F
&
f
,
Args
&&
...
args
)
{
inline
Result
partially_apply
(
F
&
f
,
Args
&&
...
args
)
{
return
partially_apply_helper
<
Result
,
Num
,
sizeof
...(
Args
)
>
return
partially_apply_helper
<
Result
,
Num
,
sizeof
...(
Args
)
>
::
_
(
f
,
std
::
forward
<
Args
>
(
args
)...);
::
_
(
f
,
std
::
forward
<
Args
>
(
args
)...);
}
}
...
...
manual.pdf
View file @
d9c92d31
No preview for this file type
src/scheduler.cpp
View file @
d9c92d31
...
@@ -127,10 +127,12 @@ class scheduler_helper {
...
@@ -127,10 +127,12 @@ class scheduler_helper {
typedef
intrusive_ptr
<
thread_mapped_actor
>
ptr_type
;
typedef
intrusive_ptr
<
thread_mapped_actor
>
ptr_type
;
void
start
()
{
void
start
()
{
ptr_type
mtimer
{
new
thread_mapped_actor
};
ptr_type
mtimer
{
detail
::
memory
::
create
<
thread_mapped_actor
>
()};
ptr_type
mprinter
{
new
thread_mapped_actor
};
ptr_type
mprinter
{
detail
::
memory
::
create
<
thread_mapped_actor
>
()};
// launch threads
m_timer_thread
=
std
::
thread
(
&
scheduler_helper
::
timer_loop
,
mtimer
);
m_timer_thread
=
std
::
thread
(
&
scheduler_helper
::
timer_loop
,
mtimer
);
m_printer_thread
=
std
::
thread
(
&
scheduler_helper
::
printer_loop
,
mprinter
);
m_printer_thread
=
std
::
thread
(
&
scheduler_helper
::
printer_loop
,
mprinter
);
// set member variables
m_timer
=
mtimer
;
m_timer
=
mtimer
;
m_printer
=
mprinter
;
m_printer
=
mprinter
;
}
}
...
@@ -291,9 +293,10 @@ void scheduler_helper::printer_loop(ptr_type m_self) {
...
@@ -291,9 +293,10 @@ void scheduler_helper::printer_loop(ptr_type m_self) {
);
);
}
}
scheduler
::
scheduler
()
:
m_helper
(
n
ew
scheduler_helpe
r
)
{
}
scheduler
::
scheduler
()
:
m_helper
(
n
ullpt
r
)
{
}
void
scheduler
::
initialize
()
{
void
scheduler
::
initialize
()
{
m_helper
=
new
scheduler_helper
;
m_helper
->
start
();
m_helper
->
start
();
}
}
...
...
src/self.cpp
View file @
d9c92d31
...
@@ -44,7 +44,7 @@ pthread_key_t s_key;
...
@@ -44,7 +44,7 @@ pthread_key_t s_key;
pthread_once_t
s_key_once
=
PTHREAD_ONCE_INIT
;
pthread_once_t
s_key_once
=
PTHREAD_ONCE_INIT
;
local_actor
*
tss_constructor
()
{
local_actor
*
tss_constructor
()
{
local_actor
*
result
=
new
thread_mapped_actor
;
local_actor
*
result
=
detail
::
memory
::
create
<
thread_mapped_actor
>
()
;
result
->
ref
();
result
->
ref
();
get_scheduler
()
->
register_converted_context
(
result
);
get_scheduler
()
->
register_converted_context
(
result
);
return
result
;
return
result
;
...
...
src/thread_pool_scheduler.cpp
View file @
d9c92d31
...
@@ -205,7 +205,7 @@ actor_ptr thread_pool_scheduler::spawn_as_thread(void_function fun,
...
@@ -205,7 +205,7 @@ actor_ptr thread_pool_scheduler::spawn_as_thread(void_function fun,
init_callback
cb
,
init_callback
cb
,
bool
hidden
)
{
bool
hidden
)
{
if
(
!
hidden
)
inc_actor_count
();
if
(
!
hidden
)
inc_actor_count
();
thread_mapped_actor_ptr
ptr
{
new
thread_mapped_actor
(
std
::
move
(
fun
))};
thread_mapped_actor_ptr
ptr
{
detail
::
memory
::
create
<
thread_mapped_actor
>
(
std
::
move
(
fun
))};
ptr
->
init
();
ptr
->
init
();
ptr
->
initialized
(
true
);
ptr
->
initialized
(
true
);
cb
(
ptr
.
get
());
cb
(
ptr
.
get
());
...
@@ -257,7 +257,7 @@ actor_ptr thread_pool_scheduler::spawn(scheduled_actor* raw,
...
@@ -257,7 +257,7 @@ actor_ptr thread_pool_scheduler::spawn(scheduled_actor* raw,
actor_ptr
thread_pool_scheduler
::
spawn
(
void_function
fun
,
scheduling_hint
hint
)
{
actor_ptr
thread_pool_scheduler
::
spawn
(
void_function
fun
,
scheduling_hint
hint
)
{
if
(
hint
==
scheduled
||
hint
==
scheduled_and_hidden
)
{
if
(
hint
==
scheduled
||
hint
==
scheduled_and_hidden
)
{
scheduled_actor_ptr
ptr
{
new
context_switching_actor
(
std
::
move
(
fun
))};
scheduled_actor_ptr
ptr
{
detail
::
memory
::
create
<
context_switching_actor
>
(
std
::
move
(
fun
))};
ptr
->
attach_to_scheduler
(
this
,
hint
==
scheduled_and_hidden
);
ptr
->
attach_to_scheduler
(
this
,
hint
==
scheduled_and_hidden
);
return
spawn_impl
(
std
::
move
(
ptr
));
return
spawn_impl
(
std
::
move
(
ptr
));
}
}
...
@@ -267,11 +267,12 @@ actor_ptr thread_pool_scheduler::spawn(void_function fun, scheduling_hint hint)
...
@@ -267,11 +267,12 @@ actor_ptr thread_pool_scheduler::spawn(void_function fun, scheduling_hint hint)
hint
==
detached_and_hidden
);
hint
==
detached_and_hidden
);
}
}
}
}
actor_ptr
thread_pool_scheduler
::
spawn
(
void_function
fun
,
actor_ptr
thread_pool_scheduler
::
spawn
(
void_function
fun
,
init_callback
init_cb
,
init_callback
init_cb
,
scheduling_hint
hint
)
{
scheduling_hint
hint
)
{
if
(
hint
==
scheduled
||
hint
==
scheduled_and_hidden
)
{
if
(
hint
==
scheduled
||
hint
==
scheduled_and_hidden
)
{
scheduled_actor_ptr
ptr
{
new
context_switching_actor
(
std
::
move
(
fun
))};
scheduled_actor_ptr
ptr
{
detail
::
memory
::
create
<
context_switching_actor
>
(
std
::
move
(
fun
))};
ptr
->
attach_to_scheduler
(
this
,
hint
==
scheduled_and_hidden
);
ptr
->
attach_to_scheduler
(
this
,
hint
==
scheduled_and_hidden
);
init_cb
(
ptr
.
get
());
init_cb
(
ptr
.
get
());
return
spawn_impl
(
std
::
move
(
ptr
));
return
spawn_impl
(
std
::
move
(
ptr
));
...
...
unit_testing/test__spawn.cpp
View file @
d9c92d31
...
@@ -484,6 +484,7 @@ int main() {
...
@@ -484,6 +484,7 @@ int main() {
await_all_others_done
();
await_all_others_done
();
CPPA_IF_VERBOSE
(
cout
<<
"ok"
<<
endl
);
CPPA_IF_VERBOSE
(
cout
<<
"ok"
<<
endl
);
CPPA_IF_VERBOSE
(
cout
<<
"test sync send with factory spawned actor ... "
<<
flush
);
auto
sync_testee_factory
=
factory
::
event_based
(
auto
sync_testee_factory
=
factory
::
event_based
(
[
&
]()
{
[
&
]()
{
self
->
become
(
self
->
become
(
...
@@ -510,25 +511,39 @@ int main() {
...
@@ -510,25 +511,39 @@ int main() {
);
);
}
}
);
);
CPPA_CHECK
(
true
);
auto
sync_testee
=
sync_testee_factory
.
spawn
();
auto
sync_testee
=
sync_testee_factory
.
spawn
();
self
->
monitor
(
sync_testee
);
send
(
sync_testee
,
"hi"
);
send
(
sync_testee
,
"hi"
);
receive
(
receive
(
on
(
"whassup?"
)
>>
[]()
{
on
(
"whassup?"
)
>>
[
&
]
{
CPPA_CHECK
(
true
);
// this is NOT a reply, it's just an asynchronous message
// this is NOT a reply, it's just an asynchronous message
send
(
self
->
last_sender
(),
"a lot!"
);
send
(
self
->
last_sender
(),
"a lot!"
);
reply
(
"nothing"
);
reply
(
"nothing"
);
}
}
);
);
receive
(
receive
(
on
(
"goodbye!"
)
>>
[]()
{
}
on
(
"goodbye!"
)
>>
[
&
]
{
CPPA_CHECK
(
true
);
}
);
CPPA_CHECK
(
true
);
receive
(
on
(
atom
(
"DOWN"
),
exit_reason
::
normal
)
>>
[
&
]
{
CPPA_CHECK
(
self
->
last_sender
()
==
sync_testee
);
}
);
);
await_all_others_done
();
await_all_others_done
();
CPPA_IF_VERBOSE
(
cout
<<
"ok"
<<
endl
);
receive_response
(
sync_send
(
sync_testee
,
"!?"
))
(
receive_response
(
sync_send
(
sync_testee
,
"!?"
))
(
others
()
>>
[
&
]()
{
others
()
>>
[
&
]()
{
CPPA_ERROR
(
"'sync_testee' still alive?"
);
CPPA_ERROR
(
"'sync_testee' still alive?"
);
},
},
after
(
chrono
::
milliseconds
(
5
))
>>
[]()
{
}
after
(
chrono
::
milliseconds
(
5
))
>>
[
&
]
{
CPPA_CHECK
(
true
);
}
);
);
auto
inflater
=
factory
::
event_based
(
auto
inflater
=
factory
::
event_based
(
...
@@ -547,10 +562,12 @@ int main() {
...
@@ -547,10 +562,12 @@ int main() {
auto
bob
=
inflater
.
spawn
(
"Bob"
,
joe
);
auto
bob
=
inflater
.
spawn
(
"Bob"
,
joe
);
send
(
bob
,
1
,
"hello actor"
);
send
(
bob
,
1
,
"hello actor"
);
receive
(
receive
(
on
(
4
,
"hello actor"
)
>>
[]()
{
on
(
4
,
"hello actor"
)
>>
[
&
]
{
CPPA_CHECK
(
true
);
// done
// done
},
},
others
()
>>
[]
{
others
()
>>
[
&
]
{
CPPA_ERROR
(
"unexpected result"
);
cerr
<<
"unexpected: "
<<
to_string
(
self
->
last_dequeued
())
<<
endl
;
cerr
<<
"unexpected: "
<<
to_string
(
self
->
last_dequeued
())
<<
endl
;
}
}
);
);
...
...
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