COM.inc 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. //===- llvm/Support/Windows/COM.inc - Windows COM Implementation *- C++ -*-===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. //
  10. // This file implements the Windows portion of COM support.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //===----------------------------------------------------------------------===//
  14. //=== WARNING: Implementation here must contain only Windows code.
  15. //===----------------------------------------------------------------------===//
  16. #include <objbase.h>
  17. namespace llvm {
  18. namespace sys {
  19. InitializeCOMRAII::InitializeCOMRAII(COMThreadingMode Threading,
  20. bool SpeedOverMemory) {
  21. DWORD Coinit = 0;
  22. if (Threading == COMThreadingMode::SingleThreaded)
  23. Coinit |= COINIT_APARTMENTTHREADED;
  24. else
  25. Coinit |= COINIT_MULTITHREADED;
  26. if (SpeedOverMemory)
  27. Coinit |= COINIT_SPEED_OVER_MEMORY;
  28. ::CoInitializeEx(nullptr, Coinit);
  29. }
  30. InitializeCOMRAII::~InitializeCOMRAII() { ::CoUninitialize(); }
  31. }
  32. }