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);
|
writeAddressTablePointer(SweepstorePointer::NULL_PTR);
|
||||||
writeFreeListCount(0);
|
writeFreeListCount(0);
|
||||||
writeIsFreeListLifted(false);
|
writeIsFreeListLifted(false);
|
||||||
file->flush();
|
file.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t SweepstoreConcurrencyHeader::readMasterIdentifier() {
|
uint64_t SweepstoreConcurrencyHeader::readMasterIdentifier() {
|
||||||
@@ -158,7 +158,7 @@ void SweepstoreConcurrencyHeader::initialise(int concurrentWorkers) {
|
|||||||
SweepstoreWorkerTicket ticketWriter = SweepstoreWorkerTicket(i, file);
|
SweepstoreWorkerTicket ticketWriter = SweepstoreWorkerTicket(i, file);
|
||||||
ticketWriter.write(ticket);
|
ticketWriter.write(ticket);
|
||||||
}
|
}
|
||||||
file->flush();
|
file.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SweepstoreWorkerTicket::write(SweepstoreWorkerTicketSnapshot &snapshot) {
|
void SweepstoreWorkerTicket::write(SweepstoreWorkerTicketSnapshot &snapshot) {
|
||||||
@@ -189,7 +189,7 @@ void SweepstoreWorkerTicket::write(SweepstoreWorkerTicketSnapshot &snapshot) {
|
|||||||
// Write to file
|
// Write to file
|
||||||
file.writeSeek(getOffset());
|
file.writeSeek(getOffset());
|
||||||
file.writeBytes(dataPtr, data.size());
|
file.writeBytes(dataPtr, data.size());
|
||||||
file->flush();
|
file.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SweepstoreWorkerTicket::writable() {
|
bool SweepstoreWorkerTicket::writable() {
|
||||||
|
|||||||
@@ -55,6 +55,23 @@ void SweepstoreFileHandle::close() {
|
|||||||
#endif
|
#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)
|
#if defined(_WIN32) || defined(WITH_UNREAL)
|
||||||
// readSeek
|
// readSeek
|
||||||
void SweepstoreFileHandle::readSeek(std::streampos pos, std::ios::seekdir dir) {
|
void SweepstoreFileHandle::readSeek(std::streampos pos, std::ios::seekdir dir) {
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ public:
|
|||||||
|
|
||||||
bool isOpen() const;
|
bool isOpen() const;
|
||||||
void close();
|
void close();
|
||||||
|
void flush();
|
||||||
|
|
||||||
// Windows-compatible I/O wrappers
|
// Windows-compatible I/O wrappers
|
||||||
#if defined(_WIN32) || defined(WITH_UNREAL)
|
#if defined(_WIN32) || defined(WITH_UNREAL)
|
||||||
|
|||||||
Reference in New Issue
Block a user