diff --git a/fdbclient/AsyncFileBlobStore.actor.cpp b/fdbclient/AsyncFileBlobStore.actor.cpp index 9dd87263dd..a12317f8f8 100644 --- a/fdbclient/AsyncFileBlobStore.actor.cpp +++ b/fdbclient/AsyncFileBlobStore.actor.cpp @@ -23,7 +23,7 @@ #include "flow/UnitTest.h" #include "flow/actorcompiler.h" // has to be last include -Future AsyncFileBlobStoreRead::size() { +Future AsyncFileBlobStoreRead::size() const { if(!m_size.isValid()) m_size = m_bstore->objectSize(m_bucket, m_object); return m_size; diff --git a/fdbclient/AsyncFileBlobStore.actor.h b/fdbclient/AsyncFileBlobStore.actor.h index 980e211a98..681c28ac6a 100644 --- a/fdbclient/AsyncFileBlobStore.actor.h +++ b/fdbclient/AsyncFileBlobStore.actor.h @@ -92,7 +92,7 @@ public: MD5_CTX content_md5_buf; }; - virtual Future read( void *data, int length, int64_t offset ) { throw file_not_readable(); } + Future read(void* data, int length, int64_t offset) override { throw file_not_readable(); } ACTOR static Future write_impl(Reference f, const uint8_t *data, int length) { state Part *p = f->m_parts.back().getPtr(); @@ -115,7 +115,7 @@ public: return Void(); } - virtual Future write( void const *data, int length, int64_t offset ) { + Future write(void const* data, int length, int64_t offset) override { if(offset != m_cursor) throw non_sequential_op(); m_cursor += length; @@ -123,7 +123,7 @@ public: return m_error.getFuture() || write_impl(Reference::addRef(this), (const uint8_t *)data, length); } - virtual Future truncate( int64_t size ) { + Future truncate(int64_t size) override { if(size != m_cursor) return non_sequential_op(); return Void(); @@ -165,7 +165,7 @@ public: } // Ready once all data has been sent AND acknowledged from the remote side - virtual Future sync() { + Future sync() override { // Only initiate the finish operation once, and also prevent further writing. if(!m_finished.isValid()) { m_finished = doFinishUpload(this); @@ -182,25 +182,25 @@ public: // their size. So in the case of a write buffer that does not meet the part minimum size the part could be sent // but then if there is any more data written then that part needs to be sent again in its entirety. So a client // that calls flush often could generate far more blob store write traffic than they intend to. - virtual Future flush() { return Void(); } + Future flush() override { return Void(); } - virtual Future size() { return m_cursor; } + Future size() const override { return m_cursor; } - virtual Future readZeroCopy( void** data, int* length, int64_t offset ) { + Future readZeroCopy(void** data, int* length, int64_t offset) override { TraceEvent(SevError, "ReadZeroCopyNotSupported").detail("FileType", "BlobStoreWrite"); return platform_error(); } - virtual void releaseZeroCopy( void* data, int length, int64_t offset ) {} + void releaseZeroCopy(void* data, int length, int64_t offset) override {} - virtual int64_t debugFD() { return -1; } + int64_t debugFD() const override { return -1; } - virtual ~AsyncFileBlobStoreWrite() { + ~AsyncFileBlobStoreWrite() override { m_upload_id.cancel(); m_finished.cancel(); m_parts.clear(); // Contains futures } - virtual std::string getFilename() { return m_object; } + std::string getFilename() const override { return m_object; } private: Reference m_bstore; @@ -259,32 +259,32 @@ public: virtual void addref() { ReferenceCounted::addref(); } virtual void delref() { ReferenceCounted::delref(); } - virtual Future read( void *data, int length, int64_t offset ); + Future read(void* data, int length, int64_t offset) override; - virtual Future write( void const *data, int length, int64_t offset ) { throw file_not_writable(); } - virtual Future truncate( int64_t size ) { throw file_not_writable(); } + Future write(void const* data, int length, int64_t offset) override { throw file_not_writable(); } + Future truncate(int64_t size) override { throw file_not_writable(); } - virtual Future sync() { return Void(); } - virtual Future flush() { return Void(); } + Future sync() override { return Void(); } + Future flush() override { return Void(); } - virtual Future size(); + Future size() const override; - virtual Future readZeroCopy( void** data, int* length, int64_t offset ) { + Future readZeroCopy(void** data, int* length, int64_t offset) override { TraceEvent(SevError, "ReadZeroCopyNotSupported").detail("FileType", "BlobStoreRead"); return platform_error(); } - virtual void releaseZeroCopy( void* data, int length, int64_t offset ) {} + void releaseZeroCopy(void* data, int length, int64_t offset) override {} - virtual int64_t debugFD() { return -1; } + int64_t debugFD() const override { return -1; } - virtual std::string getFilename() { return m_object; } + std::string getFilename() const override { return m_object; } virtual ~AsyncFileBlobStoreRead() {} Reference m_bstore; std::string m_bucket; std::string m_object; - Future m_size; + mutable Future m_size; AsyncFileBlobStoreRead(Reference bstore, std::string bucket, std::string object) : m_bstore(bstore), m_bucket(bucket), m_object(object) { diff --git a/fdbrpc/AsyncFileCached.actor.h b/fdbrpc/AsyncFileCached.actor.h index 28d4e61ff4..5ab91ff860 100644 --- a/fdbrpc/AsyncFileCached.actor.h +++ b/fdbrpc/AsyncFileCached.actor.h @@ -160,7 +160,7 @@ public: return openFiles[filename].get(); } - virtual Future read( void* data, int length, int64_t offset ) { + Future read(void* data, int length, int64_t offset) override { ++countFileCacheReads; ++countCacheReads; if (offset + length > this->length) { @@ -190,17 +190,15 @@ public: return Void(); } - virtual Future write( void const* data, int length, int64_t offset ) { + Future write(void const* data, int length, int64_t offset) override { return write_impl(this, data, length, offset); } - virtual Future readZeroCopy( void** data, int* length, int64_t offset ); - virtual void releaseZeroCopy( void* data, int length, int64_t offset ); + Future readZeroCopy(void** data, int* length, int64_t offset) override; + void releaseZeroCopy(void* data, int length, int64_t offset) override; // This waits for previously started truncates to finish and then truncates - virtual Future truncate( int64_t size ) { - return truncate_impl(this, size); - } + Future truncate(int64_t size) override { return truncate_impl(this, size); } // This is the 'real' truncate that does the actual removal of cache blocks and then shortens the file Future changeFileSize( int64_t size ); @@ -215,21 +213,13 @@ public: return Void(); } - virtual Future sync() { - return waitAndSync( this, flush() ); - } + Future sync() override { return waitAndSync(this, flush()); } - virtual Future size() { - return length; - } + Future size() const override { return length; } - virtual int64_t debugFD() { - return uncached->debugFD(); - } + int64_t debugFD() const override { return uncached->debugFD(); } - virtual std::string getFilename() { - return filename; - } + std::string getFilename() const override { return filename; } virtual void addref() { ReferenceCounted::addref(); @@ -337,7 +327,7 @@ private: } } - virtual Future flush(); + Future flush() override; Future quiesce(); @@ -356,7 +346,7 @@ private: }; struct AFCPage : public EvictablePage, public FastAllocated { - virtual bool evict() { + bool evict() override { if ( notReading.isReady() && notFlushing.isReady() && !dirty && !zeroCopyRefCount && !truncated ) { owner->remove_page( this ); delete this; diff --git a/fdbrpc/AsyncFileEIO.actor.h b/fdbrpc/AsyncFileEIO.actor.h index 4284c1a427..683572faa3 100644 --- a/fdbrpc/AsyncFileEIO.actor.h +++ b/fdbrpc/AsyncFileEIO.actor.h @@ -115,26 +115,26 @@ public: virtual void addref() { ReferenceCounted::addref(); } virtual void delref() { ReferenceCounted::delref(); } - virtual int64_t debugFD() { return fd; } + int64_t debugFD() const override { return fd; } - virtual Future read( void* data, int length, int64_t offset ) { + Future read(void* data, int length, int64_t offset) override { ++countFileLogicalReads; ++countLogicalReads; return read_impl(fd, data, length, offset); } - virtual Future write( void const* data, int length, int64_t offset ) // Copies data synchronously + Future write(void const* data, int length, int64_t offset) override // Copies data synchronously { ++countFileLogicalWrites; ++countLogicalWrites; //Standalone copy = StringRef((const uint8_t*)data, length); return write_impl( fd, err, StringRef((const uint8_t*)data, length), offset ); } - virtual Future truncate( int64_t size ) { + Future truncate(int64_t size) override { ++countFileLogicalWrites; ++countLogicalWrites; return truncate_impl( fd, err, size ); } - virtual Future sync() { + Future sync() override { ++countFileLogicalWrites; ++countLogicalWrites; auto fsync = sync_impl( fd, err ); @@ -147,14 +147,12 @@ public: return fsync; } - virtual Future size() { + Future size() const override { ++countFileLogicalReads; ++countLogicalReads; return size_impl(fd); } - virtual std::string getFilename() { - return filename; - } + std::string getFilename() const override { return filename; } ACTOR static Future async_fsync_parent( std::string filename ) { std::string folder = parentDirectory( filename ); @@ -227,11 +225,11 @@ private: int fd, flags; Reference err; std::string filename; - Int64MetricHandle countFileLogicalWrites; - Int64MetricHandle countFileLogicalReads; + mutable Int64MetricHandle countFileLogicalWrites; + mutable Int64MetricHandle countFileLogicalReads; - Int64MetricHandle countLogicalWrites; - Int64MetricHandle countLogicalReads; + mutable Int64MetricHandle countLogicalWrites; + mutable Int64MetricHandle countLogicalReads; AsyncFileEIO( int fd, int flags, std::string const& filename ) : fd(fd), flags(flags), filename(filename), err(new ErrorInfo) { if( !g_network->isSimulated() ) { diff --git a/fdbrpc/AsyncFileKAIO.actor.h b/fdbrpc/AsyncFileKAIO.actor.h index 6f9f781862..876a64be74 100644 --- a/fdbrpc/AsyncFileKAIO.actor.h +++ b/fdbrpc/AsyncFileKAIO.actor.h @@ -182,7 +182,7 @@ public: virtual void addref() { ReferenceCounted::addref(); } virtual void delref() { ReferenceCounted::delref(); } - virtual Future read( void* data, int length, int64_t offset ) { + Future read(void* data, int length, int64_t offset) override { ++countFileLogicalReads; ++countLogicalReads; //printf("%p Begin logical read\n", getCurrentCoro()); @@ -205,7 +205,7 @@ public: return result; } - virtual Future write( void const* data, int length, int64_t offset ) { + Future write(void const* data, int length, int64_t offset) override { ++countFileLogicalWrites; ++countLogicalWrites; //printf("%p Begin logical write\n", getCurrentCoro()); @@ -234,7 +234,7 @@ public: #ifndef FALLOC_FL_ZERO_RANGE #define FALLOC_FL_ZERO_RANGE 0x10 #endif - virtual Future zeroRange( int64_t offset, int64_t length ) override { + Future zeroRange(int64_t offset, int64_t length) override { bool success = false; if (ctx.fallocateZeroSupported) { int rc = fallocate( fd, FALLOC_FL_ZERO_RANGE, offset, length ); @@ -247,7 +247,7 @@ public: } return success ? Void() : IAsyncFile::zeroRange(offset, length); } - virtual Future truncate( int64_t size ) { + Future truncate(int64_t size) override { ++countFileLogicalWrites; ++countLogicalWrites; @@ -308,7 +308,7 @@ public: return Void(); } - virtual Future sync() { + Future sync() override { ++countFileLogicalWrites; ++countLogicalWrites; @@ -340,13 +340,9 @@ public: return fsync; } - virtual Future size() { return nextFileSize; } - virtual int64_t debugFD() { - return fd; - } - virtual std::string getFilename() { - return filename; - } + Future size() const override { return nextFileSize; } + int64_t debugFD() const override { return fd; } + std::string getFilename() const override { return filename; } ~AsyncFileKAIO() { close(fd); diff --git a/fdbrpc/AsyncFileNonDurable.actor.h b/fdbrpc/AsyncFileNonDurable.actor.h index 7e8e551b3e..4b86f9776f 100644 --- a/fdbrpc/AsyncFileNonDurable.actor.h +++ b/fdbrpc/AsyncFileNonDurable.actor.h @@ -87,42 +87,42 @@ public: ReferenceCounted::delref(); } - Future read(void *data, int length, int64_t offset) { + Future read(void* data, int length, int64_t offset) override { if( !file.getPtr() || g_simulator.getCurrentProcess()->shutdownSignal.getFuture().isReady() ) return io_error().asInjectedFault(); return sendErrorOnShutdown( file->read( data, length, offset ) ); } - Future write(void const *data, int length, int64_t offset) { + Future write(void const* data, int length, int64_t offset) override { if( !file.getPtr() || g_simulator.getCurrentProcess()->shutdownSignal.getFuture().isReady() ) return io_error().asInjectedFault(); return sendErrorOnShutdown( file->write( data, length, offset ) ); } - - Future truncate(int64_t size) { + + Future truncate(int64_t size) override { if( !file.getPtr() || g_simulator.getCurrentProcess()->shutdownSignal.getFuture().isReady() ) return io_error().asInjectedFault(); return sendErrorOnShutdown( file->truncate( size ) ); } - Future sync() { + Future sync() override { if( !file.getPtr() || g_simulator.getCurrentProcess()->shutdownSignal.getFuture().isReady() ) return io_error().asInjectedFault(); return sendErrorOnShutdown( file->sync() ); } - Future size() { + Future size() const override { if( !file.getPtr() || g_simulator.getCurrentProcess()->shutdownSignal.getFuture().isReady() ) return io_error().asInjectedFault(); return sendErrorOnShutdown( file->size() ); } - int64_t debugFD() { + int64_t debugFD() const override { if( !file.getPtr() ) throw io_error().asInjectedFault(); return file->debugFD(); } - std::string getFilename() { + std::string getFilename() const override { if( !file.getPtr() ) throw io_error().asInjectedFault(); return file->getFilename(); @@ -137,7 +137,7 @@ public: std::string filename; //An approximation of the size of the file; .size() should be used instead of this variable in most cases - int64_t approximateSize; + mutable int64_t approximateSize; //The address of the machine that opened the file NetworkAddress openedAddress; @@ -263,13 +263,11 @@ public: } //Passes along reads straight to the underlying file, waiting for any outstanding changes that could affect the results - Future read(void *data, int length, int64_t offset) { - return read(this, data, length, offset); - } + Future read(void* data, int length, int64_t offset) override { return read(this, data, length, offset); } //Writes data to the file. Writes are delayed a random amount of time before being //passed to the underlying file - Future write(void const *data, int length, int64_t offset) { + Future write(void const* data, int length, int64_t offset) override { //TraceEvent("AsyncFileNonDurable_Write", id).detail("Filename", filename).detail("Offset", offset).detail("Length", length); if(length == 0) { TraceEvent(SevWarnAlways, "AsyncFileNonDurable_EmptyModification", id).detail("Filename", filename); @@ -283,10 +281,10 @@ public: writeEnded.send(write(this, writeStarted, writeEnded.getFuture(), data, length, offset)); return writeStarted.getFuture(); } - + //Truncates the file. Truncates are delayed a random amount of time before being //passed to the underlying file - Future truncate(int64_t size) { + Future truncate(int64_t size) override { //TraceEvent("AsyncFileNonDurable_Truncate", id).detail("Filename", filename).detail("Offset", size); debugFileTruncate("AsyncFileNonDurableTruncate", filename, size); @@ -306,17 +304,11 @@ public: } //Passes along size requests to the underlying file, augmenting with any writes past the end of the file - Future size() { - return size(this); - } + Future size() const override { return size(this); } - int64_t debugFD() { - return file->debugFD(); - } + int64_t debugFD() const override { return file->debugFD(); } - std::string getFilename() { - return file->getFilename(); - } + std::string getFilename() const override { return file->getFilename(); } //Forces a non-durable sync (some writes are not made or made incorrectly) //This is used when the file should 'die' without first completing its operations @@ -358,7 +350,7 @@ private: } //Checks if the file is killed. If so, then the current sync is completed if running and then an error is thrown - ACTOR Future checkKilled(AsyncFileNonDurable *self, std::string context) { + ACTOR static Future checkKilled(AsyncFileNonDurable const* self, std::string context) { if(self->killed.isSet()) { //TraceEvent("AsyncFileNonDurable_KilledInCheck", self->id).detail("In", context).detail("Filename", self->filename); wait(self->killComplete.getFuture()); @@ -372,14 +364,14 @@ private: //Passes along reads straight to the underlying file, waiting for any outstanding changes that could affect the results ACTOR Future onRead(AsyncFileNonDurable *self, void *data, int length, int64_t offset) { - wait(self->checkKilled(self, "Read")); + wait(checkKilled(self, "Read")); vector> priorModifications = self->getModificationsAndInsert(offset, length); wait(waitForAll(priorModifications)); state Future readFuture = self->file->read(data, length, offset); wait( success( readFuture ) || self->killed.getFuture() ); // throws if we were killed - wait(self->checkKilled(self, "ReadEnd")); + wait(checkKilled(self, "ReadEnd")); debugFileCheck("AsyncFileNonDurableRead", self->filename, data, offset, length); @@ -421,7 +413,7 @@ private: try { //TraceEvent("AsyncFileNonDurable_Write", self->id).detail("Delay", delayDuration).detail("Filename", self->filename).detail("WriteLength", length).detail("Offset", offset); - wait(self->checkKilled(self, "Write")); + wait(checkKilled(self, "Write")); Future writeEnded = wait(ownFuture); std::vector> priorModifications = self->getModificationsAndInsert(offset, length, true, writeEnded); @@ -543,7 +535,7 @@ private: try { //TraceEvent("AsyncFileNonDurable_Truncate", self->id).detail("Delay", delayDuration).detail("Filename", self->filename); - wait(self->checkKilled(self, "Truncate")); + wait(checkKilled(self, "Truncate")); Future truncateEnded = wait(ownFuture); std::vector> priorModifications = self->getModificationsAndInsert(size, -1, true, truncateEnded); @@ -600,8 +592,8 @@ private: wait(waitUntilDiskReady(self->diskParameters, 0, true) || self->killed.getFuture()); } - wait(self->checkKilled(self, durable ? "Sync" : "Kill")); - + wait(checkKilled(self, durable ? "Sync" : "Kill")); + if(!durable) self->killed.send( Void() ); @@ -653,7 +645,7 @@ private: } //A killed file cannot be allowed to report that it successfully synced else { - wait(self->checkKilled(self, "SyncEnd")); + wait(checkKilled(self, "SyncEnd")); wait(self->file->sync()); //TraceEvent("AsyncFileNonDurable_ImplSyncEnd", self->id).detail("Filename", self->filename).detail("Durable", durable); } @@ -679,13 +671,13 @@ private: } //Passes along size requests to the underlying file, augmenting with any writes past the end of the file - ACTOR Future onSize(AsyncFileNonDurable *self) { + ACTOR static Future onSize(AsyncFileNonDurable const* self) { //TraceEvent("AsyncFileNonDurable_Size", self->id).detail("Filename", self->filename); - wait(self->checkKilled(self, "Size")); + wait(checkKilled(self, "Size")); state Future sizeFuture = self->file->size(); wait( success( sizeFuture ) || self->killed.getFuture() ); - wait(self->checkKilled(self, "SizeEnd")); + wait(checkKilled(self, "SizeEnd")); //Include any modifications which extend past the end of the file uint64_t maxModification = self->pendingModifications.lastItem().begin(); @@ -693,14 +685,14 @@ private: return self->approximateSize; } - ACTOR Future size(AsyncFileNonDurable *self) { + ACTOR static Future size(AsyncFileNonDurable const* self) { state ISimulator::ProcessInfo* currentProcess = g_simulator.getCurrentProcess(); state TaskPriority currentTaskID = g_network->getCurrentTask(); wait( g_simulator.onMachine( currentProcess ) ); try { - state int64_t rep = wait( self->onSize( self ) ); + state int64_t rep = wait(onSize(self)); wait( g_simulator.onProcess( currentProcess, currentTaskID ) ); return rep; diff --git a/fdbrpc/AsyncFileReadAhead.actor.h b/fdbrpc/AsyncFileReadAhead.actor.h index cc3216ebdb..c27375194f 100644 --- a/fdbrpc/AsyncFileReadAhead.actor.h +++ b/fdbrpc/AsyncFileReadAhead.actor.h @@ -155,27 +155,27 @@ public: return wpos; } - virtual Future read( void *data, int length, int64_t offset ) { + Future read(void* data, int length, int64_t offset) override { return read_impl(Reference::addRef(this), data, length, offset); } - virtual Future write( void const *data, int length, int64_t offset ) { throw file_not_writable(); } - virtual Future truncate( int64_t size ) { throw file_not_writable(); } + Future write(void const* data, int length, int64_t offset) override { throw file_not_writable(); } + Future truncate(int64_t size) override { throw file_not_writable(); } - virtual Future sync() { return Void(); } - virtual Future flush() { return Void(); } + Future sync() override { return Void(); } + Future flush() override { return Void(); } - virtual Future size() { return m_f->size(); } + Future size() const override { return m_f->size(); } - virtual Future readZeroCopy( void** data, int* length, int64_t offset ) { + Future readZeroCopy(void** data, int* length, int64_t offset) override { TraceEvent(SevError, "ReadZeroCopyNotSupported").detail("FileType", "ReadAheadCache"); return platform_error(); } - virtual void releaseZeroCopy( void* data, int length, int64_t offset ) {} + void releaseZeroCopy(void* data, int length, int64_t offset) override {} - virtual int64_t debugFD() { return -1; } + int64_t debugFD() const override { return -1; } - virtual std::string getFilename() { return m_f->getFilename(); } + std::string getFilename() const override { return m_f->getFilename(); } virtual ~AsyncFileReadAheadCache() { for(auto &it : m_blocks) { diff --git a/fdbrpc/AsyncFileWinASIO.actor.h b/fdbrpc/AsyncFileWinASIO.actor.h index 19b6ffcb9c..1f4f89c00f 100644 --- a/fdbrpc/AsyncFileWinASIO.actor.h +++ b/fdbrpc/AsyncFileWinASIO.actor.h @@ -87,7 +87,7 @@ public: virtual void addref() { ReferenceCounted::addref(); } virtual void delref() { ReferenceCounted::delref(); } - virtual int64_t debugFD() { return (int64_t)file.native_handle(); } + int64_t debugFD() const override { return (int64_t)(const_cast(file).native_handle()); } static void onReadReady( Promise onReady, const boost::system::error_code& error, size_t bytesRead ) { if (error) { @@ -116,7 +116,7 @@ public: } } - virtual Future read( void* data, int length, int64_t offset ) { + Future read(void* data, int length, int64_t offset) override { // the size call is set inline auto end = this->size().get(); //TraceEvent("WinAsyncRead").detail("Offset", offset).detail("Length", length).detail("FileSize", end).detail("FileName", filename); @@ -128,7 +128,7 @@ public: return result.getFuture(); } - virtual Future write( void const* data, int length, int64_t offset ) { + Future write(void const* data, int length, int64_t offset) override { /* FIXME if ( length + offset >= fileValidData ) { @@ -139,7 +139,7 @@ public: boost::asio::async_write_at( file, offset, boost::asio::const_buffers_1( data, length ), boost::bind( &onWriteReady, result, length, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred ) ); return result.getFuture(); } - virtual Future truncate( int64_t size ) { + Future truncate(int64_t size) override { // FIXME: Possibly use SetFileInformationByHandle( file.native_handle(), FileEndOfFileInfo, ... ) instead if (!SetFilePointerEx( file.native_handle(), *(LARGE_INTEGER*)&size, NULL, FILE_BEGIN )) throw io_error(); @@ -147,7 +147,7 @@ public: throw io_error(); return Void(); } - virtual Future sync() { + Future sync() override { // FIXME: Do FlushFileBuffers in a worker thread (using g_network->createThreadPool)? if (!FlushFileBuffers( file.native_handle() )) throw io_error(); @@ -159,14 +159,12 @@ public: return Void(); } - virtual Future size() { + Future size() const override { LARGE_INTEGER s; - if (!GetFileSizeEx(file.native_handle(), &s)) throw io_error(); + if (!GetFileSizeEx(const_cast(file).native_handle(), &s)) throw io_error(); return *(int64_t*)&s; } - virtual std::string getFilename() { - return filename; - } + std::string getFilename() const override { return filename; } ~AsyncFileWinASIO() { } diff --git a/fdbrpc/AsyncFileWriteChecker.h b/fdbrpc/AsyncFileWriteChecker.h index 64a74d24b2..242fef730d 100644 --- a/fdbrpc/AsyncFileWriteChecker.h +++ b/fdbrpc/AsyncFileWriteChecker.h @@ -60,10 +60,10 @@ public: Future sync() { return m_f->sync(); } Future flush() { return m_f->flush(); } - Future size() { return m_f->size(); } - std::string getFilename() { return m_f->getFilename(); } + Future size() const override { return m_f->size(); } + std::string getFilename() const override { return m_f->getFilename(); } void releaseZeroCopy( void* data, int length, int64_t offset ) { return m_f->releaseZeroCopy(data, length, offset); } - int64_t debugFD() { return m_f->debugFD(); } + int64_t debugFD() const override { return m_f->debugFD(); } AsyncFileWriteChecker(Reference f) : m_f(f) { // Initialize the static history budget the first time (and only the first time) a file is opened. diff --git a/fdbrpc/IAsyncFile.h b/fdbrpc/IAsyncFile.h index 764b8e6426..d02fb8368c 100644 --- a/fdbrpc/IAsyncFile.h +++ b/fdbrpc/IAsyncFile.h @@ -63,8 +63,8 @@ public: virtual Future truncate( int64_t size ) = 0; virtual Future sync() = 0; virtual Future flush() { return Void(); } // Sends previous writes to the OS if they have been buffered in memory, but does not make them power safe - virtual Future size() = 0; - virtual std::string getFilename() = 0; + virtual Future size() const = 0; + virtual std::string getFilename() const = 0; // Attempt to read the *length bytes at offset without copying. If successful, a pointer to the // requested bytes is written to *data, and the number of bytes successfully read is @@ -80,7 +80,7 @@ public: virtual Future readZeroCopy( void** data, int* length, int64_t offset ) { return io_error(); } virtual void releaseZeroCopy( void* data, int length, int64_t offset ) {} - virtual int64_t debugFD() = 0; + virtual int64_t debugFD() const = 0; }; typedef void (*runCycleFuncPtr)(); diff --git a/fdbrpc/RangeMap.h b/fdbrpc/RangeMap.h index 8407478256..d4db66c6a4 100644 --- a/fdbrpc/RangeMap.h +++ b/fdbrpc/RangeMap.h @@ -164,6 +164,11 @@ public: i.decrementNonEnd(); return iterator(i); } + const_iterator lastItem() const { + auto i(map.lastItem()); + i.decrementNonEnd(); + return const_iterator(i); + } int size() const { return map.size() - 1; } // We always have one range bounded by two entries iterator randomRange() { return iterator(map.index(deterministicRandom()->randomInt(0, map.size() - 1))); } const_iterator randomRange() const { @@ -275,4 +280,4 @@ void RangeMap::insert( const Range& keys, const map.insert(beginPair, true, mf(beginPair)); } -#endif \ No newline at end of file +#endif diff --git a/fdbrpc/sim2.actor.cpp b/fdbrpc/sim2.actor.cpp index 65299afda1..45500d4675 100644 --- a/fdbrpc/sim2.actor.cpp +++ b/fdbrpc/sim2.actor.cpp @@ -478,31 +478,21 @@ public: virtual void addref() { ReferenceCounted::addref(); } virtual void delref() { ReferenceCounted::delref(); } - virtual int64_t debugFD() { return (int64_t)h; } + int64_t debugFD() const override { return (int64_t)h; } - virtual Future read( void* data, int length, int64_t offset ) { - return read_impl( this, data, length, offset ); - } + Future read(void* data, int length, int64_t offset) override { return read_impl(this, data, length, offset); } - virtual Future write( void const* data, int length, int64_t offset ) { + Future write(void const* data, int length, int64_t offset) override { return write_impl( this, StringRef((const uint8_t*)data, length), offset ); } - virtual Future truncate( int64_t size ) { - return truncate_impl( this, size ); - } + Future truncate(int64_t size) override { return truncate_impl(this, size); } - virtual Future sync() { - return sync_impl( this ); - } + Future sync() override { return sync_impl(this); } - virtual Future size() { - return size_impl( this ); - } + Future size() const override { return size_impl(this); } - virtual std::string getFilename() { - return actualFilename; - } + std::string getFilename() const override { return actualFilename; } ~SimpleFile() { _close( h ); @@ -667,7 +657,7 @@ private: return Void(); } - ACTOR static Future size_impl( SimpleFile* self ) { + ACTOR static Future size_impl(SimpleFile const* self) { state UID opId = deterministicRandom()->randomUniqueID(); if (randLog) fprintf(randLog, "SFS1 %s %s %s\n", self->dbgId.shortString().c_str(), self->filename.c_str(), opId.shortString().c_str()); diff --git a/flow/flow.h b/flow/flow.h index 5e6ce3f3b8..5c28323b68 100644 --- a/flow/flow.h +++ b/flow/flow.h @@ -785,14 +785,14 @@ public: void sendError(const E& exc) const { sav->sendError(exc); } Future getFuture() const { sav->addFutureRef(); return Future(sav); } - bool isSet() { return sav->isSet(); } - bool canBeSet() { return sav->canBeSet(); } - bool isValid() const { return sav != NULL; } + bool isSet() const { return sav->isSet(); } + bool canBeSet() const { return sav->canBeSet(); } + bool isValid() const { return sav != nullptr; } Promise() : sav(new SAV(0, 1)) {} Promise(const Promise& rhs) : sav(rhs.sav) { sav->addPromiseRef(); } - Promise(Promise&& rhs) BOOST_NOEXCEPT : sav(rhs.sav) { rhs.sav = 0; } + Promise(Promise&& rhs) noexcept : sav(rhs.sav) { rhs.sav = 0; } ~Promise() { if (sav) sav->delPromiseRef(); }