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
e7154b0b
Commit
e7154b0b
authored
Feb 18, 2014
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'unstable' of github.com:Neverlord/libcppa into unstable
parents
d4a01972
8a702203
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
46 deletions
+64
-46
cppa/detail/proper_actor.hpp
cppa/detail/proper_actor.hpp
+5
-3
cppa/spawn.hpp
cppa/spawn.hpp
+33
-28
unit_testing/test_spawn.cpp
unit_testing/test_spawn.cpp
+9
-5
unit_testing/test_sync_send.cpp
unit_testing/test_sync_send.cpp
+17
-10
No files found.
cppa/detail/proper_actor.hpp
View file @
e7154b0b
...
...
@@ -272,11 +272,13 @@ class proper_actor<Base, Policies,true> : public proper_actor_base<Base,
has_timeout
=
true
;
timeout_id
=
this
->
request_timeout
(
bhvr
.
timeout
());
}
// workaround for GCC 4.7 bug (const this when capturing refs)
auto
&
pending_timeouts
=
m_pending_timeouts
;
auto
guard
=
util
::
make_scope_guard
([
&
]
{
if
(
has_timeout
)
{
auto
e
=
m_
pending_timeouts
.
end
();
auto
i
=
std
::
find
(
m_
pending_timeouts
.
begin
(),
e
,
timeout_id
);
if
(
i
!=
e
)
m_
pending_timeouts
.
erase
(
i
);
auto
e
=
pending_timeouts
.
end
();
auto
i
=
std
::
find
(
pending_timeouts
.
begin
(),
e
,
timeout_id
);
if
(
i
!=
e
)
pending_timeouts
.
erase
(
i
);
}
});
// read incoming messages
...
...
cppa/spawn.hpp
View file @
e7154b0b
...
...
@@ -231,30 +231,24 @@ class functor_based_typed_actor : public typed_event_based_actor<Rs...> {
typedef
std
::
function
<
behavior_type
(
pointer
)
>
one_arg_fun1
;
typedef
std
::
function
<
void
(
pointer
)
>
one_arg_fun2
;
functor_based_typed_actor
(
one_arg_fun1
fun
)
{
set
(
std
::
move
(
fun
));
}
functor_based_typed_actor
(
one_arg_fun2
fun
)
{
set
(
std
::
move
(
fun
));
}
functor_based_typed_actor
(
no_arg_fun
fun
)
{
set
(
std
::
move
(
fun
));
}
template
<
typename
F
,
typename
T
,
typename
...
Ts
>
functor_based_typed_actor
(
F
fun
,
T
&&
arg
,
Ts
&&
...
args
)
{
typedef
typename
util
::
get_callable_trait
<
F
>::
arg_types
arg_types
;
template
<
typename
F
,
typename
...
Ts
>
functor_based_typed_actor
(
F
fun
,
Ts
&&
...
args
)
{
typedef
typename
util
::
get_callable_trait
<
F
>::
type
trait
;
typedef
typename
trait
::
arg_types
arg_types
;
typedef
typename
trait
::
result_type
result_type
;
constexpr
bool
returns_behavior
=
std
::
is_same
<
result_type
,
behavior_type
>::
value
;
constexpr
bool
uses_first_arg
=
std
::
is_same
<
typename
util
::
tl_head
<
arg_types
>::
type
,
pointer
>::
value
;
std
::
integral_constant
<
bool
,
uses_first_arg
>
token
;
bind_and_set
(
token
,
std
::
move
(
fun
),
std
::
forward
<
T
>
(
arg
),
std
::
forward
<
Ts
>
(
args
)...);
std
::
integral_constant
<
bool
,
returns_behavior
>
token1
;
std
::
integral_constant
<
bool
,
uses_first_arg
>
token2
;
set
(
token1
,
token2
,
std
::
move
(
fun
),
std
::
forward
<
Ts
>
(
args
)...);
}
protected:
...
...
@@ -265,29 +259,40 @@ class functor_based_typed_actor : public typed_event_based_actor<Rs...> {
private:
void
set
(
one_arg_fun1
fun
)
{
m_fun
=
std
::
move
(
fun
);
template
<
typename
F
>
void
set
(
std
::
true_type
,
std
::
true_type
,
F
&&
fun
)
{
// behavior_type (pointer)
m_fun
=
std
::
forward
<
F
>
(
fun
);
}
void
set
(
one_arg_fun2
fun
)
{
template
<
typename
F
>
void
set
(
std
::
false_type
,
std
::
true_type
,
F
fun
)
{
// void (pointer)
m_fun
=
[
fun
](
pointer
ptr
)
{
fun
(
ptr
);
return
behavior_type
{};
};
}
void
set
(
no_arg_fun
fun
)
{
template
<
typename
F
>
void
set
(
std
::
true_type
,
std
::
false_type
,
F
fun
)
{
// behavior_type ()
m_fun
=
[
fun
](
pointer
)
{
return
fun
();
};
}
template
<
typename
F
,
typename
...
Ts
>
void
bind_and_set
(
std
::
true_type
,
F
fun
,
Ts
&&
...
args
)
{
set
(
std
::
bind
(
fun
,
std
::
placeholders
::
_1
,
std
::
forward
<
Ts
>
(
args
)...));
// (false_type, false_type) is an invalid functor for typed actors
template
<
class
Token
,
typename
F
,
typename
T0
,
typename
...
Ts
>
void
set
(
Token
t1
,
std
::
true_type
t2
,
F
fun
,
T0
&&
arg0
,
Ts
&&
...
args
)
{
set
(
t1
,
t2
,
std
::
bind
(
fun
,
std
::
placeholders
::
_1
,
std
::
forward
<
T0
>
(
arg0
),
std
::
forward
<
Ts
>
(
args
)...));
}
template
<
typename
F
,
typename
...
Ts
>
void
bind_and_set
(
std
::
false_type
,
F
fun
,
Ts
&&
...
args
)
{
set
(
std
::
bind
(
fun
,
std
::
forward
<
Ts
>
(
args
)...));
template
<
class
Token
,
typename
F
,
typename
T0
,
typename
...
Ts
>
void
set
(
Token
t1
,
std
::
false_type
t2
,
F
fun
,
T0
&&
arg0
,
Ts
&&
...
args
)
{
set
(
t1
,
t2
,
std
::
bind
(
fun
,
std
::
forward
<
T0
>
(
arg0
),
std
::
forward
<
Ts
>
(
args
)...));
}
one_arg_fun1
m_fun
;
...
...
unit_testing/test_spawn.cpp
View file @
e7154b0b
...
...
@@ -274,11 +274,15 @@ behavior echo_actor(event_based_actor* self) {
struct
simple_mirror
:
sb_actor
<
simple_mirror
>
{
behavior
init_state
=
(
others
()
>>
[
=
]
{
behavior
init_state
;
simple_mirror
()
{
init_state
=
(
others
()
>>
[
=
]()
->
any_tuple
{
return
last_dequeued
();
}
);
}
};
...
...
unit_testing/test_sync_send.cpp
View file @
e7154b0b
...
...
@@ -6,9 +6,13 @@ using namespace cppa;
using
namespace
cppa
::
placeholders
;
struct
sync_mirror
:
sb_actor
<
sync_mirror
>
{
behavior
init_state
=
(
behavior
init_state
;
sync_mirror
()
{
init_state
=
(
others
()
>>
[
=
]
{
return
last_dequeued
();
}
);
}
};
// replies to 'f' with 0.0f and to 'i' with 0
...
...
@@ -75,13 +79,16 @@ struct B : popular_actor {
};
struct
C
:
sb_actor
<
C
>
{
behavior
init_state
=
(
behavior
init_state
;
C
()
{
init_state
=
(
on
(
atom
(
"gogo"
))
>>
[
=
]()
->
atom_value
{
CPPA_CHECKPOINT
();
quit
();
return
atom
(
"gogogo"
);
}
);
}
};
...
...
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