aboutsummaryrefslogtreecommitdiffhomepage
path: root/watcher/batcher.go
diff options
context:
space:
mode:
authorTibor Vass <[email protected]>2014-01-29 14:50:31 -0800
committerspf13 <[email protected]>2014-01-29 18:03:35 -0500
commit6dd2e9a49acde23dcf5e9701915f7e8ed692ce5a (patch)
treedbbc04239e25626868fad3e7faab656c26e3715a /watcher/batcher.go
parentff9f6e1b2a000a24e677b9a3fa8dfbdef11c404c (diff)
downloadhugo-6dd2e9a49acde23dcf5e9701915f7e8ed692ce5a.tar.gz
hugo-6dd2e9a49acde23dcf5e9701915f7e8ed692ce5a.zip
gofmt all go code
Diffstat (limited to 'watcher/batcher.go')
-rw-r--r--watcher/batcher.go112
1 files changed, 56 insertions, 56 deletions
diff --git a/watcher/batcher.go b/watcher/batcher.go
index a22ad8b41..7e9ce8861 100644
--- a/watcher/batcher.go
+++ b/watcher/batcher.go
@@ -1,56 +1,56 @@
-package watcher
-
-import (
- "github.com/howeyc/fsnotify"
- "time"
-)
-
-type Batcher struct {
- *fsnotify.Watcher
- interval time.Duration
- done chan struct{}
-
- Event chan []*fsnotify.FileEvent // Events are returned on this channel
-}
-
-func New(interval time.Duration) (*Batcher, error) {
- watcher, err := fsnotify.NewWatcher()
-
- batcher := &Batcher{}
- batcher.Watcher = watcher
- batcher.interval = interval
- batcher.done = make(chan struct{}, 1)
- batcher.Event = make(chan []*fsnotify.FileEvent, 1)
-
- if err == nil {
- go batcher.run()
- }
-
- return batcher, err
-}
-
-func (b *Batcher) run() {
- tick := time.Tick(b.interval)
- evs := make([]*fsnotify.FileEvent, 0)
-OuterLoop:
- for {
- select {
- case ev := <-b.Watcher.Event:
- evs = append(evs, ev)
- case <-tick:
- if len(evs) == 0 {
- continue
- }
- b.Event <- evs
- evs = make([]*fsnotify.FileEvent, 0)
- case <-b.done:
- break OuterLoop
- }
- }
- close(b.done)
-}
-
-func (b *Batcher) Close() {
- b.done <- struct{}{}
- b.Watcher.Close()
-}
+package watcher
+
+import (
+ "github.com/howeyc/fsnotify"
+ "time"
+)
+
+type Batcher struct {
+ *fsnotify.Watcher
+ interval time.Duration
+ done chan struct{}
+
+ Event chan []*fsnotify.FileEvent // Events are returned on this channel
+}
+
+func New(interval time.Duration) (*Batcher, error) {
+ watcher, err := fsnotify.NewWatcher()
+
+ batcher := &Batcher{}
+ batcher.Watcher = watcher
+ batcher.interval = interval
+ batcher.done = make(chan struct{}, 1)
+ batcher.Event = make(chan []*fsnotify.FileEvent, 1)
+
+ if err == nil {
+ go batcher.run()
+ }
+
+ return batcher, err
+}
+
+func (b *Batcher) run() {
+ tick := time.Tick(b.interval)
+ evs := make([]*fsnotify.FileEvent, 0)
+OuterLoop:
+ for {
+ select {
+ case ev := <-b.Watcher.Event:
+ evs = append(evs, ev)
+ case <-tick:
+ if len(evs) == 0 {
+ continue
+ }
+ b.Event <- evs
+ evs = make([]*fsnotify.FileEvent, 0)
+ case <-b.done:
+ break OuterLoop
+ }
+ }
+ close(b.done)
+}
+
+func (b *Batcher) Close() {
+ b.done <- struct{}{}
+ b.Watcher.Close()
+}