bind_processor_windows.cpp 579 B

123456789101112131415161718192021222324
  1. // Copyright Oliver Kowalke 2009.
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #include "bind_processor.hpp"
  6. extern "C"
  7. {
  8. #include <windows.h>
  9. }
  10. #include <stdexcept>
  11. #include <boost/config/abi_prefix.hpp>
  12. void bind_to_processor( unsigned int n)
  13. {
  14. if ( ::SetThreadAffinityMask( ::GetCurrentThread(), ( DWORD_PTR)1 << n) == 0)
  15. throw std::runtime_error("::SetThreadAffinityMask() failed");
  16. }
  17. #include <boost/config/abi_suffix.hpp>