1// https://github.com/boostorg/thread/blob/49ab2e86197620fc0efd14368037b2b1e41a025e/src/win32/thread.cpp23// Distributed under the Boost Software License, Version 1.0. (See4// accompanying file LICENSE_1_0.txt or copy at5// http://www.boost.org/LICENSE_1_0.txt)6// (C) Copyright 2007 Anthony Williams7// (C) Copyright 2007 David Deakins8// (C) Copyright 2011-2013 Vicente J. Botet Escriba910unsigned thread::physical_concurrency() BOOST_NOEXCEPT
11{12// a bit too strict: Windows XP with SP3 would be sufficient13// Windows XP SP3より古いと実装は難しい14#ifBOOST_PLAT_WINDOWS_RUNTIME \15||( BOOST_USE_WINAPI_VERSION <= BOOST_WINAPI_VERSION_WINXP )\16||((defined(__MINGW32__)&&!defined(__MINGW64__))&& _WIN32_WINNT <0x0600)17return0;18#else19unsigned cores =0;20 DWORD size =0;2122GetLogicalProcessorInformation(NULL,&size);23if(ERROR_INSUFFICIENT_BUFFER !=GetLastError())24return0;2526 std::vector<SYSTEM_LOGICAL_PROCESSOR_INFORMATION>buffer(size);27if(GetLogicalProcessorInformation(&buffer.front(),&size)== FALSE)28return0;2930const size_t Elements = size /sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION);3132for(size_t i =0; i < Elements;++i){33if(buffer[i].Relationship == RelationProcessorCore)34++cores;35}36return cores;37#endif
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/04/07 15:19