in include/unifex/win32/windows_thread_pool.hpp [509:542]
void start_impl(const StopToken& stopToken, FILETIME dueTime) noexcept {
auto startTimer = [&]() noexcept {
const DWORD periodInMs = 0; // Single-shot
const DWORD maxDelayInMs = 0; // Max delay to allow timer coalescing
::SetThreadpoolTimer(timer_, &dueTime, periodInMs, maxDelayInMs);
};
if constexpr (!is_stop_never_possible_v<StopToken>) {
auto* const state = state_;
if (state != nullptr) {
// Short-circuit extra work submitting the
// timer if stop has already been requested.
if (stopToken.stop_requested()) {
set_done_impl();
return;
}
stopCallback_.construct(stopToken, stop_requested_callback{*this});
startTimer();
const auto prevState = state->fetch_add(submit_complete_flag, std::memory_order_acq_rel);
if ((prevState & stop_requested_flag) != 0) {
complete_with_done();
} else if ((prevState & running_flag) != 0) {
delete state;
}
return;
}
}
startTimer();
}