mirror of
https://github.com/Artikash/Textractor.git
synced 2024-12-24 01:14:12 +08:00
42 lines
935 B
C++
42 lines
935 B
C++
#pragma once
|
|
|
|
// textthread.h
|
|
// 8/23/2013 jichi
|
|
// Branch: ITH/TextThread.h, rev 120
|
|
|
|
#include "common.h"
|
|
#include "types.h"
|
|
|
|
class TextThread
|
|
{
|
|
typedef std::function<std::wstring(TextThread*, std::wstring)> ThreadOutputCallback;
|
|
public:
|
|
TextThread(ThreadParam tp, DWORD status);
|
|
~TextThread();
|
|
|
|
std::wstring GetStore();
|
|
ThreadParam GetThreadParam() { return tp; }
|
|
|
|
void RegisterOutputCallBack(ThreadOutputCallback cb) { Output = cb; }
|
|
|
|
void AddText(const BYTE* data, int len);
|
|
void AddSentence(std::wstring sentence);
|
|
|
|
private:
|
|
void Flush();
|
|
|
|
std::vector<char> buffer;
|
|
std::wstring storage;
|
|
std::recursive_mutex ttMutex;
|
|
|
|
HANDLE deletionEvent = CreateEventW(nullptr, FALSE, FALSE, NULL);
|
|
std::thread flushThread = std::thread([&] { while (WaitForSingleObject(deletionEvent, 100) == WAIT_TIMEOUT) Flush(); });
|
|
DWORD timestamp = GetTickCount();
|
|
|
|
ThreadOutputCallback Output;
|
|
ThreadParam tp;
|
|
DWORD status;
|
|
};
|
|
|
|
// EOF
|