Skip to content

Commit

Permalink
fixup! Have only Reserve in the modules.VU interface
Browse files Browse the repository at this point in the history
  • Loading branch information
mstoykov committed Dec 2, 2021
1 parent 7043369 commit 9140e32
Showing 1 changed file with 0 additions and 7 deletions.
7 changes: 0 additions & 7 deletions js/eventloop.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
type eventLoop struct {
lock sync.Mutex
queue []func() error
started int
wakeupCh chan struct{} // maybe use sync.Cond ?
reservedCount int
}
Expand All @@ -55,15 +54,10 @@ func (e *eventLoop) wakeup() {
func (e *eventLoop) reserve() func(func() error) bool {
e.lock.Lock()
e.reservedCount++
started := e.started
e.lock.Unlock()

return func(f func() error) bool {
e.lock.Lock()
if started != e.started {
e.lock.Unlock()
return false
}
e.queue = append(e.queue, f)
e.reservedCount--
e.lock.Unlock()
Expand All @@ -77,7 +71,6 @@ func (e *eventLoop) reserve() func(func() error) bool {
// After it returns any Reserved function from this start will not be queued even if the eventLoop is restarted
func (e *eventLoop) start(f func() error) error {
e.lock.Lock()
e.started++
e.reservedCount = 0
e.queue = append(e.queue, f)
e.lock.Unlock()
Expand Down

0 comments on commit 9140e32

Please sign in to comment.