Skip to content

Commit

Permalink
buffer some channels
Browse files Browse the repository at this point in the history
  • Loading branch information
osteele committed Jul 18, 2017
1 parent 1ff6599 commit 0642963
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions site/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ func (e FilesEvent) String() string {
func (s *Site) WatchFiles() (<-chan FilesEvent, error) {
var (
sourceDir = s.SourceDir()
events = make(chan string)
debounced = debounce(time.Second, events)
filenames = make(chan string, 100)
debounced = debounce(time.Second, filenames)
results = make(chan FilesEvent)
)
watcher, err := fsnotify.NewWatcher()
Expand All @@ -39,7 +39,7 @@ func (s *Site) WatchFiles() (<-chan FilesEvent, error) {
for {
select {
case event := <-watcher.Events:
events <- event.Name
filenames <- event.Name
case err := <-watcher.Errors:
fmt.Fprintln(os.Stderr, "error:", err)
}
Expand Down
3 changes: 2 additions & 1 deletion site/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io"
"os"
"path/filepath"
"runtime"
"strings"

"github.com/osteele/gojekyll/pages"
Expand All @@ -16,7 +17,7 @@ import (
// WriteFiles writes output files.
// It attends to options.dry_run.
func (s *Site) WriteFiles() (count int, err error) {
errs := make(chan error)
errs := make(chan error, runtime.NumCPU())
for _, p := range s.OutputDocs() {
count++
go func(d pages.Document) {
Expand Down

0 comments on commit 0642963

Please sign in to comment.