mirror of
https://github.com/Artikash/Textractor.git
synced 2024-12-24 01:14:12 +08:00
fix unique_lock starvation and extension loading
This commit is contained in:
parent
4eefafeae9
commit
855f8ebfe5
@ -19,8 +19,18 @@ namespace
|
|||||||
wchar_t*(*callback)(wchar_t*, const InfoForExtension*);
|
wchar_t*(*callback)(wchar_t*, const InfoForExtension*);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class : std::shared_mutex
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void lock() { ++queuedWrites; shared_mutex::lock(); }
|
||||||
|
void unlock() { --queuedWrites; shared_mutex::unlock(); }
|
||||||
|
void lock_shared() { while (queuedWrites) Sleep(100); shared_mutex::lock_shared(); }
|
||||||
|
void unlock_shared() { shared_mutex::unlock_shared(); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::atomic<int> queuedWrites = 0;
|
||||||
|
} extenMutex;
|
||||||
std::vector<Extension> extensions;
|
std::vector<Extension> extensions;
|
||||||
std::shared_mutex extenMutex;
|
|
||||||
|
|
||||||
void Load(QString extenName)
|
void Load(QString extenName)
|
||||||
{
|
{
|
||||||
@ -105,7 +115,7 @@ void ExtenWindow::Sync()
|
|||||||
void ExtenWindow::Add(QFileInfo extenFile)
|
void ExtenWindow::Add(QFileInfo extenFile)
|
||||||
{
|
{
|
||||||
if (extenFile.suffix() != "dll") return;
|
if (extenFile.suffix() != "dll") return;
|
||||||
QFile::copy(extenFile.fileName(), extenFile.absoluteFilePath());
|
QFile::copy(extenFile.absoluteFilePath(), extenFile.fileName());
|
||||||
Load(extenFile.completeBaseName());
|
Load(extenFile.completeBaseName());
|
||||||
Sync();
|
Sync();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user