Add flush method to SweepstoreFileHandle for improved data synchronization
This commit is contained in:
@@ -88,7 +88,7 @@ void SweepstoreHeader::initialise() {
|
||||
writeAddressTablePointer(SweepstorePointer::NULL_PTR);
|
||||
writeFreeListCount(0);
|
||||
writeIsFreeListLifted(false);
|
||||
file->flush();
|
||||
file.flush();
|
||||
}
|
||||
|
||||
uint64_t SweepstoreConcurrencyHeader::readMasterIdentifier() {
|
||||
@@ -158,7 +158,7 @@ void SweepstoreConcurrencyHeader::initialise(int concurrentWorkers) {
|
||||
SweepstoreWorkerTicket ticketWriter = SweepstoreWorkerTicket(i, file);
|
||||
ticketWriter.write(ticket);
|
||||
}
|
||||
file->flush();
|
||||
file.flush();
|
||||
}
|
||||
|
||||
void SweepstoreWorkerTicket::write(SweepstoreWorkerTicketSnapshot &snapshot) {
|
||||
@@ -189,7 +189,7 @@ void SweepstoreWorkerTicket::write(SweepstoreWorkerTicketSnapshot &snapshot) {
|
||||
// Write to file
|
||||
file.writeSeek(getOffset());
|
||||
file.writeBytes(dataPtr, data.size());
|
||||
file->flush();
|
||||
file.flush();
|
||||
}
|
||||
|
||||
bool SweepstoreWorkerTicket::writable() {
|
||||
|
||||
@@ -55,6 +55,23 @@ void SweepstoreFileHandle::close() {
|
||||
#endif
|
||||
}
|
||||
|
||||
// flush
|
||||
void SweepstoreFileHandle::flush() {
|
||||
#ifdef WITH_UNREAL
|
||||
if (unrealHandle) {
|
||||
unrealHandle->Flush();
|
||||
}
|
||||
#else
|
||||
if (stream) {
|
||||
stream->flush();
|
||||
#ifdef _WIN32
|
||||
// On Windows, also sync to ensure data hits disk
|
||||
stream->sync();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(_WIN32) || defined(WITH_UNREAL)
|
||||
// readSeek
|
||||
void SweepstoreFileHandle::readSeek(std::streampos pos, std::ios::seekdir dir) {
|
||||
|
||||
@@ -37,6 +37,7 @@ public:
|
||||
|
||||
bool isOpen() const;
|
||||
void close();
|
||||
void flush();
|
||||
|
||||
// Windows-compatible I/O wrappers
|
||||
#if defined(_WIN32) || defined(WITH_UNREAL)
|
||||
|
||||
Reference in New Issue
Block a user