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
697f25e9
Commit
697f25e9
authored
Nov 06, 2014
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix timeout handling for event-based actors
parent
91e2761f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
0 deletions
+15
-0
libcaf_core/caf/mixin/single_timeout.hpp
libcaf_core/caf/mixin/single_timeout.hpp
+4
-0
libcaf_core/caf/policy/event_based_resume.hpp
libcaf_core/caf/policy/event_based_resume.hpp
+11
-0
No files found.
libcaf_core/caf/mixin/single_timeout.hpp
View file @
697f25e9
...
...
@@ -67,6 +67,10 @@ class single_timeout : public Base {
return
waits_for_timeout
(
tid
);
}
uint32_t
active_timeout_id
()
const
{
return
m_timeout_id
;
}
void
reset_timeout
()
{
this
->
has_timeout
(
false
);
}
...
...
libcaf_core/caf/policy/event_based_resume.hpp
View file @
697f25e9
...
...
@@ -112,11 +112,20 @@ class event_based_resume {
return
resume_result
::
done
;
}
}
auto
had_tout
=
d
->
has_timeout
();
auto
tout
=
d
->
active_timeout_id
();
int
handled_msgs
=
0
;
auto
reset_timeout_if_needed
=
[
&
]
{
if
(
had_tout
&&
handled_msgs
>
0
&&
tout
==
d
->
active_timeout_id
())
{
d
->
request_timeout
(
d
->
get_behavior
().
timeout
());
}
};
// max_throughput = 0 means infinite
for
(
size_t
i
=
0
;
i
<
max_throughput
;
++
i
)
{
auto
ptr
=
d
->
next_message
();
if
(
ptr
)
{
if
(
d
->
invoke_message
(
ptr
))
{
++
handled_msgs
;
if
(
actor_done
())
{
CAF_LOG_DEBUG
(
"actor exited"
);
return
resume_result
::
done
;
...
...
@@ -140,12 +149,14 @@ class event_based_resume {
}
else
{
CAF_LOG_DEBUG
(
"no more element in mailbox; going to block"
);
if
(
d
->
mailbox
().
try_block
())
{
reset_timeout_if_needed
();
return
resumable
::
awaiting_message
;
}
CAF_LOG_DEBUG
(
"try_block() interrupted by new message"
);
}
}
if
(
!
d
->
has_next_message
()
&&
d
->
mailbox
().
try_block
())
{
reset_timeout_if_needed
();
return
resumable
::
awaiting_message
;
}
// time's up
...
...
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