refactor HANDLE out param

This commit is contained in:
Akash Mozumdar 2018-12-03 18:29:30 -05:00
parent f409ee78ce
commit 74383ee0d8
3 changed files with 4 additions and 6 deletions

View File

@ -8,12 +8,9 @@ TextThread::TextThread(ThreadParam tp, HookParam hp, std::optional<std::wstring>
handle(threadCounter++),
name(name.value_or(Util::StringToWideString(hp.name).value())),
tp(tp),
hp(hp),
timer(NULL)
hp(hp)
{
HANDLE newTimer;
CreateTimerQueueTimer(&newTimer, NULL, Flush, this, 25, 25, WT_EXECUTELONGFUNCTION);
timer = newTimer;
CreateTimerQueueTimer(timer, NULL, Flush, this, 25, 25, WT_EXECUTELONGFUNCTION);
OnCreate(this);
}

View File

@ -36,6 +36,6 @@ private:
std::wstring buffer;
std::unordered_set<wchar_t> repeatingChars;
std::mutex bufferMutex;
AutoHandle<TimerDeleter> timer;
DWORD lastPushTime;
AutoHandle<TimerDeleter> timer = NULL; // this needs to be last so it's destructed first
};

View File

@ -31,6 +31,7 @@ class AutoHandle
public:
AutoHandle(HANDLE h) : h(h) {}
operator HANDLE() { return h.get(); }
operator PHANDLE() { return &h._Myptr(); }
operator bool() { return h.get() != NULL && h.get() != INVALID_HANDLE_VALUE; }
private: