Let\'s say I define a following C++ object:
class AClass
{
public:
AClass() : foo(0) {}
uint32_t getFoo() { return foo; }
void changeFoo() { foo
Not sure what you're looking for. On most modern architectures, there is a very distinct possibility that getFoo()
always returns 0
, even after changeFoo
has been called. With just about any decent compiler, it's almost guaranteed that getFoo()
, will always return the same value, regardless of any calls to changeFoo
, if it is called in a tight loop.
Of course, in any real program, there will be other reads and writes, which will be totally unsynchronized with regards to the changes in foo
.
And finally, there are 16 bit processors, and there may also be a possibility with some compilers that the uint32_t
isn't aligned, so that the accesses won't be atomic. (Of course, you're only changing bits in one of the bytes, so this might not be an issue.)