Daily bit(e) of C++ | std::timed_mutex, std::recursive_timed_mutex, std::shared_timed_mutex

Daily bit(e) of C++ #19, The timed mutex variants: std::timed_mutex, std::recursive_timed_mutex, std::shared_timed_mutex

Timed mutex variants (std::timed_mutex, std::recursive_timed_mutex and std::shared_timed_mutex) offer support for timeouts when waiting on a lock. The timeout the be specified as either a time point or a duration.

Adding timeouts to mutexes allows a program to give up waiting on a lock and potentially report an error instead of being stuck in a hard-to-detect state.

Open this example in Compiler Explorer.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Šimon Tóth

I'm an ex-Software Engineer and ex-Researcher focusing on providing free educational content.