performance improvement

This commit is contained in:
Akash Mozumdar 2018-08-21 23:56:16 -04:00
parent 67e5ff31d1
commit 911fb991be
2 changed files with 9 additions and 5 deletions

View File

@ -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()

View File

@ -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;
};