Browse Source

.

pull/9/head
Jae Kwon 11 years ago
parent
commit
4e09037e9f
5 changed files with 43 additions and 1 deletions
  1. +1
    -0
      blocks/account.go
  2. +1
    -0
      blocks/adjustment.go
  3. +1
    -0
      blocks/tx.go
  4. +39
    -0
      common/debounce.go
  5. +1
    -1
      common/panic.go

+ 1
- 0
blocks/account.go View File

@ -1,6 +1,7 @@
package blocks
import (
. "github.com/tendermint/tendermint/common"
. "github.com/tendermint/tendermint/binary"
"io"
)


+ 1
- 0
blocks/adjustment.go View File

@ -1,6 +1,7 @@
package blocks
import (
. "github.com/tendermint/tendermint/common"
. "github.com/tendermint/tendermint/binary"
"io"
)


+ 1
- 0
blocks/tx.go View File

@ -1,6 +1,7 @@
package blocks
import (
. "github.com/tendermint/tendermint/common"
. "github.com/tendermint/tendermint/binary"
"io"
)


+ 39
- 0
common/debounce.go View File

@ -0,0 +1,39 @@
package common
import (
"time"
)
/* Debouncer */
type Debouncer struct {
Ch chan struct{}
quit chan struct{}
dur time.Duration
timer *time.Timer
}
func NewDebouncer(dur time.Duration) *Debouncer {
var timer *time.Timer
var ch = make(chan struct{})
var quit = make(chan struct{})
fire := func() {
go func() {
select {
case ch <- struct{}{}:
case <-quit:
}
}()
timer.Reset(dur)
}
timer = time.AfterFunc(dur, fire)
return &Debouncer{Ch:ch, dur:dur, quit:quit, timer:timer}
}
func (d *Debouncer) Reset() {
d.timer.Reset(d.dur)
}
func (d *Debouncer) Stop() bool {
close(d.quit)
return d.timer.Stop()
}

blocks/util.go → common/panic.go View File


Loading…
Cancel
Save