The open source OpenXR runtime
at main 31 lines 691 B view raw
1// Copyright 2022, Collabora, Ltd. 2// SPDX-License-Identifier: BSL-1.0 3/*! 4 * @file 5 * @brief An object that serves to keep the reference count of COM initialization greater than 0. 6 * 7 * @author Rylie Pavlik <rylie.pavlik@collabora.com> 8 * @ingroup aux_util 9 * 10 */ 11#include "u_win32_com_guard.hpp" 12#include "xrt/xrt_config_have.h" 13 14 15#if defined(XRT_OS_WINDOWS) && defined(XRT_HAVE_WIL) 16#include <wil/result.h> 17 18namespace xrt::auxiliary::util { 19 20 21ComGuard::ComGuard() 22{ 23 THROW_IF_FAILED(CoIncrementMTAUsage(&m_cookie)); 24} 25ComGuard::~ComGuard() 26{ 27 LOG_IF_FAILED(CoDecrementMTAUsage(m_cookie)); 28} 29 30} // namespace xrt::auxiliary::util 31#endif // defined(XRT_OS_WINDOWS) && defined(XRT_HAVE_WIL)