This commit is contained in:
Akash Mozumdar 2019-02-09 18:24:54 -05:00
parent ceeeced02f
commit 4a7b29de72
3 changed files with 7 additions and 7 deletions

View File

@ -33,11 +33,11 @@ namespace
} }
template <typename T> template <typename T>
void Send(T data) std::enable_if_t<sizeof(T) < PIPE_BUFFER_SIZE> Send(T data)
{ {
std::thread([=] std::thread([=]
{ {
std::enable_if_t<sizeof(data) < PIPE_BUFFER_SIZE, DWORD> DUMMY; DWORD DUMMY;
WriteFile(pipe, &data, sizeof(data), &DUMMY, nullptr); WriteFile(pipe, &data, sizeof(data), &DUMMY, nullptr);
}).detach(); }).detach();
} }

View File

@ -26,7 +26,7 @@ void TextThread::AddSentence(std::wstring&& sentence)
queuedSentences->emplace_back(std::move(sentence)); queuedSentences->emplace_back(std::move(sentence));
} }
void TextThread::Push(const BYTE* data, int length) void TextThread::Push(BYTE* data, int length)
{ {
if (length < 0) return; if (length < 0) return;
std::scoped_lock lock(bufferMutex); std::scoped_lock lock(bufferMutex);
@ -36,8 +36,8 @@ void TextThread::Push(const BYTE* data, int length)
if (leadByte) std::tie(doubleByteChar[0], doubleByteChar[1], data, length, leadByte) = std::tuple(leadByte, data[0], doubleByteChar, 2, 0); if (leadByte) std::tie(doubleByteChar[0], doubleByteChar[1], data, length, leadByte) = std::tuple(leadByte, data[0], doubleByteChar, 2, 0);
else if (IsDBCSLeadByteEx(hp.codepage ? hp.codepage : Host::defaultCodepage, data[0])) std::tie(leadByte, length) = std::tuple(data[0], 0); else if (IsDBCSLeadByteEx(hp.codepage ? hp.codepage : Host::defaultCodepage, data[0])) std::tie(leadByte, length) = std::tuple(data[0], 0);
if (hp.type & USING_UNICODE) buffer += std::wstring((wchar_t*)data, length / sizeof(wchar_t)); if (hp.type & USING_UNICODE) buffer.append((wchar_t*)data, length / sizeof(wchar_t));
else if (auto converted = Util::StringToWideString(std::string((char*)data, length), hp.codepage ? hp.codepage : Host::defaultCodepage)) buffer += converted.value(); else if (auto converted = Util::StringToWideString(std::string((char*)data, length), hp.codepage ? hp.codepage : Host::defaultCodepage)) buffer.append(converted.value());
else Host::AddConsoleOutput(INVALID_CODEPAGE); else Host::AddConsoleOutput(INVALID_CODEPAGE);
lastPushTime = GetTickCount(); lastPushTime = GetTickCount();

View File

@ -18,7 +18,7 @@ public:
void Start(); void Start();
void Stop(); void Stop();
void AddSentence(std::wstring&& sentence); void AddSentence(std::wstring&& sentence);
void Push(const BYTE* data, int length); void Push(BYTE* data, int length);
ThreadSafe<std::wstring> storage; ThreadSafe<std::wstring> storage;
const int64_t handle; const int64_t handle;