mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 10:58:52 +00:00
Make Formats::isZippedFile() threadsafe
In this case I use a mutex, so the zip status of files is shared between threads. This is possible because a deadlock can't happen, and it should give better performance.
This commit is contained in:
parent
0092b523c7
commit
4a2250a5d1
@ -22,6 +22,7 @@
|
|||||||
#include "support/filetools.h"
|
#include "support/filetools.h"
|
||||||
#include "support/gettext.h"
|
#include "support/gettext.h"
|
||||||
#include "support/lstrings.h"
|
#include "support/lstrings.h"
|
||||||
|
#include "support/mutex.h"
|
||||||
#include "support/os.h"
|
#include "support/os.h"
|
||||||
#include "support/PathChanger.h"
|
#include "support/PathChanger.h"
|
||||||
#include "support/Systemcall.h"
|
#include "support/Systemcall.h"
|
||||||
@ -503,14 +504,15 @@ struct ZippedInfo {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// FIXME THREAD
|
|
||||||
/// Mapping absolute pathnames of files to their ZippedInfo metadata.
|
/// Mapping absolute pathnames of files to their ZippedInfo metadata.
|
||||||
static std::map<std::string, ZippedInfo> zipped_;
|
static std::map<std::string, ZippedInfo> zipped_;
|
||||||
|
static Mutex zipped_mutex;
|
||||||
|
|
||||||
|
|
||||||
bool Formats::isZippedFile(support::FileName const & filename) const {
|
bool Formats::isZippedFile(support::FileName const & filename) const {
|
||||||
string const & fname = filename.absFileName();
|
string const & fname = filename.absFileName();
|
||||||
time_t timestamp = filename.lastModified();
|
time_t timestamp = filename.lastModified();
|
||||||
|
Mutex::Locker lock(&zipped_mutex);
|
||||||
map<string, ZippedInfo>::iterator it = zipped_.find(fname);
|
map<string, ZippedInfo>::iterator it = zipped_.find(fname);
|
||||||
if (it != zipped_.end() && it->second.timestamp == timestamp)
|
if (it != zipped_.end() && it->second.timestamp == timestamp)
|
||||||
return it->second.zipped;
|
return it->second.zipped;
|
||||||
|
Loading…
Reference in New Issue
Block a user