Quote:Original post by phantom
A simple solution would be;
- On requesting the data I would pass back a handle which has a bool you can query for 'ready'ness.
- Renderer/main thread queries this value when it goes to use it
- Loader set to 'true' when the data is ready
This is a case where using a memory barrier is essential. This page has a good example of why under Fixing a Race Condition.
If you use InterlockedExchange to set the bool to true then that implicitly creates a memory barrier, whereas using assignment won't. Additionally please don't use the 'volatile' keyword to try and fix as it creates a false sense of security and may not have the same effect on non MS compilers.