I have a thread that writes to a struct, and it needs access to that struct all the time. I don't want to use a mutex to allow other threads to access this struct, because I don't want the first thread to ever have to wait for access to the data in the struct.
My solution is to write a copy of the struct every time it modifies the data, so other threads can access the copy of the (now potentially outdated, but that doesn't matter) struct data, without interrupting the primary thread. If the primary thread needs to read the data, it references its own copy. If it needs to write the data, it writes to its own struct, and only writes a copy if that copy isn't being read from (otherwise it skips that step). I'd like to make this as efficient as possible, so I was wondering if there a way to write to 2 identical structs that's more efficient than simply writing, for example:
struct1.data1 = newdata;
struct2.data1 = newdata;
assuming that you know the data is identical, and both are being written at the exact same time.