refactor HANDLE out param
This commit is contained in:
parent
f409ee78ce
commit
74383ee0d8
@ -8,12 +8,9 @@ TextThread::TextThread(ThreadParam tp, HookParam hp, std::optional<std::wstring>
|
|||||||
handle(threadCounter++),
|
handle(threadCounter++),
|
||||||
name(name.value_or(Util::StringToWideString(hp.name).value())),
|
name(name.value_or(Util::StringToWideString(hp.name).value())),
|
||||||
tp(tp),
|
tp(tp),
|
||||||
hp(hp),
|
hp(hp)
|
||||||
timer(NULL)
|
|
||||||
{
|
{
|
||||||
HANDLE newTimer;
|
CreateTimerQueueTimer(timer, NULL, Flush, this, 25, 25, WT_EXECUTELONGFUNCTION);
|
||||||
CreateTimerQueueTimer(&newTimer, NULL, Flush, this, 25, 25, WT_EXECUTELONGFUNCTION);
|
|
||||||
timer = newTimer;
|
|
||||||
OnCreate(this);
|
OnCreate(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,6 @@ private:
|
|||||||
std::wstring buffer;
|
std::wstring buffer;
|
||||||
std::unordered_set<wchar_t> repeatingChars;
|
std::unordered_set<wchar_t> repeatingChars;
|
||||||
std::mutex bufferMutex;
|
std::mutex bufferMutex;
|
||||||
AutoHandle<TimerDeleter> timer;
|
|
||||||
DWORD lastPushTime;
|
DWORD lastPushTime;
|
||||||
|
AutoHandle<TimerDeleter> timer = NULL; // this needs to be last so it's destructed first
|
||||||
};
|
};
|
||||||
|
@ -31,6 +31,7 @@ class AutoHandle
|
|||||||
public:
|
public:
|
||||||
AutoHandle(HANDLE h) : h(h) {}
|
AutoHandle(HANDLE h) : h(h) {}
|
||||||
operator HANDLE() { return h.get(); }
|
operator HANDLE() { return h.get(); }
|
||||||
|
operator PHANDLE() { return &h._Myptr(); }
|
||||||
operator bool() { return h.get() != NULL && h.get() != INVALID_HANDLE_VALUE; }
|
operator bool() { return h.get() != NULL && h.get() != INVALID_HANDLE_VALUE; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user