How fast std::time(NULL)
comparing to just reading variable? I plan to use std::time(NULL)
in low-latency application for trading. I'm thinking what is better:
- just call
std::time(NULL)
every time I need it - in special thread (which I already have) periodically update global variable and assign
std::time(NULL)
to it, read this variable from all other places from other threads
Second appraoch is less accurate, but will it be faster? I don't need accuracy, I need speed. If second approach makes sense then how should I declare my variable? volatile std::time_t
or std::atomic<std::time_t>
or something else? I write this variable from one thread and read it from many threads.