COM.inc 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. //==- llvm/Support/Windows/COM.inc - Windows COM Implementation -*- C++ -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file implements the Windows portion of COM support.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. //===----------------------------------------------------------------------===//
  13. //=== WARNING: Implementation here must contain only Windows code.
  14. //===----------------------------------------------------------------------===//
  15. #include <objbase.h>
  16. namespace llvm {
  17. namespace sys {
  18. InitializeCOMRAII::InitializeCOMRAII(COMThreadingMode Threading,
  19. bool SpeedOverMemory) {
  20. DWORD Coinit = 0;
  21. if (Threading == COMThreadingMode::SingleThreaded)
  22. Coinit |= COINIT_APARTMENTTHREADED;
  23. else
  24. Coinit |= COINIT_MULTITHREADED;
  25. if (SpeedOverMemory)
  26. Coinit |= COINIT_SPEED_OVER_MEMORY;
  27. ::CoInitializeEx(nullptr, Coinit);
  28. }
  29. InitializeCOMRAII::~InitializeCOMRAII() { ::CoUninitialize(); }
  30. } // namespace sys
  31. } // namespace llvm