I have a question about race conditions and simultaneous writes.
I have a class who's objects are accessed from different threads. I would like to calculate some values only on demand and cache the result. For performance reasons I'd rather not use locks (before anyone asks - yes it is relevant in my case).
This constitutes a race condition. However, the objects are const and won't be changed. So if different threads calculate values to be cached they are in my use case guaranteed to be identical. Would it be safe to write these values without locking? Or, in broader terms, is it safe to write identical content to memory from different threads without locking?
The values written are of types bool and double and the architectures in question may be x86 and ARM.
EDIT: Thanx to everyone for their input. I have finally decided to find a way that does not involve caching. This approach does seem to much like a 'hack' and there is the problem with using a flag variable.