samedi 18 janvier 2020

Is is worth to declare a size_t as std::atomic if used across 2 threads?

I have a size_t variable which is updated by a std::thread and read by another std::thread.

I know that I can mutex protect the reads and writes. But, would it be the same or would it be beneficial if I make the size_t as std::atomic<size_t>?

Aucun commentaire:

Enregistrer un commentaire