From d64a2c05b4f20769f2c740ad030e83bd740b0f6a Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Thu, 1 Jul 2021 13:35:33 -0600 Subject: [PATCH] get rid of gettickcount --- GUI/host/textthread.cpp | 6 +++--- GUI/host/textthread.h | 2 +- extensions/translatewrapper.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/GUI/host/textthread.cpp b/GUI/host/textthread.cpp index b55d165..593ab0f 100644 --- a/GUI/host/textthread.cpp +++ b/GUI/host/textthread.cpp @@ -63,7 +63,7 @@ void TextThread::Push(BYTE* data, int length) else if (auto converted = StringToWideString(std::string((char*)data, length), hp.codepage ? hp.codepage : Host::defaultCodepage)) buffer.append(converted.value()); else Host::AddConsoleOutput(INVALID_CODEPAGE); if (hp.type & FULL_STRING) buffer.push_back(L'\n'); - lastPushTime = GetTickCount(); + lastPushTime = GetTickCount64(); if (filterRepetition) { @@ -87,7 +87,7 @@ void TextThread::Push(const wchar_t* data) { std::scoped_lock lock(bufferMutex); // not sure if this should filter repetition - lastPushTime = GetTickCount(); + lastPushTime = GetTickCount64(); buffer += data; } @@ -110,7 +110,7 @@ void TextThread::Flush() std::scoped_lock lock(bufferMutex); if (buffer.empty()) return; - if (buffer.size() > maxBufferSize || GetTickCount() - lastPushTime > flushDelay) + if (buffer.size() > maxBufferSize || GetTickCount64() - lastPushTime > flushDelay) { AddSentence(std::move(buffer)); buffer.clear(); diff --git a/GUI/host/textthread.h b/GUI/host/textthread.h index 98a9e98..029811e 100644 --- a/GUI/host/textthread.h +++ b/GUI/host/textthread.h @@ -36,7 +36,7 @@ private: BYTE leadByte = 0; std::unordered_set repeatingChars; std::mutex bufferMutex; - DWORD lastPushTime = 0; + DWORD64 lastPushTime = 0; Synchronized> queuedSentences; struct TimerDeleter { void operator()(HANDLE h) { DeleteTimerQueueTimer(NULL, h, INVALID_HANDLE_VALUE); } }; AutoHandle timer = NULL; diff --git a/extensions/translatewrapper.cpp b/extensions/translatewrapper.cpp index 001f269..719c150 100644 --- a/extensions/translatewrapper.cpp +++ b/extensions/translatewrapper.cpp @@ -154,7 +154,7 @@ bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo) public: bool Request() { - DWORD current = GetTickCount(), token; + DWORD64 current = GetTickCount64(), token; while (tokens.try_pop(token)) if (token > current - rateLimitTimespan) { tokens.push(token); // popped one too many @@ -165,7 +165,7 @@ bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo) } private: - concurrency::concurrent_priority_queue> tokens; + concurrency::concurrent_priority_queue> tokens; } rateLimiter; auto Trim = [](std::wstring& text)