why is std::shared_ptr using atomic cpu operations

后端 未结 2 1966
礼貌的吻别
礼貌的吻别 2021-02-08 02:35

I have a problem understanding why shared_ptr is using atomic cpu instructions... I cant figure out the reasons because it is NOT thread safe. Can somebody please explain.

2条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-08 03:10

    Herb Sutter just used shared_ptr as a nice example in his gotw 95, he goes there to elaborate on design decision:
    https://herbsutter.com/2014/01/13/gotw-95-solution-thread-safety-and-synchronization/

提交回复
热议问题