148 static void defer_for(duration duration, Fn&& fn, Handler&& handler, Args&&... args)
150 if (handler.is_disposed())
156 get_queue() = &queue;
158 const auto timepoint = details::immediate_scheduling_while_condition<worker_strategy>(duration,
is_queue_is_empty{queue}, fn, handler, args...);
159 if (!timepoint || handler.is_disposed())
160 return drain_queue();
162 get_queue()->emplace(timepoint.value(), std::forward<Fn>(fn), std::forward<Handler>(handler), std::forward<Args>(args)...);
163 return drain_queue();
166 get_queue()->emplace(now() + duration, std::forward<Fn>(fn), std::forward<Handler>(handler), std::forward<Args>(args)...);
170 static void defer_to(time_point tp, Fn&& fn, Handler&& handler, Args&&... args)
172 if (handler.is_disposed())
177 get_queue()->emplace(tp, std::forward<Fn>(fn), std::forward<Handler>(handler), std::forward<Args>(args)...);
181 defer_for(tp - now(), std::forward<Fn>(fn), std::forward<Handler>(handler), std::forward<Args>(args)...);
185 static rpp::schedulers::time_point now() {
return details::now(); }