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
817ea66b
Commit
817ea66b
authored
Jul 27, 2016
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix anon_send in composable behaviors
parent
d8884198
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
13 deletions
+52
-13
libcaf_core/caf/local_actor.hpp
libcaf_core/caf/local_actor.hpp
+9
-8
libcaf_core/caf/mixin/sender.hpp
libcaf_core/caf/mixin/sender.hpp
+1
-1
libcaf_core/caf/typed_actor_pointer.hpp
libcaf_core/caf/typed_actor_pointer.hpp
+1
-1
libcaf_core/caf/typed_actor_view.hpp
libcaf_core/caf/typed_actor_view.hpp
+11
-3
libcaf_core/test/composable_behavior.cpp
libcaf_core/test/composable_behavior.cpp
+30
-0
No files found.
libcaf_core/caf/local_actor.hpp
View file @
817ea66b
...
...
@@ -117,15 +117,20 @@ public:
// -- spawn functions --------------------------------------------------------
template
<
class
T
,
spawn_options
Os
=
no_spawn_options
,
class
...
Ts
>
typename
infer_handle_from_class
<
T
>::
type
spawn
(
Ts
&&
...
xs
)
{
infer_handle_from_class_t
<
T
>
spawn
(
Ts
&&
...
xs
)
{
actor_config
cfg
{
context
()};
return
eval_opts
(
Os
,
system
().
spawn_class
<
T
,
make_unbound
(
Os
)
>
(
cfg
,
std
::
forward
<
Ts
>
(
xs
)...));
}
template
<
class
T
,
spawn_options
Os
=
no_spawn_options
>
infer_handle_from_state_t
<
T
>
spawn
()
{
using
impl
=
composable_behavior_based_actor
<
T
>
;
actor_config
cfg
{
context
()};
return
eval_opts
(
Os
,
system
().
spawn_class
<
impl
,
make_unbound
(
Os
)
>
(
cfg
));
}
template
<
spawn_options
Os
=
no_spawn_options
,
class
F
,
class
...
Ts
>
typename
infer_handle_from_fun
<
F
>::
type
spawn
(
F
fun
,
Ts
&&
...
xs
)
{
infer_handle_from_fun_t
<
F
>
spawn
(
F
fun
,
Ts
&&
...
xs
)
{
actor_config
cfg
{
context
()};
return
eval_opts
(
Os
,
system
().
spawn_functor
<
make_unbound
(
Os
)
>
(
cfg
,
fun
,
std
::
forward
<
Ts
>
(
xs
)...));
}
...
...
@@ -377,10 +382,6 @@ protected:
std
::
function
<
behavior
(
local_actor
*
)
>
initial_behavior_fac_
;
};
/// A smart pointer to a {@link local_actor} instance.
/// @relates local_actor
using
local_actor_ptr
=
intrusive_ptr
<
local_actor
>
;
}
// namespace caf
#endif // CAF_LOCAL_ACTOR_HPP
libcaf_core/caf/mixin/sender.hpp
View file @
817ea66b
...
...
@@ -143,7 +143,7 @@ public:
>::
value
,
"this actor does not accept the response message"
);
dptr
()
->
system
().
scheduler
().
delayed_send
(
rtime
,
this
->
ctrl
(),
actor_cast
<
strong_actor_ptr
>
(
dest
),
rtime
,
dptr
()
->
ctrl
(),
actor_cast
<
strong_actor_ptr
>
(
dest
),
message_id
::
make
(
P
),
make_message
(
std
::
forward
<
Ts
>
(
xs
)...));
}
...
...
libcaf_core/caf/typed_actor_pointer.hpp
View file @
817ea66b
...
...
@@ -52,7 +52,7 @@ public:
/// @private
actor_control_block
*
get
()
const
{
return
actor_control_block
::
from
(
view_
.
selfptr
()
);
return
view_
.
ctrl
(
);
}
private:
...
...
libcaf_core/caf/typed_actor_view.hpp
View file @
817ea66b
...
...
@@ -34,7 +34,10 @@ class typed_actor_view : public extend<typed_actor_view_base,
typed_actor_view
<
Sigs
...
>>::
template
with
<
mixin
::
sender
,
mixin
::
requester
>
{
public:
typed_actor_view
(
scheduled_actor
*
selfptr
)
:
self_
(
selfptr
)
{
/// Stores the template parameter pack.
using
signatures
=
detail
::
type_list
<
Sigs
...
>
;
typed_actor_view
(
scheduled_actor
*
ptr
)
:
self_
(
ptr
)
{
// nop
}
...
...
@@ -48,6 +51,11 @@ public:
return
self_
->
spawn
<
T
,
Os
>
(
std
::
forward
<
Ts
>
(
xs
)...);
}
template
<
class
T
,
spawn_options
Os
=
no_spawn_options
>
infer_handle_from_state_t
<
T
>
spawn
()
{
return
self_
->
spawn
<
T
,
Os
>
();
}
template
<
spawn_options
Os
=
no_spawn_options
,
class
F
,
class
...
Ts
>
typename
infer_handle_from_fun
<
F
>::
type
spawn
(
F
fun
,
Ts
&&
...
xs
)
{
...
...
@@ -96,8 +104,8 @@ public:
}
/// @private
scheduled_actor
*
selfptr
()
const
{
return
self_
;
actor_control_block
*
ctrl
()
const
{
return
actor_control_block
::
from
(
self_
);
;
}
private:
...
...
libcaf_core/test/composable_behavior.cpp
View file @
817ea66b
...
...
@@ -200,6 +200,30 @@ protected:
std
::
unordered_map
<
counting_string
,
counting_string
>
values_
;
};
using
delayed_testee_actor
=
typed_actor
<
reacts_to
<
int
>
,
replies_to
<
bool
>::
with
<
int
>
,
reacts_to
<
std
::
string
>>
;
class
delayed_testee
:
public
composable_behavior
<
delayed_testee_actor
>
{
public:
result
<
void
>
operator
()(
int
x
)
override
{
CAF_CHECK_EQUAL
(
x
,
42
);
self
->
delayed_anon_send
(
self
,
std
::
chrono
::
milliseconds
(
10
),
true
);
return
unit
;
}
result
<
int
>
operator
()(
bool
x
)
override
{
CAF_CHECK_EQUAL
(
x
,
true
);
self
->
delayed_send
(
self
,
std
::
chrono
::
milliseconds
(
10
),
"hello"
);
return
0
;
}
result
<
void
>
operator
()(
param
<
std
::
string
>
x
)
override
{
CAF_CHECK_EQUAL
(
x
.
get
(),
"hello"
);
return
unit
;
}
};
struct
fixture
{
fixture
()
:
system
(
cfg
)
{
// nop
...
...
@@ -320,4 +344,10 @@ CAF_TEST(param_detaching) {
CAF_CHECK_EQUAL
(
counting_strings_destroyed
.
load
(),
11
);
}
CAF_TEST
(
delayed_sends
)
{
scoped_actor
self
{
system
};
auto
testee
=
self
->
spawn
<
delayed_testee
>
();
self
->
send
(
testee
,
42
);
}
CAF_TEST_FIXTURE_SCOPE_END
()
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