0

I am trying to create a function that returns a time stamp for a few seconds into the future.

Currently my attempt has been

struct timeval time;
gettimeofday(&time, NULL);
time.tv_usec += 10; // 10 seconds into the future

I will then later get a gettimeofday and do a comparison

And then do the comparison with the macro on this other stack overflow post.

To figure out when I can do the 10 seconds later code.

Is this correct? I dont fully understand the mechanics of struct timeval and like if there would be edge cases if I for example tried to increment by a sub 1 amount of seconds or perhaps an above hour amount of seconds.

CalebK
  • 353
  • 2
  • 11
  • Please review std::promise and std::future. And perhaps the tutorial at "https://thispointer.com/c11-multithreading-part-8-stdfuture-stdpromise-and-returning-values-from-thread/". There are many tutorials that seem related. – 2785528 May 17 '20 at 21:03
  • 1
    `tv_usec` holds microseconds, not seconds. – Igor Tandetnik May 17 '20 at 21:52

0 Answers0