diff options
author | Felföldi Zsolt <zsfelfoldi@gmail.com> | 2019-05-31 02:51:13 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-31 02:51:13 +0800 |
commit | 58497f46bd0bdd105828c30500e863e826e598cd (patch) | |
tree | 7c658530edfebb6e47ed5f993753f4b48fd1747e /les/execqueue.go | |
parent | 3d58268bba92c6c8f7f035bafcd1608bc22cee51 (diff) | |
download | go-tangerine-58497f46bd0bdd105828c30500e863e826e598cd.tar go-tangerine-58497f46bd0bdd105828c30500e863e826e598cd.tar.gz go-tangerine-58497f46bd0bdd105828c30500e863e826e598cd.tar.bz2 go-tangerine-58497f46bd0bdd105828c30500e863e826e598cd.tar.lz go-tangerine-58497f46bd0bdd105828c30500e863e826e598cd.tar.xz go-tangerine-58497f46bd0bdd105828c30500e863e826e598cd.tar.zst go-tangerine-58497f46bd0bdd105828c30500e863e826e598cd.zip |
les, les/flowcontrol: implement LES/3 (#19329)
les, les/flowcontrol: implement LES/3
Diffstat (limited to 'les/execqueue.go')
-rw-r--r-- | les/execqueue.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/les/execqueue.go b/les/execqueue.go index 614721bf0..e0c88a990 100644 --- a/les/execqueue.go +++ b/les/execqueue.go @@ -44,7 +44,7 @@ func (q *execQueue) loop() { func (q *execQueue) waitNext(drop bool) (f func()) { q.mu.Lock() - if drop { + if drop && len(q.funcs) > 0 { // Remove the function that just executed. We do this here instead of when // dequeuing so len(q.funcs) includes the function that is running. q.funcs = append(q.funcs[:0], q.funcs[1:]...) @@ -84,6 +84,13 @@ func (q *execQueue) queue(f func()) bool { return ok } +// clear drops all queued functions +func (q *execQueue) clear() { + q.mu.Lock() + q.funcs = q.funcs[:0] + q.mu.Unlock() +} + // quit stops the exec queue. // quit waits for the current execution to finish before returning. func (q *execQueue) quit() { |