forked from Public-Mirror/Textractor
performance improvement
This commit is contained in:
parent
67e5ff31d1
commit
911fb991be
@ -13,17 +13,20 @@
|
|||||||
#define TT_LOCK std::lock_guard<std::recursive_mutex> ttLocker(ttMutex) // Synchronized scope for accessing private data
|
#define TT_LOCK std::lock_guard<std::recursive_mutex> ttLocker(ttMutex) // Synchronized scope for accessing private data
|
||||||
|
|
||||||
TextThread::TextThread(ThreadParameter tp, DWORD status) :
|
TextThread::TextThread(ThreadParameter tp, DWORD status) :
|
||||||
status(status),
|
deletionEvent(CreateEventW(nullptr, FALSE, FALSE, NULL)),
|
||||||
|
flushThread([&]() { while (WaitForSingleObject(deletionEvent, 100), FlushSentenceBuffer()); }),
|
||||||
timestamp(GetTickCount()),
|
timestamp(GetTickCount()),
|
||||||
Output(nullptr),
|
Output(nullptr),
|
||||||
tp(tp),
|
tp(tp),
|
||||||
flushThread([&]() { while (Sleep(25), FlushSentenceBuffer()); })
|
status(status)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
TextThread::~TextThread()
|
TextThread::~TextThread()
|
||||||
{
|
{
|
||||||
status = -1UL;
|
status = -1UL;
|
||||||
|
SetEvent(deletionEvent);
|
||||||
flushThread.join();
|
flushThread.join();
|
||||||
|
CloseHandle(deletionEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring TextThread::GetStore()
|
std::wstring TextThread::GetStore()
|
||||||
|
@ -47,14 +47,15 @@ public:
|
|||||||
private:
|
private:
|
||||||
bool FlushSentenceBuffer();
|
bool FlushSentenceBuffer();
|
||||||
|
|
||||||
ThreadOutputCallback Output;
|
|
||||||
std::vector<char> sentenceBuffer;
|
std::vector<char> sentenceBuffer;
|
||||||
std::wstring storage;
|
std::wstring storage;
|
||||||
|
|
||||||
ThreadParameter tp;
|
|
||||||
std::recursive_mutex ttMutex;
|
std::recursive_mutex ttMutex;
|
||||||
|
HANDLE deletionEvent;
|
||||||
std::thread flushThread;
|
std::thread flushThread;
|
||||||
|
|
||||||
DWORD timestamp;
|
DWORD timestamp;
|
||||||
|
ThreadOutputCallback Output;
|
||||||
|
ThreadParameter tp;
|
||||||
DWORD status;
|
DWORD status;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user