Skip to content

Commit

Permalink
get rid of gettickcount
Browse files Browse the repository at this point in the history
  • Loading branch information
Artikash committed Jul 1, 2021
1 parent f8874bf commit d64a2c0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions GUI/host/textthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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;
}

Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion GUI/host/textthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class TextThread
BYTE leadByte = 0;
std::unordered_set<wchar_t> repeatingChars;
std::mutex bufferMutex;
DWORD lastPushTime = 0;
DWORD64 lastPushTime = 0;
Synchronized<std::vector<std::wstring>> queuedSentences;
struct TimerDeleter { void operator()(HANDLE h) { DeleteTimerQueueTimer(NULL, h, INVALID_HANDLE_VALUE); } };
AutoHandle<TimerDeleter> timer = NULL;
Expand Down
4 changes: 2 additions & 2 deletions extensions/translatewrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -165,7 +165,7 @@ bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
}

private:
concurrency::concurrent_priority_queue<DWORD, std::greater<DWORD>> tokens;
concurrency::concurrent_priority_queue<DWORD64, std::greater<DWORD64>> tokens;
} rateLimiter;

auto Trim = [](std::wstring& text)
Expand Down

0 comments on commit d64a2c0

Please sign in to comment.