aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@oath.com>2017-12-12 13:50:02 +0000
committerTor Egge <Tor.Egge@oath.com>2017-12-12 13:50:02 +0000
commitb43a3d9b4aec0e0a537d5711aae6f8044e08177c (patch)
tree613511e25c58a5f7f5099c2b624cbed198b59ff2
parent855cce458dffb6c699555a664f11a8a25fa43100 (diff)
Use standard locking in searchlib (pass 2).
-rw-r--r--searchlib/src/vespa/searchlib/common/bitvectorcache.cpp16
-rw-r--r--searchlib/src/vespa/searchlib/common/bitvectorcache.h6
-rw-r--r--searchlib/src/vespa/searchlib/common/sortspec.cpp1
-rw-r--r--searchlib/src/vespa/searchlib/uca/ucaconverter.cpp6
4 files changed, 14 insertions, 15 deletions
diff --git a/searchlib/src/vespa/searchlib/common/bitvectorcache.cpp b/searchlib/src/vespa/searchlib/common/bitvectorcache.cpp
index 04909da8ea7..a063ed347a4 100644
--- a/searchlib/src/vespa/searchlib/common/bitvectorcache.cpp
+++ b/searchlib/src/vespa/searchlib/common/bitvectorcache.cpp
@@ -29,7 +29,7 @@ BitVectorCache::computeCountVector(KeySet & keys, CountVector & v) const
std::vector<CondensedBitVector::KeySet> keySets;
ChunkV chunks;
{
- vespalib::LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
keySets.resize(_chunks.size());
Key2Index::const_iterator end(_keys.end());
for (Key k : keys) {
@@ -61,7 +61,7 @@ BitVectorCache::KeySet
BitVectorCache::lookupCachedSet(const KeyAndCountSet & keys)
{
KeySet cached(keys.size()*3);
- vespalib::LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
_lookupCount++;
if (_lookupCount == 2000) {
_needPopulation = true;
@@ -101,7 +101,7 @@ BitVectorCache::getSorted(Key2Index & keys)
}
bool
-BitVectorCache::hasCostChanged(const vespalib::LockGuard & guard)
+BitVectorCache::hasCostChanged(const std::lock_guard<std::mutex> & guard)
{
(void) guard;
if ( ! _chunks.empty()) {
@@ -163,17 +163,17 @@ BitVectorCache::populate(Key2Index & newKeys, CondensedBitVector & chunk, const
void
BitVectorCache::populate(uint32_t sz, const PopulateInterface & lookup)
{
- vespalib::LockGuard guard1(_lock);
+ std::unique_lock<std::mutex> guard(_lock);
if (! _needPopulation) {
return;
}
Key2Index newKeys(_keys);
- guard1.unlock();
+ guard.unlock();
CondensedBitVector::UP chunk(CondensedBitVector::create(sz, _genHolder));
populate(newKeys, *chunk, lookup);
- vespalib::LockGuard guard2(_lock);
+ guard.lock();
_chunks.push_back(std::move(chunk));
_keys.swap(newKeys);
_needPopulation = false;
@@ -182,7 +182,7 @@ BitVectorCache::populate(uint32_t sz, const PopulateInterface & lookup)
void
BitVectorCache::set(Key key, uint32_t index, bool v)
{
- vespalib::LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
auto found = _keys.find(key);
if (found != _keys.end()) {
const KeyMeta & m(found->second);
@@ -202,7 +202,7 @@ BitVectorCache::get(Key key, uint32_t index) const
void
BitVectorCache::removeIndex(uint32_t index)
{
- vespalib::LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
for (auto & chunk : _chunks) {
chunk->clearIndex(index);
}
diff --git a/searchlib/src/vespa/searchlib/common/bitvectorcache.h b/searchlib/src/vespa/searchlib/common/bitvectorcache.h
index 0d27701e1e1..c1415d9130f 100644
--- a/searchlib/src/vespa/searchlib/common/bitvectorcache.h
+++ b/searchlib/src/vespa/searchlib/common/bitvectorcache.h
@@ -2,9 +2,9 @@
#pragma once
#include "condensedbitvectors.h"
-#include <vespa/vespalib/util/sync.h>
#include <vespa/vespalib/stllike/hash_set.h>
#include <vespa/fastos/dynamiclibrary.h>
+#include <mutex>
namespace search {
@@ -74,11 +74,11 @@ private:
VESPA_DLL_LOCAL static SortedKeyMeta getSorted(Key2Index & keys);
VESPA_DLL_LOCAL static void populate(Key2Index & newKeys, CondensedBitVector & chunk, const PopulateInterface & lookup);
- VESPA_DLL_LOCAL bool hasCostChanged(const vespalib::LockGuard &);
+ VESPA_DLL_LOCAL bool hasCostChanged(const std::lock_guard<std::mutex> &);
uint64_t _lookupCount;
bool _needPopulation;
- vespalib::Lock _lock;
+ mutable std::mutex _lock;
Key2Index _keys;
ChunkV _chunks;
GenerationHolder &_genHolder;
diff --git a/searchlib/src/vespa/searchlib/common/sortspec.cpp b/searchlib/src/vespa/searchlib/common/sortspec.cpp
index f43596f9c7f..694443b00ba 100644
--- a/searchlib/src/vespa/searchlib/common/sortspec.cpp
+++ b/searchlib/src/vespa/searchlib/common/sortspec.cpp
@@ -1,7 +1,6 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "sortspec.h"
#include <vespa/vespalib/util/stringfmt.h>
-#include <vespa/vespalib/util/sync.h>
#include <vespa/fastlib/text/normwordfolder.h>
#include <vespa/vespalib/text/utf8.h>
diff --git a/searchlib/src/vespa/searchlib/uca/ucaconverter.cpp b/searchlib/src/vespa/searchlib/uca/ucaconverter.cpp
index db16d165cec..47d66a94d9e 100644
--- a/searchlib/src/vespa/searchlib/uca/ucaconverter.cpp
+++ b/searchlib/src/vespa/searchlib/uca/ucaconverter.cpp
@@ -2,8 +2,8 @@
#include "ucaconverter.h"
#include <vespa/vespalib/util/stringfmt.h>
-#include <vespa/vespalib/util/sync.h>
#include <vespa/vespalib/text/utf8.h>
+#include <mutex>
#include <vespa/log/log.h>
LOG_SETUP(".search.common.sortspec");
@@ -14,7 +14,7 @@ using vespalib::ConstBufferRef;
using vespalib::make_string;
namespace {
- vespalib::Lock _GlobalDirtyICUThreadSafeLock;
+std::mutex _GlobalDirtyICUThreadSafeLock;
}
BlobConverter::UP
@@ -30,7 +30,7 @@ UcaConverter::UcaConverter(vespalib::stringref locale, vespalib::stringref stren
UErrorCode status = U_ZERO_ERROR;
Collator *coll(NULL);
{
- vespalib::LockGuard guard(_GlobalDirtyICUThreadSafeLock);
+ std::lock_guard<std::mutex> guard(_GlobalDirtyICUThreadSafeLock);
coll = Collator::createInstance(icu::Locale(locale.c_str()), status);
}
if(U_SUCCESS(status)) {