| 1019 | } |
| 1020 | |
| 1021 | inline auto _static_thread_pool::thread_state::try_steal(std::span<workstealing_victim> victims) |
| 1022 | -> _static_thread_pool::thread_state::pop_result |
| 1023 | { |
| 1024 | if (victims.empty()) |
| 1025 | { |
| 1026 | return {.task = nullptr, .queue_index = index_}; |
| 1027 | } |
| 1028 | std::uniform_int_distribution<std::uint32_t> dist(0, |
| 1029 | static_cast<std::uint32_t>(victims.size() |
| 1030 | - 1)); |
| 1031 | std::uint32_t victim_index = dist(rng_); |
| 1032 | auto& v = victims[victim_index]; |
| 1033 | return {.task = v.try_steal(), .queue_index = v.index()}; |
| 1034 | } |
| 1035 | |
| 1036 | inline auto _static_thread_pool::thread_state::try_steal_near() |
| 1037 | -> _static_thread_pool::thread_state::pop_result |