




> rg volatile src/ | cat
src/game/server/gamecontext.cpp: static volatile int ReentryGuard = 0;
src/game/server/gamecontext.cpp: static volatile int ReentryGuard = 0;
src/base/system.cpp: *((volatile unsigned *)0) = 0x0;
src/engine/server/server.cpp: static volatile int s_ReentryGuard = 0;
src/engine/client/client.h: volatile int m_GfxState;
src/engine/client/sound.cpp:static volatile int m_SoundVolume = 100;
src/engine/client/backend_sdl.h: CCommandBuffer *volatile m_pBuffer;
src/engine/client/backend_sdl.h: volatile bool m_Shutdown;

m_GfxState is unused, can be removedm_SoundVolume should be an atomic, its access weirdly but not completely lockedm_pBuffer I don't knowm_Shutdown just replace with an std::atomic_bool





CCommandBuffer *volatile m_pBuffer;




CCommandBuffer thing looks rather over engineered










CCommandBuffer thing looks rather over engineered 






























CMD_SWAP part of CMDGROUP_CORE while it's clearly handled by SDL and thus belongs in CMDGROUP_PLATFORM_SDL?CMD_SHUTDOWNs?

CMD_SHUTDOWNs?




RunBuffer command instead to set it inside the thread?

CCommandBuffer *?




























1


happens-before the write because the write is sequenced-before the unlock, which happens-before the lock (as it synchronizes-with it) that is sequenced-before the read. You don't need to assume anything about the compilers behaviour. The abstract machine prescribes correct behaviour and thus the as-if rule guarantees the optimizer can't overreach.
m_SoundVolume (edited)


