Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
46e9b522
Commit
46e9b522
authored
May 25, 2017
by
Wojciech Tyczynski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make BoundedFrequencyRunner Run() really non-blocking
parent
714ac7c9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
+12
-2
bounded_frequency_runner.go
pkg/util/async/bounded_frequency_runner.go
+12
-2
No files found.
pkg/util/async/bounded_frequency_runner.go
View file @
46e9b522
...
...
@@ -151,7 +151,7 @@ func construct(name string, fn func(), minInterval, maxInterval time.Duration, b
fn
:
fn
,
minInterval
:
minInterval
,
maxInterval
:
maxInterval
,
run
:
make
(
chan
struct
{},
1
6
),
run
:
make
(
chan
struct
{},
1
),
timer
:
timer
,
}
if
minInterval
==
0
{
...
...
@@ -185,8 +185,18 @@ func (bfr *BoundedFrequencyRunner) Loop(stop <-chan struct{}) {
// Run the function as soon as possible. If this is called while Loop is not
// running, the call may be deferred indefinitely.
// If there is already a queued request to call the underlying function, it
// may be dropped - it is just guaranteed that we will try calling the
// underlying function as soon as possible starting from now.
func
(
bfr
*
BoundedFrequencyRunner
)
Run
()
{
bfr
.
run
<-
struct
{}{}
// If it takes a lot of time to run the underlying function, noone is really
// processing elements from <run> channel. So to avoid blocking here on the
// putting element to it, we simply skip it if there is already an element
// in it.
select
{
case
bfr
.
run
<-
struct
{}{}
:
default
:
}
}
// assumes the lock is not held
...
...
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