Subzero: Use C++11 member initializers where practical.
Also change the pattern "foo() {}" into "foo() = default;" for ctors and dtors.
Generally avoids initializing unique_ptr<> members to nullptr in a .h file, because that requires knowing the definition of the underlying class which may not be available to all includers.
BUG= none
R=jpp@chromium.org
Review URL: https://codereview.chromium.org/1197223002
diff --git a/src/IceThreading.h b/src/IceThreading.h
index 35e1bfb..12b085d 100644
--- a/src/IceThreading.h
+++ b/src/IceThreading.h
@@ -55,8 +55,7 @@
public:
BoundedProducerConsumerQueue(bool Sequential, size_t MaxSize = MaxStaticSize)
- : Back(0), Front(0), MaxSize(std::min(MaxSize, MaxStaticSize)),
- Sequential(Sequential), IsEnded(false) {}
+ : MaxSize(std::min(MaxSize, MaxStaticSize)), Sequential(Sequential) {}
void blockingPush(T *Item) {
{
std::unique_lock<GlobalLockType> L(Lock);
@@ -112,7 +111,7 @@
// be pushed. (More precisely, Back&MaxStaticSize is the index.)
// It is written by the producers, and read by all via size() and
// empty().
- size_t Back;
+ size_t Back = 0;
ICE_CACHELINE_BOUNDARY;
// Shrunk is notified (by the consumer) when something is removed
@@ -124,7 +123,7 @@
// i.e. the next to be popped. (More precisely Front&MaxStaticSize
// is the index.) It is written by the consumers, and read by all
// via size() and empty().
- size_t Front;
+ size_t Front = 0;
ICE_CACHELINE_BOUNDARY;
@@ -133,7 +132,7 @@
const bool Sequential;
// IsEnded is read by the consumers, and only written once by the
// producer.
- bool IsEnded;
+ bool IsEnded = false;
// The lock must be held when the following methods are called.
bool empty() const { return Front == Back; }