Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
327555fc
Commit
327555fc
authored
Sep 11, 2018
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a way to set a maximum number of event loop turns before we poll for input.
parent
46ed8793
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
0 deletions
+11
-0
async.c++
c++/src/kj/async.c++
+6
-0
async.h
c++/src/kj/async.h
+5
-0
No files found.
c++/src/kj/async.c++
View file @
327555fc
...
...
@@ -436,10 +436,16 @@ void waitImpl(Own<_::PromiseNode>&& node, _::ExceptionOrValue& result, WaitScope
loop
.
running
=
true
;
KJ_DEFER
(
loop
.
running
=
false
);
uint
counter
=
0
;
while
(
!
doneEvent
.
fired
)
{
if
(
!
loop
.
turn
())
{
// No events in the queue. Wait for callback.
counter
=
0
;
loop
.
port
.
wait
();
}
else
if
(
++
counter
>
waitScope
.
busyPollInterval
)
{
// Note: It's intentional that if busyPollInterval is kj::maxValue, we never poll.
counter
=
0
;
loop
.
port
.
poll
();
}
}
...
...
c++/src/kj/async.h
View file @
327555fc
...
...
@@ -798,8 +798,13 @@ public:
void
poll
();
// Pumps the event queue and polls for I/O until there's nothing left to do (without blocking).
void
setBusyPollInterval
(
uint
count
)
{
busyPollInterval
=
count
;
}
// Set the maximum number of events to run in a row before calling poll() on the EventPort to
// check for new I/O.
private
:
EventLoop
&
loop
;
uint
busyPollInterval
=
kj
::
maxValue
;
friend
class
EventLoop
;
friend
void
_
::
waitImpl
(
Own
<
_
::
PromiseNode
>&&
node
,
_
::
ExceptionOrValue
&
result
,
WaitScope
&
waitScope
);
...
...
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