How 'undefined' a race condition can be?

前端 未结 7 528
甜味超标
甜味超标 2021-01-03 02:49

Let\'s say I define a following C++ object:

class AClass
{
public:
    AClass() : foo(0) {}
    uint32_t getFoo() { return foo; }
    void changeFoo() { foo          


        
7条回答
  •  我在风中等你
    2021-01-03 03:09

    In practice, all mainstream 32-bit architectures perform 32-bit reads and writes atomically. You'll never see anything other than 0 or 5.

提交回复
热议问题