dimanche 5 mai 2019

Performance difference between std::this_thread::sleep_for and std::condition_variable::wait_for

I've got a question regarding performance difference between using

std::this_thread::sleep_for(const std::chrono::duration<Rep, Period>& sleep_duration)

and

std::condition_variable::wait_for(std::unique_lock<std::mutex>& lock, const std::chrono::duration<Rep, Period>& rel_time)

I have heard that condition_variable does not waste any CPU cycle during waiting, how about std::thead_thread::sleep_for?

I know that condition_variable wasn't designed to be used just for waiting but I'm curious. :)

Best regards.

btw. Sorry for my english.

Aucun commentaire:

Enregistrer un commentaire