Add support for lambdas to Win32Thread

This commit is contained in:
Robbert van der Helm
2020-10-27 17:04:40 +01:00
parent 058eb9f2ee
commit 1681ec9767
2 changed files with 69 additions and 21 deletions
+23
View File
@@ -18,6 +18,29 @@
PluginContext::PluginContext() : context(), events_timer(context) {}
uint32_t WINAPI win32_thread_trampoline(std::function<void()>* entry_point) {
(*entry_point)();
delete entry_point;
return 0;
}
Win32Thread::~Win32Thread() {
// Imitate std::jthread's joining behaviour, the thread handle will be
// cleaned up by the `std::unique_ptr`
if (handle) {
WaitForSingleObject(handle.get(), INFINITE);
}
}
Win32Thread::Win32Thread(Win32Thread&& o) : handle(std::move(o.handle)) {}
Win32Thread& Win32Thread::operator=(Win32Thread&& o) {
handle = std::move(o.handle);
return *this;
}
void PluginContext::run() {
context.run();
}