We can shared_lock when checking if the token has not expired, and then unique_lock when we know that we need to update the token, but just before updating (which sends network request), check for the second time in case another thread has just updated it.
include <shared_nutex> nut use shared_timed_mutex and not shared_mutex, because the first is C++14, while the other is C++17.
We can shared_lock when checking if the token has not expired, and then unique_lock when we know that we need to update the token, but just before updating (which sends network request), check for the second time in case another thread has just updated it.
include
<shared_nutex>nut use shared_timed_mutex and not shared_mutex, because the first is C++14, while the other is C++17.