Skip to content

Commit e8cae1b

Browse files
committed
Bug 1591132 - Use an atomic bool for Checker::mIsWritable. r=froydnj
It's a bool, should use a bool. Differential Revision: https://phabricator.services.mozilla.com/D50495 --HG-- extra : moz-landing-system : lando
1 parent 3024015 commit e8cae1b

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

xpcom/ds/PLDHashTable.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,15 @@ struct PLDHashEntryHdr {
8686
//
8787
class Checker {
8888
public:
89-
constexpr Checker() : mState(kIdle), mIsWritable(1) {}
89+
constexpr Checker() : mState(kIdle), mIsWritable(true) {}
9090

9191
Checker& operator=(Checker&& aOther) {
9292
// Atomic<> doesn't have an |operator=(Atomic<>&&)|.
9393
mState = uint32_t(aOther.mState);
94-
mIsWritable = uint32_t(aOther.mIsWritable);
94+
mIsWritable = bool(aOther.mIsWritable);
9595

9696
aOther.mState = kIdle;
97+
// XXX Shouldn't we set mIsWritable to true here for consistency?
9798

9899
return *this;
99100
}
@@ -107,9 +108,9 @@ class Checker {
107108

108109
bool IsIdle() const { return mState == kIdle; }
109110

110-
bool IsWritable() const { return !!mIsWritable; }
111+
bool IsWritable() const { return mIsWritable; }
111112

112-
void SetNonWritable() { mIsWritable = 0; }
113+
void SetNonWritable() { mIsWritable = false; }
113114

114115
// NOTE: the obvious way to implement these functions is to (a) check
115116
// |mState| is reasonable, and then (b) update |mState|. But the lack of
@@ -190,11 +191,11 @@ class Checker {
190191
static const uint32_t kReadMax = 9999;
191192
static const uint32_t kWrite = 10000;
192193

193-
mutable mozilla::Atomic<uint32_t, mozilla::SequentiallyConsistent,
194-
mozilla::recordreplay::Behavior::DontPreserve>
194+
mozilla::Atomic<uint32_t, mozilla::SequentiallyConsistent,
195+
mozilla::recordreplay::Behavior::DontPreserve>
195196
mState;
196-
mutable mozilla::Atomic<uint32_t, mozilla::SequentiallyConsistent,
197-
mozilla::recordreplay::Behavior::DontPreserve>
197+
mozilla::Atomic<bool, mozilla::SequentiallyConsistent,
198+
mozilla::recordreplay::Behavior::DontPreserve>
198199
mIsWritable;
199200
};
200201
#endif

0 commit comments

Comments
 (0)