summaryrefslogtreecommitdiffstats
path: root/staging_vespalib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2017-10-03 22:31:03 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2017-10-05 23:07:08 +0200
commitdff6169faab318931c8c3ca4d0dc7df4ea763594 (patch)
tree094ff5bd2fdcab25999a863987131a8bf7a8c84c /staging_vespalib
parent6fe9751702a2ccbe431944d36dc6fae339e093ab (diff)
Wire in for live reconfiguration of DocumentStore.
Diffstat (limited to 'staging_vespalib')
-rw-r--r--staging_vespalib/src/vespa/vespalib/stllike/cache.h2
-rw-r--r--staging_vespalib/src/vespa/vespalib/stllike/cache.hpp7
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/varholder.h51
3 files changed, 22 insertions, 38 deletions
diff --git a/staging_vespalib/src/vespa/vespalib/stllike/cache.h b/staging_vespalib/src/vespa/vespalib/stllike/cache.h
index 832e6ede43d..3d5ab155877 100644
--- a/staging_vespalib/src/vespa/vespalib/stllike/cache.h
+++ b/staging_vespalib/src/vespa/vespalib/stllike/cache.h
@@ -71,6 +71,8 @@ public:
*/
cache & reserveElements(size_t elems);
+ cache & setCapacityBytes(size_t sz);
+
size_t capacity() const { return Lru::capacity(); }
size_t capacityBytes() const { return _maxBytes; }
size_t size() const { return Lru::size(); }
diff --git a/staging_vespalib/src/vespa/vespalib/stllike/cache.hpp b/staging_vespalib/src/vespa/vespalib/stllike/cache.hpp
index 06e7e249ec6..a8c7d16473c 100644
--- a/staging_vespalib/src/vespa/vespalib/stllike/cache.hpp
+++ b/staging_vespalib/src/vespa/vespalib/stllike/cache.hpp
@@ -21,6 +21,13 @@ cache<P>::reserveElements(size_t elems) {
}
template< typename P >
+cache<P> &
+cache<P>::setCapacityBytes(size_t sz) {
+ _maxBytes = sz;
+ return *this;
+}
+
+template< typename P >
void
cache<P>::invalidate(const K & key) {
vespalib::LockGuard guard(_hashLock);
diff --git a/staging_vespalib/src/vespa/vespalib/util/varholder.h b/staging_vespalib/src/vespa/vespalib/util/varholder.h
index 26f8f57839a..fdcc15d1fb4 100644
--- a/staging_vespalib/src/vespa/vespalib/util/varholder.h
+++ b/staging_vespalib/src/vespa/vespalib/util/varholder.h
@@ -2,41 +2,23 @@
#pragma once
-#include <vespa/vespalib/util/noncopyable.hpp>
#include <vespa/vespalib/util/sync.h>
-namespace vespalib
-{
-
+namespace vespalib {
template <typename T>
-class VarHolder : public noncopyable
+class VarHolder
{
-
- T _v;
- vespalib::Lock _lock;
-
+ T _v;
+ Lock _lock;
public:
- VarHolder(void)
- : _v(),
- _lock()
- {
- }
+ VarHolder() : _v(), _lock() {}
+ explicit VarHolder(const T &v) : _v(v), _lock() {}
+ VarHolder(const VarHolder &) = delete;
+ VarHolder & operator = (const VarHolder &) = delete;
+ ~VarHolder() {}
- explicit
- VarHolder(const T &v)
- : _v(v),
- _lock()
- {
- }
-
- ~VarHolder(void)
- {
- }
-
- void
- set(const T &v)
- {
+ void set(const T &v) {
T old;
{
vespalib::LockGuard guard(_lock);
@@ -45,19 +27,12 @@ public:
}
}
- void
- clear(void)
- {
- set(T());
- }
+ void clear() { set(T()); }
- T
- get(void) const
- {
+ T get() const {
vespalib::LockGuard guard(_lock);
return _v;
}
};
-} // namespace vespalib
-
+}