diff --git a/fdbcli/FlowLineNoise.actor.cpp b/fdbcli/FlowLineNoise.actor.cpp index dad4213671..8725a7255b 100644 --- a/fdbcli/FlowLineNoise.actor.cpp +++ b/fdbcli/FlowLineNoise.actor.cpp @@ -39,15 +39,15 @@ struct LineNoiseReader final : IThreadPoolReceiver { void init() override {} - struct Read : TypedAction { - std::string prompt; + struct Read final : TypedAction { + std::string prompt; ThreadReturnPromise> result; double getTimeEstimate() const override { return 0.0; } explicit Read(std::string const& prompt) : prompt(prompt) {} - }; + }; - void action(Read& r) { + void action(Read& r) { try { r.result.send( read(r.prompt) ); } catch (Error& e) { diff --git a/fdbclient/BackupContainer.actor.cpp b/fdbclient/BackupContainer.actor.cpp index cb8ba02f8e..223ef1949b 100644 --- a/fdbclient/BackupContainer.actor.cpp +++ b/fdbclient/BackupContainer.actor.cpp @@ -1837,7 +1837,7 @@ private: std::string m_path; }; -class BackupContainerBlobStore : public BackupContainerFileSystem, ReferenceCounted { +class BackupContainerBlobStore final : public BackupContainerFileSystem, ReferenceCounted { private: // Backup files to under a single folder prefix with subfolders for each named backup static const std::string DATAFOLDER; @@ -1877,15 +1877,13 @@ public: } } - void addref() final { return ReferenceCounted::addref(); } - void delref() final { return ReferenceCounted::delref(); } + void addref() override { return ReferenceCounted::addref(); } + void delref() override { return ReferenceCounted::delref(); } static std::string getURLFormat() { return BlobStoreEndpoint::getURLFormat(true) + " (Note: The 'bucket' parameter is required.)"; } - ~BackupContainerBlobStore() = default; - Future> readFile(std::string path) final { return Reference( new AsyncFileReadAheadCache( diff --git a/fdbclient/FileBackupAgent.actor.cpp b/fdbclient/FileBackupAgent.actor.cpp index b3daf35678..b8bbab844c 100644 --- a/fdbclient/FileBackupAgent.actor.cpp +++ b/fdbclient/FileBackupAgent.actor.cpp @@ -940,17 +940,17 @@ 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 { - Future handleError(Database cx, Reference task, Error const& error) override { + Future handleError(Database cx, Reference task, Error const& error) final 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) const override { return ""; } + virtual std::string toString(Reference task) const override { return ""; } }; struct BackupTaskFuncBase : TaskFuncBase { - Future handleError(Database cx, Reference task, Error const& error) override { + Future handleError(Database cx, Reference task, Error const& error) final 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) const override { return ""; } + virtual std::string toString(Reference task) const override { return ""; } }; ACTOR static Future>> getBlockOfShards(Reference tr, Key beginKey, Key endKey, int limit) { @@ -984,15 +984,15 @@ namespace fileBackup { } } Params; - std::string toString(Reference task) { - return format("beginKey '%s' endKey '%s' addTasks %d", + std::string toString(Reference task) const override { + return format("beginKey '%s' endKey '%s' addTasks %d", Params.beginKey().get(task).printable().c_str(), Params.endKey().get(task).printable().c_str(), Params.addBackupRangeTasks().get(task) ); - } + } - StringRef getName() const { return name; }; + StringRef getName() const { return name; }; Future execute(Database cx, Reference tb, Reference fb, Reference task) { return _execute(cx, tb, fb, task); }; Future finish(Reference tr, Reference tb, Reference fb, Reference task) { return _finish(tr, tb, fb, task); }; @@ -2589,13 +2589,13 @@ namespace fileBackup { static TaskParam readLen() { return LiteralStringRef(__FUNCTION__); } } Params; - std::string toString(Reference task) { - return format("fileName '%s' readLen %lld readOffset %lld", + std::string toString(Reference task) const override { + return format("fileName '%s' readLen %lld readOffset %lld", Params.inputFile().get(task).fileName.c_str(), Params.readLen().get(task), Params.readOffset().get(task)); - } - }; + } + }; struct RestoreRangeTaskFunc : RestoreFileTaskFuncBase { static struct : InputParams { @@ -2616,14 +2616,14 @@ namespace fileBackup { } } Params; - std::string toString(Reference task) { - std::string returnStr = RestoreFileTaskFuncBase::toString(task); + std::string toString(Reference task) const override { + std::string returnStr = RestoreFileTaskFuncBase::toString(task); for(auto &range : Params.getOriginalFileRanges(task)) returnStr += format(" originalFileRange '%s'", printable(range).c_str()); return returnStr; - } + } - ACTOR static Future _execute(Database cx, Reference taskBucket, Reference futureBucket, Reference task) { + ACTOR static Future _execute(Database cx, Reference taskBucket, Reference futureBucket, Reference task) { state RestoreConfig restore(task); state RestoreFile rangeFile = Params.inputFile().get(task); diff --git a/fdbclient/ManagementAPI.actor.cpp b/fdbclient/ManagementAPI.actor.cpp index ff1f367567..cca55fafcc 100644 --- a/fdbclient/ManagementAPI.actor.cpp +++ b/fdbclient/ManagementAPI.actor.cpp @@ -1096,7 +1096,7 @@ ACTOR Future changeQuorum(Database cx, Reference desired; explicit SpecifiedQuorumChange( vector const& desired ) : desired(desired) {} Future> getDesiredCoordinators(Transaction* tr, vector oldCoordinators, @@ -1107,7 +1107,7 @@ struct SpecifiedQuorumChange : IQuorumChange { }; Reference specifiedQuorumChange(vector const& addresses) { return Reference(new SpecifiedQuorumChange(addresses)); } -struct NoQuorumChange : IQuorumChange { +struct NoQuorumChange final : IQuorumChange { Future> getDesiredCoordinators(Transaction* tr, vector oldCoordinators, Reference, CoordinatorsResult&) override { @@ -1116,7 +1116,7 @@ struct NoQuorumChange : IQuorumChange { }; Reference noQuorumChange() { return Reference(new NoQuorumChange); } -struct NameQuorumChange : IQuorumChange { +struct NameQuorumChange final : IQuorumChange { std::string newName; Reference otherChange; explicit NameQuorumChange( std::string const& newName, Reference const& otherChange ) : newName(newName), otherChange(otherChange) {} @@ -1131,7 +1131,7 @@ Reference nameQuorumChange(std::string const& name, Reference(new NameQuorumChange( name, other )); } -struct AutoQuorumChange : IQuorumChange { +struct AutoQuorumChange final : IQuorumChange { int desired; explicit AutoQuorumChange( int desired ) : desired(desired) {} diff --git a/fdbclient/MultiVersionAssignmentVars.h b/fdbclient/MultiVersionAssignmentVars.h index 2c72747f8a..b270198ecf 100644 --- a/fdbclient/MultiVersionAssignmentVars.h +++ b/fdbclient/MultiVersionAssignmentVars.h @@ -24,8 +24,8 @@ #include "flow/ThreadHelper.actor.h" -template -class AbortableSingleAssignmentVar : public ThreadSingleAssignmentVar, public ThreadCallback { +template +class AbortableSingleAssignmentVar final : public ThreadSingleAssignmentVar, public ThreadCallback { public: AbortableSingleAssignmentVar(ThreadFuture future, ThreadFuture abortSignal) : future(future), abortSignal(abortSignal), hasBeenSet(false), callbacksCleared(false) { int userParam; @@ -124,8 +124,8 @@ ThreadFuture abortableFuture(ThreadFuture f, ThreadFuture abortSigna return ThreadFuture(new AbortableSingleAssignmentVar(f, abortSignal)); } -template -class DLThreadSingleAssignmentVar : public ThreadSingleAssignmentVar { +template +class DLThreadSingleAssignmentVar final : public ThreadSingleAssignmentVar { public: DLThreadSingleAssignmentVar(Reference api, FdbCApi::FDBFuture *f, std::function extractValue) : api(api), f(f), extractValue(extractValue), futureRefCount(1) { ThreadSingleAssignmentVar::addref(); @@ -223,8 +223,8 @@ ThreadFuture toThreadFuture(Reference api, FdbCApi::FDBFuture *f, st return ThreadFuture(new DLThreadSingleAssignmentVar(api, f, extractValue)); } -template -class MapSingleAssignmentVar : public ThreadSingleAssignmentVar, ThreadCallback { +template +class MapSingleAssignmentVar final : public ThreadSingleAssignmentVar, ThreadCallback { public: MapSingleAssignmentVar(ThreadFuture source, std::function(ErrorOr)> mapValue) : source(source), mapValue(mapValue) { ThreadSingleAssignmentVar::addref(); @@ -275,8 +275,8 @@ ThreadFuture mapThreadFuture(ThreadFuture source, std::function return ThreadFuture(new MapSingleAssignmentVar(source, mapValue)); } -template -class FlatMapSingleAssignmentVar : public ThreadSingleAssignmentVar, ThreadCallback { +template +class FlatMapSingleAssignmentVar final : public ThreadSingleAssignmentVar, ThreadCallback { public: FlatMapSingleAssignmentVar(ThreadFuture source, std::function>(ErrorOr)> mapValue) : source(source), mapValue(mapValue), cancelled(false), released(false) { ThreadSingleAssignmentVar::addref(); diff --git a/fdbclient/MultiVersionTransaction.actor.cpp b/fdbclient/MultiVersionTransaction.actor.cpp index db6d8ca33c..63c1f4d498 100644 --- a/fdbclient/MultiVersionTransaction.actor.cpp +++ b/fdbclient/MultiVersionTransaction.actor.cpp @@ -1436,7 +1436,7 @@ TEST_CASE("/fdbclient/multiversionclient/EnvironmentVariableParsing" ) { return Void(); } -class ValidateFuture : public ThreadCallback { +class ValidateFuture final : public ThreadCallback { public: ValidateFuture(ThreadFuture f, ErrorOr expectedValue, std::set legalErrors) : f(f), expectedValue(expectedValue), legalErrors(legalErrors) { } @@ -1693,7 +1693,7 @@ TEST_CASE("/fdbclient/multiversionclient/AbortableSingleAssignmentVar" ) { return Void(); } -class CAPICallback : public ThreadCallback { +class CAPICallback final : public ThreadCallback { public: CAPICallback(void (*callbackf)(FdbCApi::FDBFuture*, void*), FdbCApi::FDBFuture* f, void* userdata) : callbackf(callbackf), f(f), userdata(userdata) {} diff --git a/fdbclient/MultiVersionTransaction.h b/fdbclient/MultiVersionTransaction.h index 8ee93668fe..1a24e39c5f 100644 --- a/fdbclient/MultiVersionTransaction.h +++ b/fdbclient/MultiVersionTransaction.h @@ -296,7 +296,7 @@ struct ClientInfo : ThreadSafeReferenceCounted { class MultiVersionApi; -class MultiVersionDatabase : public IDatabase, ThreadSafeReferenceCounted { +class MultiVersionDatabase final : public IDatabase, ThreadSafeReferenceCounted { public: MultiVersionDatabase(MultiVersionApi *api, std::string clusterFilePath, Reference db, bool openConnectors=true); ~MultiVersionDatabase(); diff --git a/fdbrpc/sim2.actor.cpp b/fdbrpc/sim2.actor.cpp index b1d4302e6f..31fd84d3d7 100644 --- a/fdbrpc/sim2.actor.cpp +++ b/fdbrpc/sim2.actor.cpp @@ -687,7 +687,7 @@ struct SimDiskSpace { void doReboot( ISimulator::ProcessInfo* const& p, ISimulator::KillType const& kt ); -struct Sim2Listener : IListener, ReferenceCounted { +struct Sim2Listener final : IListener, ReferenceCounted { explicit Sim2Listener( ISimulator::ProcessInfo* process, const NetworkAddress& listenAddr ) : process(process), address(listenAddr) {} @@ -728,7 +728,7 @@ private: #define g_sim2 ((Sim2&)g_simulator) -class Sim2 : public ISimulator, public INetworkConnections { +class Sim2 final : public ISimulator, public INetworkConnections { public: // Implement INetwork interface // Everything actually network related is delegated to the Sim2Net class; Sim2 is only concerned with simulating machines and time diff --git a/fdbserver/CoroFlow.actor.cpp b/fdbserver/CoroFlow.actor.cpp index 6cf9e1dabc..6353c60d81 100644 --- a/fdbserver/CoroFlow.actor.cpp +++ b/fdbserver/CoroFlow.actor.cpp @@ -94,7 +94,7 @@ private: }; template -class WorkPool : public IThreadPool, public ReferenceCounted> { +class WorkPool final : public IThreadPool, public ReferenceCounted> { struct Worker; // Pool can survive the destruction of WorkPool while it waits for workers to terminate diff --git a/fdbserver/DataDistribution.actor.cpp b/fdbserver/DataDistribution.actor.cpp index 99878fe504..3b5b6060f1 100644 --- a/fdbserver/DataDistribution.actor.cpp +++ b/fdbserver/DataDistribution.actor.cpp @@ -158,7 +158,7 @@ public: }; // TeamCollection's server team info. -class TCTeamInfo : public ReferenceCounted, public IDataDistributionTeam { +class TCTeamInfo final : public ReferenceCounted, public IDataDistributionTeam { vector< Reference > servers; vector serverIDs; bool healthy; diff --git a/fdbserver/DataDistributionQueue.actor.cpp b/fdbserver/DataDistributionQueue.actor.cpp index 2dc25196e8..230a52636b 100644 --- a/fdbserver/DataDistributionQueue.actor.cpp +++ b/fdbserver/DataDistributionQueue.actor.cpp @@ -82,7 +82,7 @@ struct RelocateData { bool operator!=(const RelocateData& rhs) const { return !(*this == rhs); } }; -class ParallelTCInfo : public ReferenceCounted, public IDataDistributionTeam { +class ParallelTCInfo final : public ReferenceCounted, public IDataDistributionTeam { vector> teams; int64_t sum(std::function func) const { diff --git a/fdbserver/TLogServer.actor.cpp b/fdbserver/TLogServer.actor.cpp index 1f5de7f727..0d203dc4b9 100644 --- a/fdbserver/TLogServer.actor.cpp +++ b/fdbserver/TLogServer.actor.cpp @@ -103,7 +103,7 @@ typedef Standalone TLogQueueEntry; struct LogData; struct TLogData; -struct TLogQueue : public IClosable { +struct TLogQueue final : public IClosable { public: TLogQueue( IDiskQueue* queue, UID dbgid ) : queue(queue), dbgid(dbgid) {} diff --git a/fdbserver/VersionedBTree.actor.cpp b/fdbserver/VersionedBTree.actor.cpp index f38c4dab8f..5b2f2e5682 100644 --- a/fdbserver/VersionedBTree.actor.cpp +++ b/fdbserver/VersionedBTree.actor.cpp @@ -2974,7 +2974,7 @@ struct InPlaceArray { }; #pragma pack(pop) -class VersionedBTree : public IVersionedStore { +class VersionedBTree final : public IVersionedStore { public: // The first possible internal record possible in the tree static RedwoodRecordRef dbBegin; diff --git a/flow/IThreadPool.cpp b/flow/IThreadPool.cpp index 77949e6f50..fb99fa79e2 100644 --- a/flow/IThreadPool.cpp +++ b/flow/IThreadPool.cpp @@ -27,8 +27,7 @@ #include "boost/asio.hpp" #include "boost/bind.hpp" - -class ThreadPool : public IThreadPool, public ReferenceCounted { +class ThreadPool final : public IThreadPool, public ReferenceCounted { struct Thread { ThreadPool *pool; IThreadPoolReceiver* userObject; @@ -103,7 +102,6 @@ public: void post(PThreadAction action) override { ios.post(ActionWrapper(action)); } }; - Reference createGenericThreadPool(int stackSize) { return Reference( new ThreadPool(stackSize) ); diff --git a/flow/IThreadPool.h b/flow/IThreadPool.h index 600d4055f8..160c567a92 100644 --- a/flow/IThreadPool.h +++ b/flow/IThreadPool.h @@ -109,7 +109,7 @@ private: Reference createGenericThreadPool(int stackSize = 0); -class DummyThreadPool : public IThreadPool, ReferenceCounted { +class DummyThreadPool final : public IThreadPool, ReferenceCounted { public: ~DummyThreadPool() {} DummyThreadPool() : thread(nullptr) {} @@ -142,6 +142,4 @@ private: Promise errors; }; - - #endif diff --git a/flow/Net2.actor.cpp b/flow/Net2.actor.cpp index cdd364d1c2..686ec82378 100644 --- a/flow/Net2.actor.cpp +++ b/flow/Net2.actor.cpp @@ -537,7 +537,7 @@ struct SSLHandshakerThread : IThreadPoolReceiver { SSLHandshakerThread() {} virtual void init() {} - struct Handshake : TypedAction { + struct Handshake final : TypedAction { Handshake(ssl_socket &socket, ssl_socket::handshake_type type) : socket(socket), type(type) { } double getTimeEstimate() const override { return 0.001; } diff --git a/flow/Trace.cpp b/flow/Trace.cpp index 53dfa9e03d..6475eb1afe 100644 --- a/flow/Trace.cpp +++ b/flow/Trace.cpp @@ -201,7 +201,7 @@ public: Reference barriers; - struct WriterThread : IThreadPoolReceiver { + struct WriterThread final : IThreadPoolReceiver { WriterThread( Reference barriers, Reference logWriter, Reference formatter ) : barriers(barriers), logWriter(logWriter), formatter(formatter) {} @@ -211,7 +211,7 @@ public: Reference formatter; Reference barriers; - struct Open : TypedAction { + struct Open final : TypedAction { double getTimeEstimate() const override { return 0; } }; void action( Open& o ) { @@ -219,7 +219,7 @@ public: logWriter->write(formatter->getHeader()); } - struct Close : TypedAction { + struct Close final : TypedAction { double getTimeEstimate() const override { return 0; } }; void action( Close& c ) { @@ -227,7 +227,7 @@ public: logWriter->close(); } - struct Roll : TypedAction { + struct Roll final : TypedAction { double getTimeEstimate() const override { return 0; } }; void action( Roll& c ) { @@ -236,14 +236,14 @@ public: logWriter->write(formatter->getHeader()); } - struct Barrier : TypedAction { + struct Barrier final : TypedAction { double getTimeEstimate() const override { return 0; } }; void action( Barrier& a ) { barriers->pop(); } - struct WriteBuffer : TypedAction { + struct WriteBuffer final : TypedAction { std::vector events; WriteBuffer(std::vector events) : events(events) {} @@ -260,7 +260,7 @@ public: } } - struct Ping : TypedAction { + struct Ping final : TypedAction { ThreadReturnPromise ack; explicit Ping(){}; diff --git a/flow/flow.h b/flow/flow.h index 8f501f6292..22d92d9c0a 100644 --- a/flow/flow.h +++ b/flow/flow.h @@ -534,8 +534,8 @@ public: int getFutureReferenceCount() const { return futures; } int getPromiseReferenceCount() const { return promises; } - void destroy() override { delete this; } - void cancel() override {} + virtual void destroy() override { delete this; } + virtual void cancel() override {} void addCallbackAndDelFutureRef(Callback* cb) { // We are always *logically* dropping one future reference from this, but if we are adding a first callback