Fully thread-safe shared_ptr implementation

后端 未结 9 1468
面向向阳花
面向向阳花 2021-02-02 17:02

Does anybody know of a fully thread-safe shared_ptr implementation? E.g. boost implementation of shared_ptr is thread-safe for the targets (refcounting

9条回答
  •  天涯浪人
    2021-02-02 17:39

    This may not be exactly what you want, but the boost::atomic documentation provides an example on how to use an atomic counter with intrusive_ptr. intrusive_ptr is one of the Boost smart pointers, it does "intrusive reference counting", which means the counter is "embedded" in the target instead of providing by the smart pointer.

    Boost atomic Usage Examples:

    http://www.boost.org/doc/html/atomic/usage_examples.html

提交回复
热议问题