add mutex to getBlock

This commit is contained in:
Xiao YiFang 2022-06-17 20:23:16 +08:00
parent 5c4a968781
commit ceb31baf97
2 changed files with 3 additions and 1 deletions

View file

@ -137,7 +137,7 @@ char * Reader::getBlock( uint32_t address, vector< char > & chunk )
// Read and decompress the chunk
{
// file.seek( offsets[ chunkIdx ] );
Mutex::Lock _( file.lock );
auto bytes = file.map( offsets[ chunkIdx ], 8 );
auto qBytes = QByteArray::fromRawData( reinterpret_cast< char * >(bytes), 8 );
QDataStream in( qBytes );

View file

@ -9,6 +9,7 @@
#include <vector>
#include <QFile>
#include "ex.hh"
#include "mutex.hh"
/// A simple wrapper over FILE * operations with added write-buffering,
/// used for non-Qt parts of code.
@ -44,6 +45,7 @@ class Class
void open( char const * filename, char const * mode ) ;
public:
Mutex lock;
Class( char const * filename, char const * mode ) ;