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
98cfdbfa
Commit
98cfdbfa
authored
Aug 30, 2021
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Run actions in scheduled actors
parent
909ad46a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
0 deletions
+36
-0
libcaf_core/src/scheduled_actor.cpp
libcaf_core/src/scheduled_actor.cpp
+8
-0
libcaf_core/test/detail/action.cpp
libcaf_core/test/detail/action.cpp
+28
-0
No files found.
libcaf_core/src/scheduled_actor.cpp
View file @
98cfdbfa
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
#include "caf/actor_system_config.hpp"
#include "caf/actor_system_config.hpp"
#include "caf/config.hpp"
#include "caf/config.hpp"
#include "caf/defaults.hpp"
#include "caf/defaults.hpp"
#include "caf/detail/action.hpp"
#include "caf/detail/default_invoke_result_visitor.hpp"
#include "caf/detail/default_invoke_result_visitor.hpp"
#include "caf/detail/meta_object.hpp"
#include "caf/detail/meta_object.hpp"
#include "caf/detail/private_thread.hpp"
#include "caf/detail/private_thread.hpp"
...
@@ -666,6 +667,13 @@ scheduled_actor::categorize(mailbox_element& x) {
...
@@ -666,6 +667,13 @@ scheduled_actor::categorize(mailbox_element& x) {
call_handler
(
down_handler_
,
this
,
dm
);
call_handler
(
down_handler_
,
this
,
dm
);
return
message_category
::
internal
;
return
message_category
::
internal
;
}
}
if
(
auto
view
=
make_typed_message_view
<
detail
::
action
>
(
content
))
{
if
(
auto
ptr
=
get
<
0
>
(
view
).
ptr
())
{
CAF_LOG_DEBUG
(
"run action"
);
ptr
->
run
();
}
return
message_category
::
internal
;
}
if
(
auto
view
=
make_typed_message_view
<
node_down_msg
>
(
content
))
{
if
(
auto
view
=
make_typed_message_view
<
node_down_msg
>
(
content
))
{
auto
&
dm
=
get
<
0
>
(
view
);
auto
&
dm
=
get
<
0
>
(
view
);
call_handler
(
node_down_handler_
,
this
,
dm
);
call_handler
(
node_down_handler_
,
this
,
dm
);
...
...
libcaf_core/test/detail/action.cpp
View file @
98cfdbfa
...
@@ -10,6 +10,14 @@
...
@@ -10,6 +10,14 @@
using
namespace
caf
;
using
namespace
caf
;
namespace
{
using
fixture
=
test_coordinator_fixture
<>
;
}
// namespace
BEGIN_FIXTURE_SCOPE
(
fixture
)
SCENARIO
(
"actions wrap function calls"
)
{
SCENARIO
(
"actions wrap function calls"
)
{
GIVEN
(
"an action wrapping a lambda"
)
{
GIVEN
(
"an action wrapping a lambda"
)
{
WHEN
(
"running the action"
)
{
WHEN
(
"running the action"
)
{
...
@@ -69,3 +77,23 @@ SCENARIO("actions wrap function calls") {
...
@@ -69,3 +77,23 @@ SCENARIO("actions wrap function calls") {
}
}
}
}
}
}
SCENARIO
(
"actors run actions that they receive"
)
{
GIVEN
(
"a scheduled actor"
)
{
WHEN
(
"sending it an action"
)
{
THEN
(
"the actor runs the action regardless of its behavior"
)
{
auto
aut
=
sys
.
spawn
([](
caf
::
event_based_actor
*
)
->
behavior
{
return
{
[](
int32_t
x
)
{
return
x
;
},
};
});
auto
n
=
0
;
inject
((
detail
::
action
),
to
(
aut
).
with
(
detail
::
make_action
([
&
n
]
{
++
n
;
})));
CHECK_EQ
(
n
,
1
);
}
}
}
}
END_FIXTURE_SCOPE
()
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