Use override where applicable in fdbclient
This commit is contained in:
parent
4005abdeb3
commit
a3de8c333b
|
@ -171,12 +171,12 @@ public:
|
|||
void* userdata)
|
||||
: callbackf(callbackf), f(f), userdata(userdata) {}
|
||||
|
||||
virtual bool canFire(int notMadeActive) { return true; }
|
||||
virtual void fire(const Void& unused, int& userParam) {
|
||||
bool canFire(int notMadeActive) const override { return true; }
|
||||
void fire(const Void& unused, int& userParam) override {
|
||||
(*callbackf)(f, userdata);
|
||||
delete this;
|
||||
}
|
||||
virtual void error(const Error&, int& userParam) {
|
||||
void error(const Error&, int& userParam) override {
|
||||
(*callbackf)(f, userdata);
|
||||
delete this;
|
||||
}
|
||||
|
|
|
@ -1884,7 +1884,7 @@ public:
|
|||
return BlobStoreEndpoint::getURLFormat(true) + " (Note: The 'bucket' parameter is required.)";
|
||||
}
|
||||
|
||||
virtual ~BackupContainerBlobStore() {}
|
||||
~BackupContainerBlobStore() = default;
|
||||
|
||||
Future<Reference<IAsyncFile>> readFile(std::string path) final {
|
||||
return Reference<IAsyncFile>(
|
||||
|
|
|
@ -793,13 +793,13 @@ namespace fileBackup {
|
|||
return Void();
|
||||
}
|
||||
|
||||
virtual StringRef getName() const {
|
||||
TraceEvent(SevError, "FileBackupError").detail("Cause", "AbortFiveZeroBackupTaskFunc::name() should never be called");
|
||||
StringRef getName() const override {
|
||||
TraceEvent(SevError, "FileBackupError").detail("Cause", "AbortFiveZeroBackupTaskFunc::name() should never be called");
|
||||
ASSERT(false);
|
||||
return StringRef();
|
||||
}
|
||||
}
|
||||
|
||||
Future<Void> execute(Database cx, Reference<TaskBucket> tb, Reference<FutureBucket> fb, Reference<Task> task) { return Future<Void>(Void()); };
|
||||
Future<Void> execute(Database cx, Reference<TaskBucket> tb, Reference<FutureBucket> fb, Reference<Task> task) { return Future<Void>(Void()); };
|
||||
Future<Void> finish(Reference<ReadYourWritesTransaction> tr, Reference<TaskBucket> tb, Reference<FutureBucket> fb, Reference<Task> task) { return _finish(tr, tb, fb, task); };
|
||||
};
|
||||
StringRef AbortFiveZeroBackupTask::name = LiteralStringRef("abort_legacy_backup");
|
||||
|
@ -863,13 +863,13 @@ namespace fileBackup {
|
|||
return Void();
|
||||
}
|
||||
|
||||
virtual StringRef getName() const {
|
||||
TraceEvent(SevError, "FileBackupError").detail("Cause", "AbortFiveOneBackupTaskFunc::name() should never be called");
|
||||
StringRef getName() const override {
|
||||
TraceEvent(SevError, "FileBackupError").detail("Cause", "AbortFiveOneBackupTaskFunc::name() should never be called");
|
||||
ASSERT(false);
|
||||
return StringRef();
|
||||
}
|
||||
}
|
||||
|
||||
Future<Void> execute(Database cx, Reference<TaskBucket> tb, Reference<FutureBucket> fb, Reference<Task> task) { return Future<Void>(Void()); };
|
||||
Future<Void> execute(Database cx, Reference<TaskBucket> tb, Reference<FutureBucket> fb, Reference<Task> task) { return Future<Void>(Void()); };
|
||||
Future<Void> finish(Reference<ReadYourWritesTransaction> tr, Reference<TaskBucket> tb, Reference<FutureBucket> fb, Reference<Task> task) { return _finish(tr, tb, fb, task); };
|
||||
};
|
||||
StringRef AbortFiveOneBackupTask::name = LiteralStringRef("abort_legacy_backup_5.2");
|
||||
|
@ -940,24 +940,18 @@ namespace fileBackup {
|
|||
// Backup and Restore taskFunc definitions will inherit from one of the following classes which
|
||||
// servers to catch and log to the appropriate config any error that execute/finish didn't catch and log.
|
||||
struct RestoreTaskFuncBase : TaskFuncBase {
|
||||
virtual Future<Void> handleError(Database cx, Reference<Task> task, Error const &error) {
|
||||
return RestoreConfig(task).logError(cx, error, format("'%s' on '%s'", error.what(), task->params[Task::reservedTaskParamKeyType].printable().c_str()));
|
||||
}
|
||||
virtual std::string toString(Reference<Task> task)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
};
|
||||
Future<Void> handleError(Database cx, Reference<Task> task, Error const& error) override {
|
||||
return RestoreConfig(task).logError(cx, error, format("'%s' on '%s'", error.what(), task->params[Task::reservedTaskParamKeyType].printable().c_str()));
|
||||
}
|
||||
std::string toString(Reference<Task> task) const override { return ""; }
|
||||
};
|
||||
|
||||
struct BackupTaskFuncBase : TaskFuncBase {
|
||||
virtual Future<Void> handleError(Database cx, Reference<Task> task, Error const &error) {
|
||||
return BackupConfig(task).logError(cx, error, format("'%s' on '%s'", error.what(), task->params[Task::reservedTaskParamKeyType].printable().c_str()));
|
||||
}
|
||||
virtual std::string toString(Reference<Task> task)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
};
|
||||
Future<Void> handleError(Database cx, Reference<Task> task, Error const& error) override {
|
||||
return BackupConfig(task).logError(cx, error, format("'%s' on '%s'", error.what(), task->params[Task::reservedTaskParamKeyType].printable().c_str()));
|
||||
}
|
||||
std::string toString(Reference<Task> task) const override { return ""; }
|
||||
};
|
||||
|
||||
ACTOR static Future<Standalone<VectorRef<KeyRef>>> getBlockOfShards(Reference<ReadYourWritesTransaction> tr, Key beginKey, Key endKey, int limit) {
|
||||
|
||||
|
|
|
@ -1099,20 +1099,18 @@ ACTOR Future<CoordinatorsResult> changeQuorum(Database cx, Reference<IQuorumChan
|
|||
struct SpecifiedQuorumChange : IQuorumChange {
|
||||
vector<NetworkAddress> desired;
|
||||
explicit SpecifiedQuorumChange( vector<NetworkAddress> const& desired ) : desired(desired) {}
|
||||
virtual Future<vector<NetworkAddress>> getDesiredCoordinators(Transaction* tr,
|
||||
vector<NetworkAddress> oldCoordinators,
|
||||
Reference<ClusterConnectionFile>,
|
||||
CoordinatorsResult&) {
|
||||
Future<vector<NetworkAddress>> getDesiredCoordinators(Transaction* tr, vector<NetworkAddress> oldCoordinators,
|
||||
Reference<ClusterConnectionFile>,
|
||||
CoordinatorsResult&) override {
|
||||
return desired;
|
||||
}
|
||||
};
|
||||
Reference<IQuorumChange> specifiedQuorumChange(vector<NetworkAddress> const& addresses) { return Reference<IQuorumChange>(new SpecifiedQuorumChange(addresses)); }
|
||||
|
||||
struct NoQuorumChange : IQuorumChange {
|
||||
virtual Future<vector<NetworkAddress>> getDesiredCoordinators(Transaction* tr,
|
||||
vector<NetworkAddress> oldCoordinators,
|
||||
Reference<ClusterConnectionFile>,
|
||||
CoordinatorsResult&) {
|
||||
Future<vector<NetworkAddress>> getDesiredCoordinators(Transaction* tr, vector<NetworkAddress> oldCoordinators,
|
||||
Reference<ClusterConnectionFile>,
|
||||
CoordinatorsResult&) override {
|
||||
return oldCoordinators;
|
||||
}
|
||||
};
|
||||
|
@ -1122,15 +1120,12 @@ struct NameQuorumChange : IQuorumChange {
|
|||
std::string newName;
|
||||
Reference<IQuorumChange> otherChange;
|
||||
explicit NameQuorumChange( std::string const& newName, Reference<IQuorumChange> const& otherChange ) : newName(newName), otherChange(otherChange) {}
|
||||
virtual Future<vector<NetworkAddress>> getDesiredCoordinators(Transaction* tr,
|
||||
vector<NetworkAddress> oldCoordinators,
|
||||
Reference<ClusterConnectionFile> cf,
|
||||
CoordinatorsResult& t) {
|
||||
Future<vector<NetworkAddress>> getDesiredCoordinators(Transaction* tr, vector<NetworkAddress> oldCoordinators,
|
||||
Reference<ClusterConnectionFile> cf,
|
||||
CoordinatorsResult& t) override {
|
||||
return otherChange->getDesiredCoordinators(tr, oldCoordinators, cf, t);
|
||||
}
|
||||
virtual std::string getDesiredClusterKeyName() {
|
||||
return newName;
|
||||
}
|
||||
std::string getDesiredClusterKeyName() const override { return newName; }
|
||||
};
|
||||
Reference<IQuorumChange> nameQuorumChange(std::string const& name, Reference<IQuorumChange> const& other) {
|
||||
return Reference<IQuorumChange>(new NameQuorumChange( name, other ));
|
||||
|
@ -1140,10 +1135,9 @@ struct AutoQuorumChange : IQuorumChange {
|
|||
int desired;
|
||||
explicit AutoQuorumChange( int desired ) : desired(desired) {}
|
||||
|
||||
virtual Future<vector<NetworkAddress>> getDesiredCoordinators(Transaction* tr,
|
||||
vector<NetworkAddress> oldCoordinators,
|
||||
Reference<ClusterConnectionFile> ccf,
|
||||
CoordinatorsResult& err) {
|
||||
Future<vector<NetworkAddress>> getDesiredCoordinators(Transaction* tr, vector<NetworkAddress> oldCoordinators,
|
||||
Reference<ClusterConnectionFile> ccf,
|
||||
CoordinatorsResult& err) override {
|
||||
return getDesired( this, tr, oldCoordinators, ccf, &err );
|
||||
}
|
||||
|
||||
|
|
|
@ -38,19 +38,19 @@ public:
|
|||
future.callOrSetAsCallback(this, userParam, 0);
|
||||
}
|
||||
|
||||
virtual void cancel() {
|
||||
void cancel() override {
|
||||
cancelCallbacks();
|
||||
ThreadSingleAssignmentVar<T>::cancel();
|
||||
}
|
||||
|
||||
virtual void cleanupUnsafe() {
|
||||
void cleanupUnsafe() override {
|
||||
future.getPtr()->releaseMemory();
|
||||
ThreadSingleAssignmentVar<T>::cleanupUnsafe();
|
||||
}
|
||||
|
||||
bool canFire(int notMadeActive) { return true; }
|
||||
bool canFire(int notMadeActive) const override { return true; }
|
||||
|
||||
void fire(const Void &unused, int& userParam) {
|
||||
void fire(const Void& unused, int& userParam) override {
|
||||
lock.enter();
|
||||
if(!hasBeenSet) {
|
||||
hasBeenSet = true;
|
||||
|
@ -74,7 +74,7 @@ public:
|
|||
ThreadSingleAssignmentVar<T>::delref();
|
||||
}
|
||||
|
||||
void error(const Error& e, int& userParam) {
|
||||
void error(const Error& e, int& userParam) override {
|
||||
ASSERT(future.isError());
|
||||
lock.enter();
|
||||
if(!hasBeenSet) {
|
||||
|
@ -169,7 +169,7 @@ public:
|
|||
return destroyNow;
|
||||
}
|
||||
|
||||
virtual void cancel() {
|
||||
void cancel() override {
|
||||
if(addFutureRef()) {
|
||||
api->futureCancel(f);
|
||||
delFutureRef();
|
||||
|
@ -178,7 +178,7 @@ public:
|
|||
ThreadSingleAssignmentVar<T>::cancel();
|
||||
}
|
||||
|
||||
virtual void cleanupUnsafe() {
|
||||
void cleanupUnsafe() override {
|
||||
delFutureRef();
|
||||
ThreadSingleAssignmentVar<T>::cleanupUnsafe();
|
||||
}
|
||||
|
@ -233,25 +233,25 @@ public:
|
|||
source.callOrSetAsCallback(this, userParam, 0);
|
||||
}
|
||||
|
||||
virtual void cancel() {
|
||||
void cancel() override {
|
||||
source.getPtr()->addref(); // Cancel will delref our future, but we don't want to destroy it until this callback gets destroyed
|
||||
source.getPtr()->cancel();
|
||||
ThreadSingleAssignmentVar<T>::cancel();
|
||||
}
|
||||
|
||||
virtual void cleanupUnsafe() {
|
||||
void cleanupUnsafe() override {
|
||||
source.getPtr()->releaseMemory();
|
||||
ThreadSingleAssignmentVar<T>::cleanupUnsafe();
|
||||
}
|
||||
|
||||
bool canFire(int notMadeActive) { return true; }
|
||||
bool canFire(int notMadeActive) const override { return true; }
|
||||
|
||||
void fire(const Void &unused, int& userParam) {
|
||||
void fire(const Void& unused, int& userParam) override {
|
||||
sendResult(mapValue(source.get()));
|
||||
ThreadSingleAssignmentVar<T>::delref();
|
||||
}
|
||||
|
||||
void error(const Error& e, int& userParam) {
|
||||
void error(const Error& e, int& userParam) override {
|
||||
sendResult(mapValue(source.getError()));
|
||||
ThreadSingleAssignmentVar<T>::delref();
|
||||
}
|
||||
|
@ -285,7 +285,7 @@ public:
|
|||
source.callOrSetAsCallback(this, userParam, 0);
|
||||
}
|
||||
|
||||
virtual void cancel() {
|
||||
void cancel() override {
|
||||
source.getPtr()->addref(); // Cancel will delref our future, but we don't want to destroy it until this callback gets destroyed
|
||||
source.getPtr()->cancel();
|
||||
|
||||
|
@ -303,7 +303,7 @@ public:
|
|||
ThreadSingleAssignmentVar<T>::cancel();
|
||||
}
|
||||
|
||||
virtual void cleanupUnsafe() {
|
||||
void cleanupUnsafe() override {
|
||||
source.getPtr()->releaseMemory();
|
||||
|
||||
lock.enter();
|
||||
|
@ -319,9 +319,9 @@ public:
|
|||
ThreadSingleAssignmentVar<T>::cleanupUnsafe();
|
||||
}
|
||||
|
||||
bool canFire(int notMadeActive) { return true; }
|
||||
bool canFire(int notMadeActive) const override { return true; }
|
||||
|
||||
void fire(const Void &unused, int& userParam) {
|
||||
void fire(const Void& unused, int& userParam) override {
|
||||
if(mappedFuture.isValid()) {
|
||||
sendResult(mappedFuture.get());
|
||||
}
|
||||
|
@ -332,7 +332,7 @@ public:
|
|||
ThreadSingleAssignmentVar<T>::delref();
|
||||
}
|
||||
|
||||
void error(const Error& e, int& userParam) {
|
||||
void error(const Error& e, int& userParam) override {
|
||||
if(mappedFuture.isValid()) {
|
||||
sendResult(mappedFuture.getError());
|
||||
}
|
||||
|
|
|
@ -1440,14 +1440,14 @@ class ValidateFuture : public ThreadCallback {
|
|||
public:
|
||||
ValidateFuture(ThreadFuture<int> f, ErrorOr<int> expectedValue, std::set<int> legalErrors) : f(f), expectedValue(expectedValue), legalErrors(legalErrors) { }
|
||||
|
||||
virtual bool canFire(int notMadeActive) { return true; }
|
||||
bool canFire(int notMadeActive) const override { return true; }
|
||||
|
||||
virtual void fire(const Void &unused, int& userParam) {
|
||||
void fire(const Void& unused, int& userParam) override {
|
||||
ASSERT(!f.isError() && !expectedValue.isError() && f.get() == expectedValue.get());
|
||||
delete this;
|
||||
}
|
||||
|
||||
virtual void error(const Error& e, int& userParam) {
|
||||
void error(const Error& e, int& userParam) override {
|
||||
ASSERT(legalErrors.count(e.code()) > 0 || (f.isError() && expectedValue.isError() && f.getError().code() == expectedValue.getError().code()));
|
||||
delete this;
|
||||
}
|
||||
|
@ -1698,12 +1698,12 @@ public:
|
|||
CAPICallback(void (*callbackf)(FdbCApi::FDBFuture*, void*), FdbCApi::FDBFuture* f, void* userdata)
|
||||
: callbackf(callbackf), f(f), userdata(userdata) {}
|
||||
|
||||
virtual bool canFire(int notMadeActive) { return true; }
|
||||
virtual void fire(const Void& unused, int& userParam) {
|
||||
bool canFire(int notMadeActive) const override { return true; }
|
||||
void fire(const Void& unused, int& userParam) override {
|
||||
(*callbackf)(f, userdata);
|
||||
delete this;
|
||||
}
|
||||
virtual void error(const Error& e, int& userParam) {
|
||||
void error(const Error& e, int& userParam) override {
|
||||
(*callbackf)(f, userdata);
|
||||
delete this;
|
||||
}
|
||||
|
|
|
@ -318,9 +318,9 @@ private:
|
|||
void connect();
|
||||
void cancel();
|
||||
|
||||
bool canFire(int notMadeActive) { return true; }
|
||||
void fire(const Void &unused, int& userParam);
|
||||
void error(const Error& e, int& userParam);
|
||||
bool canFire(int notMadeActive) const override { return true; }
|
||||
void fire(const Void& unused, int& userParam) override;
|
||||
void error(const Error& e, int& userParam) override;
|
||||
|
||||
const Reference<ClientInfo> client;
|
||||
const std::string clusterFilePath;
|
||||
|
|
|
@ -48,14 +48,12 @@ void onMainThreadVoid( F f, Error* err, TaskPriority taskID = TaskPriority::Defa
|
|||
}
|
||||
|
||||
struct ThreadCallback {
|
||||
virtual bool canFire(int notMadeActive) = 0;
|
||||
virtual bool canFire(int notMadeActive) const = 0;
|
||||
virtual void fire(const Void &unused, int& userParam) = 0;
|
||||
virtual void error(const Error&, int& userParam) = 0;
|
||||
virtual ThreadCallback* addCallback(ThreadCallback *cb);
|
||||
|
||||
virtual bool contains(ThreadCallback *cb) {
|
||||
return false;
|
||||
}
|
||||
virtual bool contains(ThreadCallback* cb) const { return false; }
|
||||
|
||||
virtual void clearCallback(ThreadCallback *cb) {
|
||||
// If this is the only registered callback this will be called with (possibly) arbitrary pointers
|
||||
|
@ -69,22 +67,20 @@ struct ThreadCallback {
|
|||
}
|
||||
};
|
||||
|
||||
class ThreadMultiCallback : public ThreadCallback, public FastAllocated<ThreadMultiCallback> {
|
||||
class ThreadMultiCallback final : public ThreadCallback, public FastAllocated<ThreadMultiCallback> {
|
||||
public:
|
||||
ThreadMultiCallback() { }
|
||||
|
||||
virtual ThreadCallback* addCallback(ThreadCallback *callback) {
|
||||
ThreadCallback* addCallback(ThreadCallback* callback) override {
|
||||
UNSTOPPABLE_ASSERT(callbackMap.count(callback) == 0); //May be triggered by a waitForAll on a vector with the same future in it more than once
|
||||
callbackMap[callback] = callbacks.size();
|
||||
callbacks.push_back(callback);
|
||||
return (ThreadCallback*)this;
|
||||
}
|
||||
|
||||
virtual bool contains(ThreadCallback *cb) {
|
||||
return callbackMap.count(cb) != 0;
|
||||
}
|
||||
bool contains(ThreadCallback* cb) const override { return callbackMap.count(cb) != 0; }
|
||||
|
||||
virtual void clearCallback(ThreadCallback *callback) {
|
||||
void clearCallback(ThreadCallback* callback) override {
|
||||
auto it = callbackMap.find(callback);
|
||||
if (it == callbackMap.end())
|
||||
return;
|
||||
|
@ -100,11 +96,9 @@ public:
|
|||
callbackMap.erase(it);
|
||||
}
|
||||
|
||||
virtual bool canFire(int notMadeActive) {
|
||||
return true;
|
||||
}
|
||||
bool canFire(int notMadeActive) const override { return true; }
|
||||
|
||||
virtual void fire(const Void& value, int& loopDepth) {
|
||||
void fire(const Void& value, int& loopDepth) override {
|
||||
if (callbacks.size() > 10000)
|
||||
TraceEvent(SevWarn, "LargeMultiCallback").detail("CallbacksSize", callbacks.size());
|
||||
|
||||
|
@ -121,7 +115,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
virtual void error(const Error& err, int& loopDepth) {
|
||||
void error(const Error& err, int& loopDepth) override {
|
||||
if (callbacks.size() > 10000)
|
||||
TraceEvent(SevWarn, "LargeMultiCallback").detail("CallbacksSize", callbacks.size());
|
||||
|
||||
|
@ -138,14 +132,12 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
virtual void destroy() {
|
||||
void destroy() override {
|
||||
UNSTOPPABLE_ASSERT(callbacks.empty());
|
||||
delete this;
|
||||
}
|
||||
|
||||
virtual bool isMultiCallback() const {
|
||||
return true;
|
||||
}
|
||||
bool isMultiCallback() const override { return true; }
|
||||
|
||||
private:
|
||||
std::vector<ThreadCallback*> callbacks;
|
||||
|
@ -193,9 +185,9 @@ public:
|
|||
|
||||
BlockCallback( ThreadSingleAssignmentVarBase& sav ) { int ignore=0; sav.callOrSetAsCallback(this,ignore,0); ev.block(); }
|
||||
|
||||
virtual bool canFire(int notMadeActive) { return true; }
|
||||
virtual void fire(const Void &unused, int& userParam) { ev.set(); }
|
||||
virtual void error(const Error&, int& userParam) { ev.set(); }
|
||||
bool canFire(int notMadeActive) const override { return true; }
|
||||
void fire(const Void& unused, int& userParam) override { ev.set(); }
|
||||
void error(const Error&, int& userParam) override { ev.set(); }
|
||||
};
|
||||
|
||||
void blockUntilReady() {
|
||||
|
@ -378,15 +370,11 @@ public:
|
|||
return value;
|
||||
}
|
||||
|
||||
virtual void addref( ) {
|
||||
ThreadSafeReferenceCounted<ThreadSingleAssignmentVar<T>>::addref( );
|
||||
}
|
||||
void addref() override { ThreadSafeReferenceCounted<ThreadSingleAssignmentVar<T>>::addref(); }
|
||||
|
||||
virtual void delref( ) {
|
||||
ThreadSafeReferenceCounted<ThreadSingleAssignmentVar<T>>::delref( );
|
||||
}
|
||||
void delref() override { ThreadSafeReferenceCounted<ThreadSingleAssignmentVar<T>>::delref(); }
|
||||
|
||||
void send(const T& value) {
|
||||
void send(const T& value) override {
|
||||
if (TRACE_SAMPLE()) TraceEvent(SevSample, "Promise_send");
|
||||
this->mutex.enter();
|
||||
if (!canBeSetUnsafe()) {
|
||||
|
@ -415,7 +403,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
virtual void cleanupUnsafe() {
|
||||
void cleanupUnsafe() override {
|
||||
value = T();
|
||||
ThreadSingleAssignmentVarBase::cleanupUnsafe();
|
||||
}
|
||||
|
@ -531,18 +519,16 @@ struct CompletionCallback : public ThreadCallback, ReferenceCounted<CompletionCa
|
|||
this->threadFuture = threadFuture;
|
||||
}
|
||||
|
||||
bool canFire(int notMadeActive) {
|
||||
return true;
|
||||
}
|
||||
bool canFire(int notMadeActive) const override { return true; }
|
||||
|
||||
//Trigger the promise
|
||||
void fire(const Void& unused, int& userParam) {
|
||||
void fire(const Void& unused, int& userParam) override {
|
||||
promise.send(threadFuture.get());
|
||||
self.clear();
|
||||
}
|
||||
|
||||
//Send the error through the promise
|
||||
void error(const Error& e, int& userParam) {
|
||||
void error(const Error& e, int& userParam) override {
|
||||
promise.sendError(e);
|
||||
self.clear();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue