shards: remove context from R/W lock helper
We always passed in background context. Additionally this makes it clearer
that lock can't fail.
Change-Id: I94f0c23ce84cb97ec1f4b3b2097e67f681364e80
diff --git a/shards/shards.go b/shards/shards.go
index 96e8419..b90c964 100644
--- a/shards/shards.go
+++ b/shards/shards.go
@@ -100,7 +100,7 @@
// Close closes references to open files. It may be called only once.
func (ss *shardedSearcher) Close() {
- ss.lock(context.Background())
+ ss.lock()
defer ss.unlock()
for _, s := range ss.shards {
s.Close()
@@ -334,8 +334,9 @@
s.throttle.Release(1)
}
-func (s *shardedSearcher) lock(ctx context.Context) error {
- return s.throttle.Acquire(ctx, s.capacity)
+func (s *shardedSearcher) lock() {
+ // won't error since context.Background won't expire
+ _ = s.throttle.Acquire(context.Background(), s.capacity)
}
func (s *shardedSearcher) unlock() {
@@ -360,7 +361,7 @@
rank = shardRank(shard)
}
- s.lock(context.Background())
+ s.lock()
defer s.unlock()
old := s.shards[key]
if old.Searcher != nil {