Merge pull request #7489 from sfc-gh-tclinkenbeard/cstate-pimpl

Mark `CoordinatedState::getConflict` const
This commit is contained in:
Trevor Clinkenbeard 2022-07-18 13:22:18 -07:00 committed by GitHub
commit 18a2c3f8a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 12 deletions

View File

@ -39,4 +39,6 @@ public:
T const& operator*() const { return *impl; }
T* operator->() { return impl.get(); }
T const* operator->() const { return impl.get(); }
T* get() { return impl.get(); }
T const* get() const { return impl.get(); }
};

View File

@ -79,13 +79,13 @@ struct CoordinatedStateImpl {
CoordinatedStateImpl(ServerCoordinators const& c)
: coordinators(c), stage(0), conflictGen(0), doomed(false), ac(false), initial(false) {}
uint64_t getConflict() { return conflictGen; }
uint64_t getConflict() const { return conflictGen; }
bool isDoomed(GenerationRegReadReply const& rep) {
return rep.gen > gen // setExclusive is doomed, because there was a write at least started at a higher
// generation, which means a read completed at that higher generation
// || rep.rgen > gen // setExclusive isn't absolutely doomed, but it may/probably will fail
;
bool isDoomed(GenerationRegReadReply const& rep) const {
return rep.gen > gen;
// setExclusive is doomed, because there was a write at least started at a higher
// generation, which means a read completed at that higher generation
// || rep.rgen > gen // setExclusive isn't absolutely doomed, but it may/probably will fail
}
ACTOR static Future<Value> read(CoordinatedStateImpl* self) {
@ -216,7 +216,7 @@ struct CoordinatedStateImpl {
};
CoordinatedState::CoordinatedState(ServerCoordinators const& coord)
: impl(std::make_unique<CoordinatedStateImpl>(coord)) {}
: impl(PImpl<CoordinatedStateImpl>::create(coord)) {}
CoordinatedState::~CoordinatedState() = default;
Future<Value> CoordinatedState::read() {
return CoordinatedStateImpl::read(impl.get());
@ -227,7 +227,7 @@ Future<Void> CoordinatedState::onConflict() {
Future<Void> CoordinatedState::setExclusive(Value v) {
return CoordinatedStateImpl::setExclusive(impl.get(), v);
}
uint64_t CoordinatedState::getConflict() {
uint64_t CoordinatedState::getConflict() const {
return impl->getConflict();
}
@ -354,7 +354,7 @@ struct MovableCoordinatedStateImpl {
MovableCoordinatedState& MovableCoordinatedState::operator=(MovableCoordinatedState&&) = default;
MovableCoordinatedState::MovableCoordinatedState(class ServerCoordinators const& coord)
: impl(std::make_unique<MovableCoordinatedStateImpl>(coord)) {}
: impl(PImpl<MovableCoordinatedStateImpl>::create(coord)) {}
MovableCoordinatedState::~MovableCoordinatedState() = default;
Future<Value> MovableCoordinatedState::read() {
return MovableCoordinatedStateImpl::read(impl.get());

View File

@ -23,6 +23,7 @@
#pragma once
#include "fdbclient/FDBTypes.h"
#include "fdbclient/PImpl.h"
class CoordinatedState : NonCopyable {
public:
@ -53,10 +54,10 @@ public:
// returned from read may or may not ever have been a valid state. Probably there was a
// call to read() or setExclusive() concurrently with this pair.
uint64_t getConflict();
uint64_t getConflict() const;
private:
std::unique_ptr<struct CoordinatedStateImpl> impl;
PImpl<struct CoordinatedStateImpl> impl;
};
class MovableCoordinatedState : NonCopyable {
@ -78,7 +79,7 @@ public:
// (and therefore the caller should die).
private:
std::unique_ptr<struct MovableCoordinatedStateImpl> impl;
PImpl<struct MovableCoordinatedStateImpl> impl;
};
#endif