GCC atomic shared_ptr implementation

后端 未结 1 790
春和景丽
春和景丽 2021-01-15 13:37

According to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57250, GCC 4.9 has support for atomic shared_ptr operations.

Using GCC 4.9.2,

相关标签:
1条回答
  • 2021-01-15 14:04

    "atomic shared_ptr operations" refers to the free std::atomic_(store|load|exchange|compare_exchange_strong|compare_exchange_weak)(_explicit)? function templates for shared_ptr, documented here. GCC doesn't have them until 5. (Fun fact: its implementation actually uses a global array of 16 mutexes under the hood.)

    Instantiating std::atomic over std::shared_ptr results in undefined behavior, as std::atomic requires a trivially copyable type.

    The concurrency TS has std::experimental::atomic_shared_ptr.

    0 讨论(0)
提交回复
热议问题