Fix cache not getting flushed correctly, causing saves to take too long

master
Marc Gilleron 2021-01-31 15:26:15 +00:00
parent 55005dad9c
commit 0526c4e860
2 changed files with 5 additions and 1 deletions

View File

@ -238,6 +238,8 @@ bool VoxelStreamSQLiteInternal::end_transaction() {
}
bool VoxelStreamSQLiteInternal::save_block(BlockLocation loc, const std::vector<uint8_t> &block_data) {
VOXEL_PROFILE_SCOPE();
sqlite3 *db = _db;
sqlite3_stmt *update_block_statement = _update_block_statement;
@ -609,7 +611,8 @@ void VoxelStreamSQLite::flush_cache() {
// This function does not lock any mutex for internal use.
void VoxelStreamSQLite::flush_cache(VoxelStreamSQLiteInternal *con) {
VOXEL_PROFILE_SCOPE();
PRINT_VERBOSE("VoxelStreamSQLite: Flushing cache");
PRINT_VERBOSE(String("VoxelStreamSQLite: Flushing cache ({0} elements)")
.format(varray(_cache.get_indicative_block_count())));
VoxelBlockSerializerInternal &serializer = _voxel_block_serializer;

View File

@ -20,6 +20,7 @@ public:
template <typename F>
void flush(F save_func) {
_count = 0;
for (unsigned int lod_index = 0; lod_index < _cache.size(); ++lod_index) {
Lod &lod = _cache[lod_index];
RWLockWrite wlock(lod.rw_lock);