MCPcopy Create free account
hub / github.com/bshoshany/thread-pool / affinity_to_string

Function affinity_to_string

tests/BS_thread_pool_test.cpp:2983–2994  ·  view source on GitHub ↗

* @brief Convert a `std::vector ` representing CPU affinity to a string of 0s and 1s. * * @param affinity The affinity. * @return The string. */

Source from the content-addressed store, hash-verified

2981 * @return The string.
2982 */
2983std::string affinity_to_string(const std::optional<std::vector<bool>>& affinity)
2984{
2985 if (affinity.has_value())
2986 {
2987 const std::size_t num_bits = affinity->size();
2988 std::string str(num_bits, ' ');
2989 for (std::size_t i = 0; i < num_bits; ++i)
2990 str[num_bits - i - 1] = (*affinity)[i] ? '1' : '0';
2991 return str;
2992 }
2993 return "N/A";
2994}
2995
2996/**
2997 * @brief Check that getting and setting OS process affinity works.

Callers 2

check_os_thread_affinityFunction · 0.85

Calls 1

sizeMethod · 0.80

Tested by

no test coverage detected