Hello,
I hope you're well and you enjoy 2020. I'm writing you a
short message about a C++ proposal. Of course, the C++ is my favorite
programming language and I have an idea about a new std class or struct
that doesn't yet exist. I think it could be cool to have a
std::timer similar to the win32 timer
(
https://docs.microsoft.com/en-us/windows/win32/winmsg/using-timers) or
the qt timer (
https://doc.qt.io/qt-5/qtimer.html) or the GLUT timer
(
https://linux.die.net/man/3/gluttimerfunc) or ...
The implementation can be discuted of course. It can use std::chrono, std::thread, std::function and more.
This is a draft.
namespace std
{
class timer
{
public:
timer(); // constructor
// ANOTHER VERSION OF THE CONSTRUCTORS : THE ADVANCED VERSION with which thread to use for the call of the callback
timer(); // will call the callback on the main thread (or the thread where the timer has been constructed)
timer(thread_id); // will use this thread_id for the call of the callback