I'm aware of Container Thread Safety topic listed there: https://en.cppreference.com/w/cpp/container
But I want to know: can I use non-const member functions and const member functions concurrently without blocking (a mutex)? More specific:
- Can I use std::vector::push_back and std::vector::size concurrently?
- Can I use std::set::insert and std::set::size concurrently?
This doesn't make a practical sense commonly, but I don't need an exact result of size which I'll use, I just need a valid result at the time when I call it.
P.S. My doubts are come from there: https://www.cplusplus.com/reference/set/set/insert/ where they say for std::set::insert that
Concurrently accessing existing elements is safe
So maybe getting the size of containter is also safe.
Aucun commentaire:
Enregistrer un commentaire