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
|
||||
|
||||
TextThread::TextThread(ThreadParameter tp, DWORD status) :
|
||||
status(status),
|
||||
deletionEvent(CreateEventW(nullptr, FALSE, FALSE, NULL)),
|
||||
flushThread([&]() { while (WaitForSingleObject(deletionEvent, 100), FlushSentenceBuffer()); }),
|
||||
timestamp(GetTickCount()),
|
||||
Output(nullptr),
|
||||
tp(tp),
|
||||
flushThread([&]() { while (Sleep(25), FlushSentenceBuffer()); })
|
||||
status(status)
|
||||
{}
|
||||
|
||||
TextThread::~TextThread()
|
||||
{
|
||||
status = -1UL;
|
||||
SetEvent(deletionEvent);
|
||||
flushThread.join();
|
||||
CloseHandle(deletionEvent);
|
||||
}
|
||||
|
||||
std::wstring TextThread::GetStore()
|
||||
|
@ -47,14 +47,15 @@ public:
|
||||
private:
|
||||
bool FlushSentenceBuffer();
|
||||
|
||||
ThreadOutputCallback Output;
|
||||
std::vector<char> sentenceBuffer;
|
||||
std::wstring storage;
|
||||
|
||||
ThreadParameter tp;
|
||||
std::recursive_mutex ttMutex;
|
||||
HANDLE deletionEvent;
|
||||
std::thread flushThread;
|
||||
|
||||
DWORD timestamp;
|
||||
ThreadOutputCallback Output;
|
||||
ThreadParameter tp;
|
||||
DWORD status;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user