diff options
Diffstat (limited to 'staging_vespalib')
-rw-r--r-- | staging_vespalib/src/vespa/vespalib/stllike/cache.h | 2 | ||||
-rw-r--r-- | staging_vespalib/src/vespa/vespalib/stllike/cache.hpp | 7 | ||||
-rw-r--r-- | staging_vespalib/src/vespa/vespalib/util/varholder.h | 51 |
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 - +} |