Skip to content
Repos

DevPlaceApp

C++ 646 B18 lines Opens in site

Directory Raw Download

#pragma once
// Spec: SPEC.md NFR-THR-01. One shot timers: SDL_AddTimer fires on an SDL thread, the callback is posted to
// UiQueue so it runs on the UI thread (main loop drains the queue). Hard caps: TimerLimits (pending, delay).
#include <functional>

#include "net/HttpTypes.hpp"

namespace dp {

class Timer {
 public:
  // Runs `fn` on the UI thread after `delayMs`. Cancelling the token before it fires skips `fn`.
  // At the pending cap the timer is refused: the token comes back cancelled and a warning is logged.
  static CancelPtr after(unsigned delayMs, std::function<void()> fn);
  static unsigned pending();
};

}  // namespace dp
28.3ms