diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2015-01-11 23:49:12 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2015-01-11 23:49:12 +0900 |
commit | 9dbf6b02d24b52ae43e36905bbb1e83087e1dfe9 (patch) | |
tree | 37e627f5bb4a3037ea769aad1033593baec4eb00 /src/core.go | |
parent | 1db68a3976cfb10ed7d6ab88d7b468bb1b93ee34 (diff) |
Fix race conditions
- Wait for completions of goroutines when cancelling a search
- Remove shared access to rank field of Item
Diffstat (limited to 'src/core.go')
-rw-r--r-- | src/core.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/core.go b/src/core.go index 2970038f..ab2a48fa 100644 --- a/src/core.go +++ b/src/core.go @@ -64,7 +64,10 @@ func Run(options *Options) { var chunkList *ChunkList if len(opts.WithNth) == 0 { chunkList = NewChunkList(func(data *string, index int) *Item { - return &Item{text: data, rank: Rank{0, 0, uint32(index)}} + return &Item{ + text: data, + index: uint32(index), + rank: Rank{0, 0, uint32(index)}} }) } else { chunkList = NewChunkList(func(data *string, index int) *Item { @@ -72,6 +75,7 @@ func Run(options *Options) { item := Item{ text: Transform(tokens, opts.WithNth).whole, origText: data, + index: uint32(index), rank: Rank{0, 0, uint32(index)}} return &item }) |