Make --select-1 and --exit-0 asynchronous

This commit is contained in:
Junegunn Choi
2015-02-18 00:08:17 +09:00
parent d760b790b3
commit e808151c28
3 changed files with 39 additions and 32 deletions

View File

@@ -86,7 +86,7 @@ func (m *Matcher) Loop() {
}
if !foundCache {
merger, cancelled = m.scan(request, 0)
merger, cancelled = m.scan(request)
}
if !cancelled {
@@ -121,7 +121,7 @@ type partialResult struct {
matches []*Item
}
func (m *Matcher) scan(request MatchRequest, limit int) (*Merger, bool) {
func (m *Matcher) scan(request MatchRequest) (*Merger, bool) {
startedAt := time.Now()
numChunks := len(request.chunks)
@@ -175,10 +175,6 @@ func (m *Matcher) scan(request MatchRequest, limit int) (*Merger, bool) {
count++
matchCount += matchesInChunk
if limit > 0 && matchCount > limit {
return nil, wait() // For --select-1 and --exit-0
}
if count == numChunks {
break
}