I am using a web worker to process some data for me. The flow goes like this: main thread writes to a shared array buffer, then once done writing, uses postMessage to send the buffer to the webworker. The main thread then waits (does not read from or write to the buffer) until receiving a message back from the worker. The web worker upon receiving the message with the shared array buffer reads the data, does some processing, writes the processed data to the shared array buffer, then uses postMessage to post the shared array buffer back to the main thread. The main thread upon receiving the message, reads from the buffer.
My question is, does postMessage guarantee that the shared array buffer has up to date information visible on the worker and main threads without using atomics? I know atomics are needed for simultaneous read and writes, but in my case there are no simultaneous read and writes, and my understanding is that postMessage ensures that the state of the data at that point in time is made up-to-date and visible on the receiving end without needing atomics. Is my understanding correct?
In the application, the reading and writing is performance critical, so while I know using atomics for each read and write will for sure work, if I can avoid the overhead of atomics that would be ideal.