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
9902b4eb
Commit
9902b4eb
authored
Nov 12, 2022
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Break loop on high-throughput actions
parent
c6fc49c0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
1 deletion
+12
-1
libcaf_core/caf/scheduled_actor.hpp
libcaf_core/caf/scheduled_actor.hpp
+4
-0
libcaf_core/src/scheduled_actor.cpp
libcaf_core/src/scheduled_actor.cpp
+8
-1
No files found.
libcaf_core/caf/scheduled_actor.hpp
View file @
9902b4eb
...
@@ -807,6 +807,10 @@ private:
...
@@ -807,6 +807,10 @@ private:
/// message.
/// message.
std
::
vector
<
action
>
actions_
;
std
::
vector
<
action
>
actions_
;
/// Flag that tells delay() to push actions to the mailbox if we are already
/// in run_actions.
bool
running_actions_
=
false
;
/// Stores resources that block the actor from terminating.
/// Stores resources that block the actor from terminating.
std
::
vector
<
disposable
>
watched_disposables_
;
std
::
vector
<
disposable
>
watched_disposables_
;
};
};
...
...
libcaf_core/src/scheduled_actor.cpp
View file @
9902b4eb
...
@@ -606,7 +606,12 @@ void scheduled_actor::schedule(action what) {
...
@@ -606,7 +606,12 @@ void scheduled_actor::schedule(action what) {
}
}
void
scheduled_actor
::
delay
(
action
what
)
{
void
scheduled_actor
::
delay
(
action
what
)
{
actions_
.
emplace_back
(
std
::
move
(
what
));
// If we are already in run_actions, we force the action through the mailbox
// in order to break hot loops that would otherwise starve any other activity.
if
(
!
running_actions_
)
actions_
.
emplace_back
(
std
::
move
(
what
));
else
schedule
(
std
::
move
(
what
));
}
}
disposable
scheduled_actor
::
delay_until
(
steady_time_point
abs_time
,
disposable
scheduled_actor
::
delay_until
(
steady_time_point
abs_time
,
...
@@ -1242,6 +1247,8 @@ void scheduled_actor::watch(disposable obj) {
...
@@ -1242,6 +1247,8 @@ void scheduled_actor::watch(disposable obj) {
}
}
void
scheduled_actor
::
run_actions
()
{
void
scheduled_actor
::
run_actions
()
{
running_actions_
=
true
;
auto
guard
=
detail
::
make_scope_guard
([
this
]
{
running_actions_
=
false
;
});
if
(
!
actions_
.
empty
())
{
if
(
!
actions_
.
empty
())
{
// Note: can't use iterators here since actions may add to the vector.
// Note: can't use iterators here since actions may add to the vector.
for
(
auto
index
=
size_t
{
0
};
index
<
actions_
.
size
();
++
index
)
{
for
(
auto
index
=
size_t
{
0
};
index
<
actions_
.
size
();
++
index
)
{
...
...
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