45 : std::runtime_error(
"Stop requested!")
50static uint64_t slow_fib(
const uint16_t n, std::optional<std::stop_token> tk)
59 if (tk && tk->stop_requested())
60 throw stop_requested();
61 return slow_fib(n - 2, tk) + slow_fib(n - 1, tk);
64static uint64_t fast_fib(uint16_t n, std::optional<std::stop_token>)
66 uint64_t fib[3] = {0, 1, 1};
71 fib[2] = fib[1] + fib[0];
76template<
typename metadata_t>
77static uint64_t fib(
const uint64_t n,
const bool use_fast_fib,
80 auto fib_fn = use_fast_fib ? fast_fib : slow_fib;
82 if constexpr (pars::ev::async_event_c<
typename metadata_t::event_type,
83 metadata_t::template kind_type>)
84 return fib_fn(n, md.stop_token());