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
03f033fb
Commit
03f033fb
authored
May 27, 2012
by
neverlord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
formatting and GCC 4.7 bugfixes
parent
9b4e5f3d
Changes
26
Hide whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
171 additions
and
70 deletions
+171
-70
benchmarks/mixed_case.cpp
benchmarks/mixed_case.cpp
+2
-2
benchmarks/utility.hpp
benchmarks/utility.hpp
+3
-3
cppa.files
cppa.files
+0
-1
cppa/behavior.hpp
cppa/behavior.hpp
+5
-7
cppa/cppa.hpp
cppa/cppa.hpp
+2
-2
cppa/detail/abstract_scheduled_actor.hpp
cppa/detail/abstract_scheduled_actor.hpp
+1
-1
cppa/detail/actor_proxy_cache.hpp
cppa/detail/actor_proxy_cache.hpp
+2
-2
cppa/detail/converted_thread_context.hpp
cppa/detail/converted_thread_context.hpp
+1
-1
cppa/detail/network_manager.hpp
cppa/detail/network_manager.hpp
+1
-1
cppa/detail/recursive_queue_node.hpp
cppa/detail/recursive_queue_node.hpp
+1
-1
cppa/detail/scheduled_actor_dummy.hpp
cppa/detail/scheduled_actor_dummy.hpp
+1
-1
cppa/detail/value_guard.hpp
cppa/detail/value_guard.hpp
+2
-2
cppa/partial_function.hpp
cppa/partial_function.hpp
+9
-9
src/actor_proxy.cpp
src/actor_proxy.cpp
+2
-2
src/actor_proxy_cache.cpp
src/actor_proxy_cache.cpp
+5
-5
src/actor_registry.cpp
src/actor_registry.cpp
+1
-1
src/converted_thread_context.cpp
src/converted_thread_context.cpp
+1
-1
src/network_manager.cpp
src/network_manager.cpp
+1
-1
src/partial_function.cpp
src/partial_function.cpp
+0
-3
src/post_office.cpp
src/post_office.cpp
+5
-5
src/scheduled_actor_dummy.cpp
src/scheduled_actor_dummy.cpp
+1
-1
src/thread_pool_scheduler.cpp
src/thread_pool_scheduler.cpp
+3
-3
unit_testing/main.cpp
unit_testing/main.cpp
+1
-1
unit_testing/test__match.cpp
unit_testing/test__match.cpp
+80
-0
unit_testing/test__spawn.cpp
unit_testing/test__spawn.cpp
+38
-11
unit_testing/test__yield_interface.cpp
unit_testing/test__yield_interface.cpp
+3
-3
No files found.
benchmarks/mixed_case.cpp
View file @
03f033fb
...
...
@@ -250,7 +250,7 @@ void usage() {
enum
mode_type
{
event_based
,
fiber_based
};
option
<
int
>
_2i
(
std
::
string
const
&
str
)
{
option
<
int
>
_2i
(
const
std
::
string
&
str
)
{
char
*
endptr
=
nullptr
;
int
result
=
static_cast
<
int
>
(
strtol
(
str
.
c_str
(),
&
endptr
,
10
));
if
(
endptr
==
nullptr
||
*
endptr
!=
'\0'
)
{
...
...
@@ -265,7 +265,7 @@ int main(int argc, char** argv) {
// skip argv[0] (app name)
std
::
vector
<
std
::
string
>
args
{
argv
+
1
,
argv
+
argc
};
match
(
args
)
(
on
(
val
<
std
::
string
>
,
_2i
,
_2i
,
_2i
,
_2i
)
>>
[](
std
::
string
const
&
mode
,
on
(
val
<
std
::
string
>
,
_2i
,
_2i
,
_2i
,
_2i
)
>>
[](
const
std
::
string
&
mode
,
int
num_rings
,
int
ring_size
,
int
initial_token_value
,
...
...
benchmarks/utility.hpp
View file @
03f033fb
...
...
@@ -37,7 +37,7 @@
#include <stdexcept>
#include <algorithm>
inline
std
::
vector
<
std
::
string
>
split
(
std
::
string
const
&
str
,
char
delim
)
{
inline
std
::
vector
<
std
::
string
>
split
(
const
std
::
string
&
str
,
char
delim
)
{
std
::
vector
<
std
::
string
>
result
;
std
::
stringstream
strs
{
str
};
std
::
string
tmp
;
...
...
@@ -45,8 +45,8 @@ inline std::vector<std::string> split(std::string const& str, char delim) {
return
result
;
}
inline
std
::
string
join
(
std
::
vector
<
std
::
string
>
const
&
vec
,
std
::
string
const
&
delim
=
""
)
{
inline
std
::
string
join
(
const
std
::
vector
<
std
::
string
>
&
vec
,
const
std
::
string
&
delim
=
""
)
{
if
(
vec
.
empty
())
return
""
;
auto
result
=
vec
.
front
();
for
(
auto
i
=
vec
.
begin
()
+
1
;
i
!=
vec
.
end
();
++
i
)
{
...
...
cppa.files
View file @
03f033fb
benchmarks/ActorCreation.scala
benchmarks/Distributed.scala
benchmarks/DistributedRemoteActors.scala
benchmarks/MailboxPerformance.scala
benchmarks/Matching.scala
benchmarks/MixedCase.scala
...
...
cppa/behavior.hpp
View file @
03f033fb
...
...
@@ -53,16 +53,16 @@ class behavior {
friend
behavior
operator
,(
partial_function
&&
lhs
,
behavior
&&
rhs
);
behavior
(
const
behavior
&
)
=
delete
;
behavior
&
operator
=
(
const
behavior
&
)
=
delete
;
public:
behavior
()
=
default
;
behavior
(
behavior
&&
)
=
default
;
behavior
(
const
behavior
&
)
=
default
;
behavior
&
operator
=
(
behavior
&&
)
=
default
;
behavior
&
operator
=
(
const
behavior
&
)
=
default
;
inline
behavior
(
partial_function
&&
fun
)
:
m_fun
(
std
::
move
(
fun
))
{
}
inline
behavior
(
partial_function
&&
fun
)
:
m_fun
(
std
::
move
(
fun
))
{
}
template
<
typename
...
Cases
>
behavior
(
const
match_expr
<
Cases
...
>&
me
)
:
m_fun
(
me
)
{
}
...
...
@@ -71,8 +71,6 @@ class behavior {
:
m_timeout
(
tout
),
m_timeout_handler
(
std
::
move
(
handler
))
{
}
behavior
&
operator
=
(
behavior
&&
)
=
default
;
inline
void
handle_timeout
()
const
{
m_timeout_handler
();
}
...
...
@@ -89,7 +87,7 @@ class behavior {
return
m_fun
(
value
);
}
inline
bool
operator
()(
any_tuple
const
&
value
)
{
inline
bool
operator
()(
const
any_tuple
&
value
)
{
return
m_fun
(
value
);
}
...
...
cppa/cppa.hpp
View file @
03f033fb
...
...
@@ -501,12 +501,12 @@ template<typename T>
struct
spawn_fwd_
{
static
inline
T
&&
_
(
T
&&
arg
)
{
return
std
::
move
(
arg
);
}
static
inline
T
&
_
(
T
&
arg
)
{
return
arg
;
}
static
inline
T
const
&
_
(
T
const
&
arg
)
{
return
arg
;
}
static
inline
const
T
&
_
(
const
T
&
arg
)
{
return
arg
;
}
};
template
<
>
struct
spawn_fwd_
<
self_type
>
{
static
inline
actor_ptr
_
(
self_type
const
&
)
{
return
self
;
}
static
inline
actor_ptr
_
(
const
self_type
&
)
{
return
self
;
}
};
template
<
typename
F
,
typename
Arg0
,
typename
...
Args
>
...
...
cppa/detail/abstract_scheduled_actor.hpp
View file @
03f033fb
...
...
@@ -58,7 +58,7 @@ class abstract_scheduled_actor : public abstract_actor<scheduled_actor> {
std
::
atomic
<
int
>
m_state
;
filter_result
filter_msg
(
any_tuple
const
&
msg
)
{
filter_result
filter_msg
(
const
any_tuple
&
msg
)
{
auto
&
arr
=
detail
::
static_types_array
<
atom_value
,
std
::
uint32_t
>::
arr
;
if
(
msg
.
size
()
==
2
&&
msg
.
type_at
(
0
)
==
arr
[
0
]
...
...
cppa/detail/actor_proxy_cache.hpp
View file @
03f033fb
...
...
@@ -56,7 +56,7 @@ class actor_proxy_cache {
bool
erase
(
const
actor_proxy_ptr
&
pptr
);
template
<
typename
Fun
>
void
erase_all
(
process_information
::
node_id_type
const
&
nid
,
void
erase_all
(
const
process_information
::
node_id_type
&
nid
,
std
::
uint32_t
process_id
,
Fun
fun
)
{
key_tuple
lb
{
nid
,
process_id
,
std
::
numeric_limits
<
actor_id
>::
min
()};
...
...
@@ -82,7 +82,7 @@ class actor_proxy_cache {
key_tuple
;
struct
key_tuple_less
{
bool
operator
()(
key_tuple
const
&
lhs
,
key_tuple
const
&
rhs
)
const
;
bool
operator
()(
const
key_tuple
&
lhs
,
const
key_tuple
&
rhs
)
const
;
};
util
::
shared_spinlock
m_lock
;
...
...
cppa/detail/converted_thread_context.hpp
View file @
03f033fb
...
...
@@ -83,7 +83,7 @@ class converted_thread_context
inline
void
pop_timeout
()
{
}
filter_result
filter_msg
(
any_tuple
const
&
msg
);
filter_result
filter_msg
(
const
any_tuple
&
msg
);
inline
decltype
(
m_mailbox
)
&
mailbox
()
{
return
m_mailbox
;
}
...
...
cppa/detail/network_manager.hpp
View file @
03f033fb
...
...
@@ -45,7 +45,7 @@ class network_manager {
virtual
void
stop
()
=
0
;
virtual
void
send_to_post_office
(
po_message
const
&
msg
)
=
0
;
virtual
void
send_to_post_office
(
const
po_message
&
msg
)
=
0
;
virtual
void
send_to_post_office
(
any_tuple
msg
)
=
0
;
...
...
cppa/detail/recursive_queue_node.hpp
View file @
03f033fb
...
...
@@ -55,7 +55,7 @@ struct recursive_queue_node {
recursive_queue_node
(
recursive_queue_node
&&
)
=
delete
;
recursive_queue_node
(
recursive_queue_node
const
&
)
=
delete
;
recursive_queue_node
&
operator
=
(
recursive_queue_node
&&
)
=
delete
;
recursive_queue_node
&
operator
=
(
recursive_queue_node
const
&
)
=
delete
;
recursive_queue_node
&
operator
=
(
const
recursive_queue_node
&
)
=
delete
;
};
...
...
cppa/detail/scheduled_actor_dummy.hpp
View file @
03f033fb
...
...
@@ -44,7 +44,7 @@ struct scheduled_actor_dummy : abstract_scheduled_actor {
void
unlink_from
(
intrusive_ptr
<
actor
>&
);
bool
establish_backlink
(
intrusive_ptr
<
actor
>&
);
bool
remove_backlink
(
intrusive_ptr
<
actor
>&
);
void
detach
(
attachable
::
token
const
&
);
void
detach
(
const
attachable
::
token
&
);
bool
attach
(
attachable
*
);
};
...
...
cppa/detail/value_guard.hpp
View file @
03f033fb
...
...
@@ -76,12 +76,12 @@ class value_guard {
}
template
<
typename
T0
,
typename
T1
>
static
inline
bool
cmp
(
T0
const
&
lhs
,
T1
const
&
rhs
)
{
static
inline
bool
cmp
(
const
T0
&
lhs
,
const
T1
&
rhs
)
{
return
lhs
==
rhs
;
}
template
<
typename
T0
,
typename
T1
>
static
inline
bool
cmp
(
T0
const
&
lhs
,
std
::
reference_wrapper
<
T1
>
const
&
rhs
)
{
static
inline
bool
cmp
(
const
T0
&
lhs
,
const
std
::
reference_wrapper
<
T1
>
&
rhs
)
{
return
lhs
==
rhs
.
get
();
}
...
...
cppa/partial_function.hpp
View file @
03f033fb
...
...
@@ -36,6 +36,8 @@
#include <memory>
#include <utility>
#include "cppa/ref_counted.hpp"
#include "cppa/intrusive_ptr.hpp"
#include "cppa/detail/invokable.hpp"
#include "cppa/intrusive/singly_linked_list.hpp"
...
...
@@ -49,36 +51,34 @@ class behavior;
*/
class
partial_function
{
partial_function
(
const
partial_function
&
)
=
delete
;
partial_function
&
operator
=
(
const
partial_function
&
)
=
delete
;
public:
struct
impl
{
virtual
~
impl
();
struct
impl
:
ref_counted
{
virtual
bool
invoke
(
any_tuple
&
)
=
0
;
virtual
bool
invoke
(
const
any_tuple
&
)
=
0
;
virtual
bool
defined_at
(
const
any_tuple
&
)
=
0
;
};
typedef
std
::
uniqu
e_ptr
<
impl
>
impl_ptr
;
typedef
intrusiv
e_ptr
<
impl
>
impl_ptr
;
partial_function
()
=
default
;
partial_function
(
partial_function
&&
)
=
default
;
partial_function
(
const
partial_function
&
)
=
default
;
partial_function
&
operator
=
(
partial_function
&&
)
=
default
;
partial_function
&
operator
=
(
const
partial_function
&
)
=
default
;
partial_function
(
impl_ptr
&&
ptr
);
inline
bool
defined_at
(
const
any_tuple
&
value
)
{
return
(
(
m_impl
)
&&
m_impl
->
defined_at
(
value
)
);
return
(
m_impl
)
&&
m_impl
->
defined_at
(
value
);
}
inline
bool
operator
()(
any_tuple
&
value
)
{
return
(
(
m_impl
)
&&
m_impl
->
invoke
(
value
)
);
return
(
m_impl
)
&&
m_impl
->
invoke
(
value
);
}
inline
bool
operator
()(
const
any_tuple
&
value
)
{
return
(
(
m_impl
)
&&
m_impl
->
invoke
(
value
)
);
return
(
m_impl
)
&&
m_impl
->
invoke
(
value
);
}
inline
bool
operator
()(
any_tuple
&&
value
)
{
...
...
src/actor_proxy.cpp
View file @
03f033fb
...
...
@@ -39,12 +39,12 @@
namespace
cppa
{
actor_proxy
::
actor_proxy
(
std
::
uint32_t
mid
,
process_information_ptr
const
&
pptr
)
actor_proxy
::
actor_proxy
(
std
::
uint32_t
mid
,
const
process_information_ptr
&
pptr
)
:
super
(
mid
,
pptr
)
{
//attach(get_scheduler()->register_hidden_context());
}
void
actor_proxy
::
forward_message
(
process_information_ptr
const
&
piptr
,
void
actor_proxy
::
forward_message
(
const
process_information_ptr
&
piptr
,
actor
*
sender
,
any_tuple
&&
msg
)
{
detail
::
addressed_message
amsg
{
sender
,
this
,
std
::
move
(
msg
)};
...
...
src/actor_proxy_cache.cpp
View file @
03f033fb
...
...
@@ -66,12 +66,12 @@ actor_proxy_cache& get_actor_proxy_cache() {
actor_proxy_ptr
actor_proxy_cache
::
get
(
actor_id
aid
,
std
::
uint32_t
process_id
,
process_information
::
node_id_type
const
&
node_id
)
{
const
process_information
::
node_id_type
&
node_id
)
{
key_tuple
k
{
node_id
,
process_id
,
aid
};
return
get_impl
(
k
);
}
actor_proxy_ptr
actor_proxy_cache
::
get_impl
(
key_tuple
const
&
key
)
{
actor_proxy_ptr
actor_proxy_cache
::
get_impl
(
const
key_tuple
&
key
)
{
{
// lifetime scope of shared guard
util
::
shared_lock_guard
<
util
::
shared_spinlock
>
guard
{
m_lock
};
auto
i
=
m_entries
.
find
(
key
);
...
...
@@ -95,7 +95,7 @@ actor_proxy_ptr actor_proxy_cache::get_impl(key_tuple const& key) {
return
result
;
}
bool
actor_proxy_cache
::
erase
(
actor_proxy_ptr
const
&
pptr
)
{
bool
actor_proxy_cache
::
erase
(
const
actor_proxy_ptr
&
pptr
)
{
auto
pinfo
=
pptr
->
parent_process_ptr
();
key_tuple
key
(
pinfo
->
node_id
(),
pinfo
->
process_id
(),
pptr
->
id
());
{
lock_guard
<
util
::
shared_spinlock
>
guard
{
m_lock
};
...
...
@@ -104,8 +104,8 @@ bool actor_proxy_cache::erase(actor_proxy_ptr const& pptr) {
return
false
;
}
bool
actor_proxy_cache
::
key_tuple_less
::
operator
()(
key_tuple
const
&
lhs
,
key_tuple
const
&
rhs
)
const
{
bool
actor_proxy_cache
::
key_tuple_less
::
operator
()(
const
key_tuple
&
lhs
,
const
key_tuple
&
rhs
)
const
{
int
cmp_res
=
strncmp
(
reinterpret_cast
<
char
const
*>
(
std
::
get
<
0
>
(
lhs
).
data
()),
reinterpret_cast
<
char
const
*>
(
std
::
get
<
0
>
(
rhs
).
data
()),
process_information
::
node_id_size
);
...
...
src/actor_registry.cpp
View file @
03f033fb
...
...
@@ -90,7 +90,7 @@ void actor_registry::put(actor_id key, const actor_ptr& value) {
void
actor_registry
::
erase
(
actor_id
key
)
{
exclusive_guard
guard
(
m_instances_mtx
);
auto
i
=
std
::
find_if
(
m_instances
.
begin
(),
m_instances
.
end
(),
[
=
](
std
::
pair
<
actor_id
,
actor_ptr
>
const
&
p
)
{
[
=
](
const
std
::
pair
<
actor_id
,
actor_ptr
>
&
p
)
{
return
p
.
first
==
key
;
});
if
(
i
!=
m_instances
.
end
())
...
...
src/converted_thread_context.cpp
View file @
03f033fb
...
...
@@ -99,7 +99,7 @@ void converted_thread_context::dequeue(behavior& bhvr) { // override
}
}
filter_result
converted_thread_context
::
filter_msg
(
any_tuple
const
&
msg
)
{
filter_result
converted_thread_context
::
filter_msg
(
const
any_tuple
&
msg
)
{
if
(
m_trap_exit
==
false
&&
matches
(
msg
,
m_exit_msg_pattern
))
{
auto
reason
=
msg
.
get_as
<
std
::
uint32_t
>
(
1
);
if
(
reason
!=
exit_reason
::
normal
)
{
...
...
src/network_manager.cpp
View file @
03f033fb
...
...
@@ -82,7 +82,7 @@ struct network_manager_impl : network_manager {
close
(
pipe_fd
[
0
]);
}
void
send_to_post_office
(
po_message
const
&
msg
)
{
void
send_to_post_office
(
const
po_message
&
msg
)
{
if
(
write
(
pipe_fd
[
1
],
&
msg
,
sizeof
(
po_message
))
!=
sizeof
(
po_message
))
{
CPPA_CRITICAL
(
"cannot write to pipe"
);
}
...
...
src/partial_function.cpp
View file @
03f033fb
...
...
@@ -40,7 +40,4 @@ namespace cppa {
partial_function
::
partial_function
(
impl_ptr
&&
ptr
)
:
m_impl
(
std
::
move
(
ptr
))
{
}
partial_function
::
impl
::~
impl
()
{
}
}
// namespace cppa
src/post_office.cpp
View file @
03f033fb
...
...
@@ -109,7 +109,7 @@ inline void send2po_(network_manager* nm, Arg0&& arg0, Args&&... args) {
template
<
typename
...
Args
>
inline
void
send2po
(
po_message
const
&
msg
,
Args
&&
...
args
)
{
inline
void
send2po
(
const
po_message
&
msg
,
Args
&&
...
args
)
{
auto
nm
=
singleton_manager
::
get_network_manager
();
nm
->
send_to_post_office
(
msg
);
send2po_
(
nm
,
std
::
forward
<
Args
>
(
args
)...);
...
...
@@ -440,7 +440,7 @@ void post_office_loop(int input_fd) {
case
valof
(
atom
(
"RM_PEER"
)):
{
DEBUG
(
"post_office: rm_peer"
);
auto
i
=
std
::
find_if
(
handler
.
begin
(),
handler
.
end
(),
[
&
](
po_socket_handler_ptr
const
&
hp
)
{
[
&
](
const
po_socket_handler_ptr
&
hp
)
{
return
hp
->
get_socket
()
==
msg
.
fd
;
});
if
(
i
!=
handler
.
end
())
handler
.
erase
(
i
);
...
...
@@ -461,7 +461,7 @@ void post_office_loop(int input_fd) {
case
valof
(
atom
(
"UNPUBLISH"
)):
{
DEBUG
(
"post_office: unpublish_actor"
);
auto
i
=
std
::
find_if
(
handler
.
begin
(),
handler
.
end
(),
[
&
](
po_socket_handler_ptr
const
&
hp
)
{
[
&
](
const
po_socket_handler_ptr
&
hp
)
{
return
hp
->
is_doorman_of
(
msg
.
aid
);
});
if
(
i
!=
handler
.
end
())
handler
.
erase
(
i
);
...
...
@@ -491,13 +491,13 @@ void post_office_loop(int input_fd) {
******************************************************************************/
void
post_office_add_peer
(
native_socket_type
a0
,
process_information_ptr
const
&
a1
)
{
const
process_information_ptr
&
a1
)
{
po_message
msg
{
atom
(
"ADD_PEER"
),
-
1
,
0
};
send2po
(
msg
,
a0
,
a1
);
}
void
post_office_publish
(
native_socket_type
server_socket
,
actor_ptr
const
&
published_actor
)
{
const
actor_ptr
&
published_actor
)
{
po_message
msg
{
atom
(
"PUBLISH"
),
-
1
,
0
};
send2po
(
msg
,
server_socket
,
published_actor
);
}
...
...
src/scheduled_actor_dummy.cpp
View file @
03f033fb
...
...
@@ -58,7 +58,7 @@ bool scheduled_actor_dummy::remove_backlink(intrusive_ptr<actor>&) {
return
false
;
}
void
scheduled_actor_dummy
::
detach
(
attachable
::
token
const
&
)
{
void
scheduled_actor_dummy
::
detach
(
const
attachable
::
token
&
)
{
}
bool
scheduled_actor_dummy
::
attach
(
attachable
*
)
{
...
...
src/thread_pool_scheduler.cpp
View file @
03f033fb
...
...
@@ -235,9 +235,9 @@ actor_ptr thread_pool_scheduler::spawn(std::function<void()> what,
}
}
#else
actor_ptr
thread_pool_scheduler
::
spawn
(
std
::
function
<
void
()
>
what
,
scheduling_hint
hint
)
{
return
mock_scheduler
::
spawn
(
what
,
hint
);
actor_ptr
thread_pool_scheduler
::
spawn
(
std
::
function
<
void
()
>
what
scheduling_hint
)
{
return
mock_scheduler
::
spawn
_impl
(
std
::
move
(
what
)
);
}
#endif
...
...
unit_testing/main.cpp
View file @
03f033fb
...
...
@@ -153,7 +153,7 @@ int main(int argc, char** argv) {
await_all_others_done
();
exit
(
0
);
},
on
(
"run_ping"
,
arg_match
)
>>
[
&
](
std
::
string
const
&
num_pings
)
{
on
(
"run_ping"
,
arg_match
)
>>
[
&
](
const
std
::
string
&
num_pings
)
{
auto
ping_actor
=
spawn
<
detached
>
(
ping
,
std
::
stoi
(
num_pings
));
//auto ping_actor = spawn_event_based_ping(std::stoi(num_pings));
std
::
uint16_t
port
=
4242
;
...
...
unit_testing/test__match.cpp
View file @
03f033fb
...
...
@@ -27,12 +27,91 @@ bool ascending(int a, int b, int c) {
return
a
<
b
&&
b
<
c
;
}
vector
<
uniform_type_info
const
*>
to_vec
(
util
::
type_list
<>
,
vector
<
uniform_type_info
const
*>
vec
=
vector
<
uniform_type_info
const
*>
{})
{
return
vec
;
}
template
<
typename
Head
,
typename
...
Tail
>
vector
<
uniform_type_info
const
*>
to_vec
(
util
::
type_list
<
Head
,
Tail
...
>
,
vector
<
uniform_type_info
const
*>
vec
=
vector
<
uniform_type_info
const
*>
{})
{
vec
.
push_back
(
uniform_typeid
<
Head
>
());
return
to_vec
(
util
::
type_list
<
Tail
...
>
{},
std
::
move
(
vec
));
}
template
<
typename
Fun
>
class
__
{
typedef
typename
util
::
get_callable_trait
<
Fun
>::
type
trait
;
public:
__
(
Fun
f
,
string
annotation
=
""
)
:
m_fun
(
f
),
m_annotation
(
annotation
)
{
}
__
operator
[](
const
string
&
str
)
const
{
return
{
m_fun
,
str
};
}
template
<
typename
...
Args
>
void
operator
()(
Args
&&
...
args
)
const
{
m_fun
(
std
::
forward
<
Args
>
(
args
)...);
}
void
plot_signature
()
{
auto
vec
=
to_vec
(
typename
trait
::
arg_types
{});
for
(
auto
i
:
vec
)
{
cout
<<
i
->
name
()
<<
" "
;
}
cout
<<
endl
;
}
const
string
&
annotation
()
const
{
return
m_annotation
;
}
private:
Fun
m_fun
;
string
m_annotation
;
};
template
<
typename
Fun
>
__
<
Fun
>
get__
(
Fun
f
)
{
return
{
f
};
}
struct
fobaz
:
fsm_actor
<
fobaz
>
{
behavior
init_state
;
void
vfun
()
{
cout
<<
"fobaz::mfun"
<<
endl
;
}
void
ifun
(
int
i
)
{
cout
<<
"fobaz::ifun("
<<
i
<<
")"
<<
endl
;
}
fobaz
()
{
init_state
=
(
on
<
int
>
()
>>
[
=
](
int
i
)
{
ifun
(
i
);
},
others
()
>>
std
::
function
<
void
()
>
{
std
::
bind
(
&
fobaz
::
vfun
,
this
)}
);
}
};
size_t
test__match
()
{
CPPA_TEST
(
test__match
);
using
namespace
std
::
placeholders
;
using
namespace
cppa
::
placeholders
;
/*
auto x_ = get__([](int, float) { cout << "yeeeehaaaa!" << endl; })["prints 'yeeeehaaaa'"];
cout << "x_: "; x_(1, 1.f);
cout << "x_.annotation() = " << x_.annotation() << endl;
cout << "x_.plot_signature: "; x_.plot_signature();
auto fun = (
on<int>() >> [](int i) {
cout << "i = " << i << endl;
...
...
@@ -41,6 +120,7 @@ size_t test__match() {
cout << "no int found in mailbox" << endl;
}
);
*/
auto
expr0_a
=
gcall
(
ascending
,
_x1
,
_x2
,
_x3
);
CPPA_CHECK
(
ge_invoke
(
expr0_a
,
1
,
2
,
3
));
...
...
unit_testing/test__spawn.cpp
View file @
03f033fb
...
...
@@ -282,22 +282,16 @@ class actor_template {
actor_ptr
spawn
()
const
{
struct
impl
:
fsm_actor
<
impl
>
{
behavior
init_state
;
impl
(
MatchExpr
const
&
mx
)
:
init_state
(
mx
.
as_partial_function
())
{
impl
(
const
MatchExpr
&
mx
)
:
init_state
(
mx
.
as_partial_function
())
{
}
};
return
cppa
::
spawn
(
new
impl
{
m_expr
});
}
actor_ptr
spawn_detached
()
const
{
return
cppa
::
spawn
<
detached
>
([
m_expr
]()
{
receive_loop
(
m_expr
);
});
}
};
template
<
typename
...
Args
>
auto
actor_prototype
(
Args
const
&
...
args
)
->
actor_template
<
decltype
(
mexpr_concat
(
args
...))
>
{
auto
actor_prototype
(
const
Args
&
...
args
)
->
actor_template
<
decltype
(
mexpr_concat
(
args
...))
>
{
return
{
mexpr_concat
(
args
...)};
}
...
...
@@ -321,6 +315,29 @@ class str_wrapper {
};
struct
some_integer
{
void
set
(
int
value
)
{
m_value
=
value
;
}
int
get
()
const
{
return
m_value
;
}
private:
int
m_value
;
};
template
<
class
T
,
class
MatchExpr
=
match_expr
<
>,
class
Parent
=
void
>
class
actor_facade_builder
{
public:
private:
MatchExpr
m_expr
;
};
bool
operator
==
(
const
str_wrapper
&
lhs
,
const
std
::
string
&
rhs
)
{
return
lhs
.
str
()
==
rhs
;
}
...
...
@@ -336,10 +353,20 @@ void foobar(const str_wrapper& x, const std::string& y) {
);
}
size_t
test__spawn
()
{
using
std
::
string
;
CPPA_TEST
(
test__spawn
);
/*
actor_ptr tst = actor_facade<some_integer>()
.reply_to().when().with()
.reply_to().when().with()
.spawn();
send(tst, atom("EXIT"), exit_reason::user_defined);
*/
CPPA_IF_VERBOSE
(
cout
<<
"test send() ... "
<<
std
::
flush
);
send
(
self
,
1
,
2
,
3
);
receive
(
on
(
1
,
2
,
3
)
>>
[]()
{
});
...
...
@@ -420,9 +447,9 @@ size_t test__spawn() {
{
bool
invoked
=
false
;
str_wrapper
x
{
"x"
};
std
::
string
y
{
"y"
};
auto
foo_actor
=
spawn
(
foobar
,
std
::
cref
(
x
),
y
);
str_wrapper
actor_facade_builder
{
"x"
};
std
::
string
actor_facade_builder_interim
{
"y"
};
auto
foo_actor
=
spawn
(
foobar
,
std
::
cref
(
actor_facade_builder
),
actor_facade_builder_interim
);
send
(
foo_actor
,
atom
(
"same"
));
receive
(
on
(
atom
(
"yes"
))
>>
[
&
]()
{
...
...
unit_testing/test__yield_interface.cpp
View file @
03f033fb
...
...
@@ -73,9 +73,9 @@ size_t test__yield_interface() {
++
i
;
}
while
(
ys
!=
yield_state
::
done
&&
i
<
12
);
CPPA_CHECK_EQUAL
(
y
s
,
yield_state
::
done
);
CPPA_CHECK_EQUAL
(
worker
.
m_count
,
10
);
CPPA_CHECK_EQUAL
(
i
,
12
);
CPPA_CHECK_EQUAL
(
y
ield_state
::
done
,
ys
);
CPPA_CHECK_EQUAL
(
10
,
worker
.
m_count
);
CPPA_CHECK_EQUAL
(
12
,
i
);
# endif
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