【发布时间】:2015-09-22 12:08:02
【问题描述】:
在 boost doc(Shared_ptr doc) 中,我看到有一个线程不安全的例子:
//--- Example 4 ---
// thread A
p3 = p2; // reads p2, writes p3
// thread B
// p2 goes out of scope: undefined, the destructor is considered a "write access"
如何处理这种情况?如果 p2 超出范围,我该如何控制?
【问题讨论】:
-
如果我们知道你想要做什么会更有帮助。
标签: c++ boost thread-safety shared-ptr