// WARNING: Please don't edit this file. It was generated by C++/WinRT v2.0.240405.15 #pragma once #ifndef WINRT_Windows_System_Threading_Core_H #define WINRT_Windows_System_Threading_Core_H #include "winrt/base.h" static_assert(winrt::check_version(CPPWINRT_VERSION, "2.0.240405.15"), "Mismatched C++/WinRT headers."); #define CPPWINRT_VERSION "2.0.240405.15" #include "winrt/Windows.System.Threading.h" #include "winrt/impl/Windows.Foundation.2.h" #include "winrt/impl/Windows.System.Threading.2.h" #include "winrt/impl/Windows.System.Threading.Core.2.h" namespace winrt::impl { template auto consume_Windows_System_Threading_Core_IPreallocatedWorkItem::RunAsync() const { void* operation{}; check_hresult(WINRT_IMPL_SHIM(winrt::Windows::System::Threading::Core::IPreallocatedWorkItem)->RunAsync(&operation)); return winrt::Windows::Foundation::IAsyncAction{ operation, take_ownership_from_abi }; } template auto consume_Windows_System_Threading_Core_IPreallocatedWorkItemFactory::CreateWorkItem(winrt::Windows::System::Threading::WorkItemHandler const& handler) const { void* workItem{}; check_hresult(WINRT_IMPL_SHIM(winrt::Windows::System::Threading::Core::IPreallocatedWorkItemFactory)->CreateWorkItem(*(void**)(&handler), &workItem)); return winrt::Windows::System::Threading::Core::PreallocatedWorkItem{ workItem, take_ownership_from_abi }; } template auto consume_Windows_System_Threading_Core_IPreallocatedWorkItemFactory::CreateWorkItemWithPriority(winrt::Windows::System::Threading::WorkItemHandler const& handler, winrt::Windows::System::Threading::WorkItemPriority const& priority) const { void* WorkItem{}; check_hresult(WINRT_IMPL_SHIM(winrt::Windows::System::Threading::Core::IPreallocatedWorkItemFactory)->CreateWorkItemWithPriority(*(void**)(&handler), static_cast(priority), &WorkItem)); return winrt::Windows::System::Threading::Core::PreallocatedWorkItem{ WorkItem, take_ownership_from_abi }; } template auto consume_Windows_System_Threading_Core_IPreallocatedWorkItemFactory::CreateWorkItemWithPriorityAndOptions(winrt::Windows::System::Threading::WorkItemHandler const& handler, winrt::Windows::System::Threading::WorkItemPriority const& priority, winrt::Windows::System::Threading::WorkItemOptions const& options) const { void* WorkItem{}; check_hresult(WINRT_IMPL_SHIM(winrt::Windows::System::Threading::Core::IPreallocatedWorkItemFactory)->CreateWorkItemWithPriorityAndOptions(*(void**)(&handler), static_cast(priority), static_cast(options), &WorkItem)); return winrt::Windows::System::Threading::Core::PreallocatedWorkItem{ WorkItem, take_ownership_from_abi }; } template auto consume_Windows_System_Threading_Core_ISignalNotifier::Enable() const { check_hresult(WINRT_IMPL_SHIM(winrt::Windows::System::Threading::Core::ISignalNotifier)->Enable()); } template auto consume_Windows_System_Threading_Core_ISignalNotifier::Terminate() const { check_hresult(WINRT_IMPL_SHIM(winrt::Windows::System::Threading::Core::ISignalNotifier)->Terminate()); } template auto consume_Windows_System_Threading_Core_ISignalNotifierStatics::AttachToEvent(param::hstring const& name, winrt::Windows::System::Threading::Core::SignalHandler const& handler) const { void* signalNotifier{}; check_hresult(WINRT_IMPL_SHIM(winrt::Windows::System::Threading::Core::ISignalNotifierStatics)->AttachToEvent(*(void**)(&name), *(void**)(&handler), &signalNotifier)); return winrt::Windows::System::Threading::Core::SignalNotifier{ signalNotifier, take_ownership_from_abi }; } template auto consume_Windows_System_Threading_Core_ISignalNotifierStatics::AttachToEvent(param::hstring const& name, winrt::Windows::System::Threading::Core::SignalHandler const& handler, winrt::Windows::Foundation::TimeSpan const& timeout) const { void* signalNotifier{}; check_hresult(WINRT_IMPL_SHIM(winrt::Windows::System::Threading::Core::ISignalNotifierStatics)->AttachToEventWithTimeout(*(void**)(&name), *(void**)(&handler), impl::bind_in(timeout), &signalNotifier)); return winrt::Windows::System::Threading::Core::SignalNotifier{ signalNotifier, take_ownership_from_abi }; } template auto consume_Windows_System_Threading_Core_ISignalNotifierStatics::AttachToSemaphore(param::hstring const& name, winrt::Windows::System::Threading::Core::SignalHandler const& handler) const { void* signalNotifier{}; check_hresult(WINRT_IMPL_SHIM(winrt::Windows::System::Threading::Core::ISignalNotifierStatics)->AttachToSemaphore(*(void**)(&name), *(void**)(&handler), &signalNotifier)); return winrt::Windows::System::Threading::Core::SignalNotifier{ signalNotifier, take_ownership_from_abi }; } template auto consume_Windows_System_Threading_Core_ISignalNotifierStatics::AttachToSemaphore(param::hstring const& name, winrt::Windows::System::Threading::Core::SignalHandler const& handler, winrt::Windows::Foundation::TimeSpan const& timeout) const { void* signalNotifier{}; check_hresult(WINRT_IMPL_SHIM(winrt::Windows::System::Threading::Core::ISignalNotifierStatics)->AttachToSemaphoreWithTimeout(*(void**)(&name), *(void**)(&handler), impl::bind_in(timeout), &signalNotifier)); return winrt::Windows::System::Threading::Core::SignalNotifier{ signalNotifier, take_ownership_from_abi }; } template struct delegate final : implements_delegate { delegate(H&& handler) : implements_delegate(std::forward(handler)) {} int32_t __stdcall Invoke(void* signalNotifier, bool timedOut) noexcept final try { (*this)(*reinterpret_cast(&signalNotifier), timedOut); return 0; } catch (...) { return to_hresult(); } }; #ifndef WINRT_LEAN_AND_MEAN template struct produce : produce_base { int32_t __stdcall RunAsync(void** operation) noexcept final try { clear_abi(operation); typename D::abi_guard guard(this->shim()); *operation = detach_from(this->shim().RunAsync()); return 0; } catch (...) { return to_hresult(); } }; #endif #ifndef WINRT_LEAN_AND_MEAN template struct produce : produce_base { int32_t __stdcall CreateWorkItem(void* handler, void** workItem) noexcept final try { clear_abi(workItem); typename D::abi_guard guard(this->shim()); *workItem = detach_from(this->shim().CreateWorkItem(*reinterpret_cast(&handler))); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall CreateWorkItemWithPriority(void* handler, int32_t priority, void** WorkItem) noexcept final try { clear_abi(WorkItem); typename D::abi_guard guard(this->shim()); *WorkItem = detach_from(this->shim().CreateWorkItemWithPriority(*reinterpret_cast(&handler), *reinterpret_cast(&priority))); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall CreateWorkItemWithPriorityAndOptions(void* handler, int32_t priority, uint32_t options, void** WorkItem) noexcept final try { clear_abi(WorkItem); typename D::abi_guard guard(this->shim()); *WorkItem = detach_from(this->shim().CreateWorkItemWithPriorityAndOptions(*reinterpret_cast(&handler), *reinterpret_cast(&priority), *reinterpret_cast(&options))); return 0; } catch (...) { return to_hresult(); } }; #endif #ifndef WINRT_LEAN_AND_MEAN template struct produce : produce_base { int32_t __stdcall Enable() noexcept final try { typename D::abi_guard guard(this->shim()); this->shim().Enable(); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall Terminate() noexcept final try { typename D::abi_guard guard(this->shim()); this->shim().Terminate(); return 0; } catch (...) { return to_hresult(); } }; #endif #ifndef WINRT_LEAN_AND_MEAN template struct produce : produce_base { int32_t __stdcall AttachToEvent(void* name, void* handler, void** signalNotifier) noexcept final try { clear_abi(signalNotifier); typename D::abi_guard guard(this->shim()); *signalNotifier = detach_from(this->shim().AttachToEvent(*reinterpret_cast(&name), *reinterpret_cast(&handler))); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall AttachToEventWithTimeout(void* name, void* handler, int64_t timeout, void** signalNotifier) noexcept final try { clear_abi(signalNotifier); typename D::abi_guard guard(this->shim()); *signalNotifier = detach_from(this->shim().AttachToEvent(*reinterpret_cast(&name), *reinterpret_cast(&handler), *reinterpret_cast(&timeout))); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall AttachToSemaphore(void* name, void* handler, void** signalNotifier) noexcept final try { clear_abi(signalNotifier); typename D::abi_guard guard(this->shim()); *signalNotifier = detach_from(this->shim().AttachToSemaphore(*reinterpret_cast(&name), *reinterpret_cast(&handler))); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall AttachToSemaphoreWithTimeout(void* name, void* handler, int64_t timeout, void** signalNotifier) noexcept final try { clear_abi(signalNotifier); typename D::abi_guard guard(this->shim()); *signalNotifier = detach_from(this->shim().AttachToSemaphore(*reinterpret_cast(&name), *reinterpret_cast(&handler), *reinterpret_cast(&timeout))); return 0; } catch (...) { return to_hresult(); } }; #endif } WINRT_EXPORT namespace winrt::Windows::System::Threading::Core { inline PreallocatedWorkItem::PreallocatedWorkItem(winrt::Windows::System::Threading::WorkItemHandler const& handler) : PreallocatedWorkItem(impl::call_factory([&](IPreallocatedWorkItemFactory const& f) { return f.CreateWorkItem(handler); })) { } inline PreallocatedWorkItem::PreallocatedWorkItem(winrt::Windows::System::Threading::WorkItemHandler const& handler, winrt::Windows::System::Threading::WorkItemPriority const& priority) : PreallocatedWorkItem(impl::call_factory([&](IPreallocatedWorkItemFactory const& f) { return f.CreateWorkItemWithPriority(handler, priority); })) { } inline PreallocatedWorkItem::PreallocatedWorkItem(winrt::Windows::System::Threading::WorkItemHandler const& handler, winrt::Windows::System::Threading::WorkItemPriority const& priority, winrt::Windows::System::Threading::WorkItemOptions const& options) : PreallocatedWorkItem(impl::call_factory([&](IPreallocatedWorkItemFactory const& f) { return f.CreateWorkItemWithPriorityAndOptions(handler, priority, options); })) { } inline auto SignalNotifier::AttachToEvent(param::hstring const& name, winrt::Windows::System::Threading::Core::SignalHandler const& handler) { return impl::call_factory([&](ISignalNotifierStatics const& f) { return f.AttachToEvent(name, handler); }); } inline auto SignalNotifier::AttachToEvent(param::hstring const& name, winrt::Windows::System::Threading::Core::SignalHandler const& handler, winrt::Windows::Foundation::TimeSpan const& timeout) { return impl::call_factory([&](ISignalNotifierStatics const& f) { return f.AttachToEvent(name, handler, timeout); }); } inline auto SignalNotifier::AttachToSemaphore(param::hstring const& name, winrt::Windows::System::Threading::Core::SignalHandler const& handler) { return impl::call_factory([&](ISignalNotifierStatics const& f) { return f.AttachToSemaphore(name, handler); }); } inline auto SignalNotifier::AttachToSemaphore(param::hstring const& name, winrt::Windows::System::Threading::Core::SignalHandler const& handler, winrt::Windows::Foundation::TimeSpan const& timeout) { return impl::call_factory([&](ISignalNotifierStatics const& f) { return f.AttachToSemaphore(name, handler, timeout); }); } template SignalHandler::SignalHandler(L handler) : SignalHandler(impl::make_delegate(std::forward(handler))) { } template SignalHandler::SignalHandler(F* handler) : SignalHandler([=](auto&&... args) { return handler(args...); }) { } template SignalHandler::SignalHandler(O* object, M method) : SignalHandler([=](auto&&... args) { return ((*object).*(method))(args...); }) { } template SignalHandler::SignalHandler(com_ptr&& object, M method) : SignalHandler([o = std::move(object), method](auto&&... args) { return ((*o).*(method))(args...); }) { } template SignalHandler::SignalHandler(weak_ref&& object, LM&& lambda_or_method) : SignalHandler([o = std::move(object), lm = std::forward(lambda_or_method)](auto&&... args) { if (auto s = o.get()) { if constexpr (std::is_member_function_pointer_v) ((*s).*(lm))(args...); else lm(args...); } }) { } template SignalHandler::SignalHandler(std::shared_ptr&& object, M method) : SignalHandler([o = std::move(object), method](auto&&... args) { return ((*o).*(method))(args...); }) { } template SignalHandler::SignalHandler(std::weak_ptr&& object, LM&& lambda_or_method) : SignalHandler([o = std::move(object), lm = std::forward(lambda_or_method)](auto&&... args) { if (auto s = o.lock()) { if constexpr (std::is_member_function_pointer_v) ((*s).*(lm))(args...); else lm(args...); } }) { } inline auto SignalHandler::operator()(winrt::Windows::System::Threading::Core::SignalNotifier const& signalNotifier, bool timedOut) const { check_hresult((*(impl::abi_t**)this)->Invoke(*(void**)(&signalNotifier), timedOut)); } } namespace std { #ifndef WINRT_LEAN_AND_MEAN template<> struct hash : winrt::impl::hash_base {}; template<> struct hash : winrt::impl::hash_base {}; template<> struct hash : winrt::impl::hash_base {}; template<> struct hash : winrt::impl::hash_base {}; template<> struct hash : winrt::impl::hash_base {}; template<> struct hash : winrt::impl::hash_base {}; #endif #ifdef __cpp_lib_format #endif } #endif