-
Notifications
You must be signed in to change notification settings - Fork 82
Thread Safety
Hannes Hauswedell edited this page Apr 28, 2017
·
2 revisions
- not thread-safe or unknown
- does not modify data (safe to be called from multiple threads, as long as no other functions modifies the data)
- modifies, but re-entrant (safe to be called from multiple threads, as long as the data is different β different parameters or member function on different object)
- thread-safe (always safe)
Some rules-of-thumb:
- All const member functions should be 2 or 4.
- All non-const member functions should be 3 or 4.
- All free functions shall be 2 or 4 (if they take only copy or
const &
parameters) or 3 or 4 (otherwise)
Every function starts with 1., but should at least guarantee 2.
TODO: maybe rename to "data races"? Use other definitions?