(no title)
mrlongroots | 3 months ago
My only complaint is the verbosity, things like `std::chrono::nanonseconds` break even simple statements into multiple lines, and you're tempted to just use uint64_t instead. And `std::thread` is fine but if you want to name your thread you still need to get the underlying handle and call `pthread_setname_np`. It's hard work pulling off everything C++ tries to pull off.
spacechild1|3 months ago
Yes, but here we're getting deep into platform specifics. An even bigger pain point are thread priorities. Windows, macOS and Linux differ so fundamentally in this regard that it's really hard to create a meaningful abstraction. Certain things are better left to platform APIs.
nuertey2025|3 months ago
// To lessen verbosity, try defining the following convenience aliases in a header:
using SystemClock_t = std::chrono::system_clock;
using SteadyClock_t = std::chrono::steady_clock;
using HighClock_t = std::chrono::high_resolution_clock;
using SharedDelay_t = std::atomic<SystemClock_t::duration>;
using Minutes_t = std::chrono::minutes;
using Seconds_t = std::chrono::seconds;
using MilliSecs_t = std::chrono::milliseconds;
using MicroSecs_t = std::chrono::microseconds;
using NanoSecs_t = std::chrono::nanoseconds;
using DoubleSecs_t = std::chrono::duration<double>;
using FloatingMilliSecs_t = std::chrono::duration<double, std::milli>;
using FloatingMicroSecs_t = std::chrono::duration<double, std::micro>;
```