C++11 Concurrency Learning

The difference between unique_lock and lock_guard

lock_guard is only locked at the time of construction and unlocked at the time of destruction, while unique_lock can be unlocked and locked arbitrarily. At the same time, at the time of initialization, unique_lock has more locking strategies than lock_guard, see here for details , and unique_lock is more than lock_guard There are more member functions, see here for details .

The execution logic of wait

It is very well written here , you can refer to it, you can clearly understand why you use unique_lock instead of lock_guard in wait https://stackoverflow.com/questions/6731027/boostunique-lock-vs-boostlock-guard

How to understand future

Take a look from here

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324803767&siteId=291194637