C CASTLE / MODULE NOTES
CASTLE/Modules/Chrono

MODULE 04 / 15

Chrono

A convenience umbrella for Castle durations, time points, clocks, and chrono literals.

#include "castle/chrono/chrono.hpp"

Overview

Convenience umbrella header that includes Castle durations, time points, clocks, and chrono literals in one place.

Dependencies

  • duration
  • time_point
  • clocks
  • literals

Public API

APIDescription
castle::chrono::durationFixed-ratio time quantity template.
castle::chrono::time_pointClock-relative instant template.
system_clock, steady_clock, high_resolution_clockPlatform-backed clock types and alias.
castle::chrono::literals::chrono_literals::*User-defined literals for common duration aliases.

Usage example

See samples/sample_chrono.cpp.

#include "castle/chrono/chrono.hpp"

using namespace castle::chrono::literals::chrono_literals;

int main()
{
    const auto timeout = 250_ms;
    const auto start = castle::chrono::steady_clock::now();
    const auto deadline = start + timeout;
    (void)deadline;
    return 0;
}

Constraints & notes

  • This header adds no new semantics; tick resolution, monotonicity, and overflow behavior come from the included chrono components.
  • steady_clock is the monotonic clock abstraction; system_clock is wall-clock based and may step backward or forward.
  • Duration and time-point arithmetic is unchecked and may overflow the underlying representation.