Is this:
std::mutex mutex;
for () {
std::unique_lock<mutex> lock(mutex);
// do something
lock.unlock();
}
Equivalent to this in terms of releasing and acquiring the lock every iteration of the for loop?
std::mutex mutex;
for () {
std::unique_lock<mutex> lock(mutex);
// do something
}
Related questions:
- Is using unique_lock in new scope equivalent to unlock call at the end of work with shared resource?
- boost scoped_lock on mutex in while(1) loop
- Creating new pointer object in loop
- Reusing a unique_lock in a consumer loop
Aucun commentaire:
Enregistrer un commentaire