History log of /6.6.0/platform/include/platform/non_negative_counter.h (Results 1 - 10 of 10)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: v7.0.2, v6.6.1, v7.0.0, v6.5.1
# 66c06445 03-Feb-2020 Dave Rigby <daver@couchbase.com>

MB-37096: NonNegativeCounter: Fix signed/unsigned mismatch

As reported by MSVC:

platform/non_negative_counter.h(127): warning C4018: '>': signed/unsigned mismatch
platfo

MB-37096: NonNegativeCounter: Fix signed/unsigned mismatch

As reported by MSVC:

platform/non_negative_counter.h(127): warning C4018: '>': signed/unsigned mismatch
platform/non_negative_counter.h(116): note: while compiling class template member function 'T
cb::NonNegativeCounter<T,cb::DefaultUnderflowPolicy>::fetch_add(__int64)'
with
[
T=uint64_t
]

Change-Id: I7a5f8ec3de31bc22c72f21f8e3df47bed627190c
Reviewed-on: http://review.couchbase.org/121578
Well-Formed: Build Bot <build@couchbase.com>
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: Richard de Mellow <richard.demellow@couchbase.com>

show more ...


# 91143b09 28-Aug-2019 Dave Rigby <daver@couchbase.com>

NonNegativeCounter: Enforce invariant on construction

Change NonNegativeCounter to check that the argument passed to the
ctor is also not negative, so we catch attempts to construct an

NonNegativeCounter: Enforce invariant on construction

Change NonNegativeCounter to check that the argument passed to the
ctor is also not negative, so we catch attempts to construct an
invalid NonNegativeCounter.

(This change was motivated by a bug where we constructed a
NonNegativeCounter with a negative value, but didn't identify the
'underflow' until the /next/ time the counter was modified, which made
the bug hard to track down.)

Change-Id: Ib7d4079e977817aa17ea650b74de64e5b2cde868
Reviewed-on: http://review.couchbase.org/113966
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: James Harrison <james.harrison@couchbase.com>

show more ...


Revision tags: v6.0.3
# fd7818a5 24-Apr-2019 Ben Huddleston <ben.huddleston@couchbase.com>

MB-33846: Make NonNegativeCounter deal with negatives

In the hash table in kv_engine we often add negative values.
This causes the stats to underflow. Correct this by doing similar
l

MB-33846: Make NonNegativeCounter deal with negatives

In the hash table in kv_engine we often add negative values.
This causes the stats to underflow. Correct this by doing similar
logic done in fetch_sub in fetch_add, and allowing fetch_add to
take a signed type. Also, allow fetch_sub to take a negative value
for consistency.

Change-Id: Ic63012ce41fe13a627477a386551aa7805ca00e2
Reviewed-on: http://review.couchbase.org/108202
Reviewed-by: Dave Rigby <daver@couchbase.com>
Tested-by: Build Bot <build@couchbase.com>

show more ...


Revision tags: v5.5.4
# acda8ff3 15-Mar-2019 Trond Norbye <trond.norbye@gmail.com>

Header files should not include config.h

Change-Id: I29911b26033b35164ffa3747fa46b7c677cbce9b
Reviewed-on: http://review.couchbase.org/106297
Tested-by: Build Bot <build@couchbase.co

Header files should not include config.h

Change-Id: I29911b26033b35164ffa3747fa46b7c677cbce9b
Reviewed-on: http://review.couchbase.org/106297
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>

show more ...


# d50100a5 15-Jan-2019 Dave Rigby <daver@couchbase.com>

NonNegativeCounter: Mark noexcept methods as 'noexcept'

Mark methods of NonNegativeCounter which cannot throw as
'noexcept'. Add some documentation to the main remaining throwing
met

NonNegativeCounter: Mark noexcept methods as 'noexcept'

Mark methods of NonNegativeCounter which cannot throw as
'noexcept'. Add some documentation to the main remaining throwing
method.

Change-Id: I4d02658dc49489f79e8d3b2e7eedbae9473ac641
Reviewed-on: http://review.couchbase.org/103632
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: Ben Huddleston <ben.huddleston@couchbase.com>

show more ...


# d249c49d 09-Nov-2018 Ben Huddleston <ben.huddleston@couchbase.com>

MB-31797: Set CB_DEVELOPMENT_ASSERTS ON

Fix clang scan build error caused by used of uninitialized
value "desired" in the NonNegativeCounter when throwing an
underflow error.

MB-31797: Set CB_DEVELOPMENT_ASSERTS ON

Fix clang scan build error caused by used of uninitialized
value "desired" in the NonNegativeCounter when throwing an
underflow error.

Change-Id: Idc40e14d9f343f91042a2f926f88f98004454ecb
Reviewed-on: http://review.couchbase.org/101588
Reviewed-by: Dave Rigby <daver@couchbase.com>
Tested-by: Build Bot <build@couchbase.com>

show more ...


Revision tags: v5.5.0, v4.6.5
# d1c31a5d 05-Jan-2018 Dave Rigby <daver@couchbase.com>

NonNegativeCounter: make copy-ctor non-explicit

GCC 5.4 appears to have a bug where it fails to inline the call to a
copy constructor of the templated type for std::array in some
cir

NonNegativeCounter: make copy-ctor non-explicit

GCC 5.4 appears to have a bug where it fails to inline the call to a
copy constructor of the templated type for std::array in some
circumstances (not totally clear). More specifically, we see a linker
failure in kv_engine/hash_table_test.cc (after some refactoring) when
generating code to copy a std::array<NonNegativeCounter> for the
following code:

HashTable ht;
auto datatypeCountsBeforeCopy = ht.datatypeCounts;

where datatypeCounts is of type:

std::array<cb::NonNegativeCounter<size_t>,
mcbp::datatype::highest + 1>

This results in the following error:

hash_table_test.cc.o: In function `std::array<cb::NonNegativeCounter<unsigned long, cb::ClampAtZeroUnderflowPolicy>, 8ul>::array(std::array<cb::NonNegativeCounter<unsigned long, cb::ClampAtZeroUnderflowPolicy>, 8ul> const&)':
/usr/include/c++/5/array:89: undefined reference to `cb::NonNegativeCounter<unsigned long, cb::ClampAtZeroUnderflowPolicy>::NonNegativeCounter(unsigned long)'
collect2: error: ld returned 1 exit status

The code compiles fine in clang & MSVC.

I don't know the exact root cause here, but removing the `explicit`
keyword from NonNegativeCounter's copy-ctor avoid the problem. Given
the argument to the constructor is simply read from (via load()); I
don't think removing explicit will cause any other issues.

Change-Id: Ic6cdd8327444fde09cd18de71862a86f2ad67cef
Reviewed-on: http://review.couchbase.org/87467
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: Daniel Owen <owend@couchbase.com>

show more ...


# 53c9a646 19-Sep-2017 Dave Rigby <daver@couchbase.com>

MB-26295: NonNegativeCounter: throw exception on CB_DEVELOPMENT_ASSERTS

If CB_DEVELOPMENT_ASSERTS is defined, change the
DefaultUnderflowPolicy for NonNegativeCounter to
ThrowExcepti

MB-26295: NonNegativeCounter: throw exception on CB_DEVELOPMENT_ASSERTS

If CB_DEVELOPMENT_ASSERTS is defined, change the
DefaultUnderflowPolicy for NonNegativeCounter to
ThrowExceptionUnderflowPolicy, so an exception is thrown if the
counter would underflow.

This helps to expose any bugs in objects using this type.

Change-Id: I8c6c7365dd7ca83dd9c45623b53b6f3321ec29ff
Reviewed-on: http://review.couchbase.org/83502
Reviewed-by: Manu Dhundi <manu@couchbase.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Build Bot <build@couchbase.com>

show more ...


Revision tags: v5.0.0
# fd19cf71 11-Apr-2017 Dave Rigby <daver@couchbase.com>

NonNegativeCounter: Allow underflow policy to be customized

Add an additional template parameter to NonNegativeCounter named
UnderflowPolicy which can be used to customize the behaviour

NonNegativeCounter: Allow underflow policy to be customized

Add an additional template parameter to NonNegativeCounter named
UnderflowPolicy which can be used to customize the behaviour of this
class when it underflows.

The policy defaults to ClampAtZeroUnderflowPolicy (which is the
previous behavour), but it also adds ThrowExceptionUnderflowPolicy for
use in debugging / situations where we want to know if the counter
would have underflown.

Change-Id: I576c250a1627203b386daba23511b11555a49684
Reviewed-on: http://review.couchbase.org/76636
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: Jim Walker <jim@couchbase.com>

show more ...


# 1f2f60b6 02-Feb-2017 James Harrison <00jamesh@gmail.com>

MB-22230 add NonNegativeCounter<>

Creating NonNegativeCounter<> which cannot be reduced below 0, and will
instead be clamped at 0.

This simplifies some code e.g., we currently u

MB-22230 add NonNegativeCounter<>

Creating NonNegativeCounter<> which cannot be reduced below 0, and will
instead be clamped at 0.

This simplifies some code e.g., we currently use

stats.diskQueueSize.fetch_add
stats.decrDiskQueueSize

because using

stats.diskQueueSize.fetch_sub

directly could underflow a std::atomic.

Change-Id: I19e8645e5c1d4c608976750b323c825a1ec1b98b
Reviewed-on: http://review.couchbase.org/72409
Reviewed-by: Dave Rigby <daver@couchbase.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Build Bot <build@couchbase.com>

show more ...