get rid of gettickcount
This commit is contained in:
parent
f8874bf8a0
commit
d64a2c05b4
@ -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();
|
||||
|
@ -36,7 +36,7 @@ private:
|
||||
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;
|
||||
|
@ -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<DWORD, std::greater<DWORD>> tokens;
|
||||
concurrency::concurrent_priority_queue<DWORD64, std::greater<DWORD64>> tokens;
|
||||
} rateLimiter;
|
||||
|
||||
auto Trim = [](std::wstring& text)
|
||||
|
Loading…
Reference in New Issue
Block a user