I have the following situation.
I have a thread that writes to an array. After writing to that array I need to read that array. Reading happens after writing the array and I can guarantee so through another means (this would imply I will not need condition variables, but just when reading "refreshing" contents of the array). The array is read later from another thread.
EDIT: Additionally, the writing will happen at different times, the array is not written all at once.
I need to read the full contents of the array with all entries already refreshed and with the actual values at the time of reading. Right now the values are not refreshed.
What is the best way to synchronize this?
- mutex?
- atomic?
- fences?
I am not sure how I would do it. I do know for a single variable a mutex would be enough, but this is an array. I am not sure what the correct way to do this is. I am not sure how to do it: a lock?