找回密码
 用户注册

QQ登录

只需一步,快速开始

查看: 7186|回复: 2

ACE_Refcounted_Auto_Ptr是否线程安全啊,看看代码

[复制链接]
发表于 2012-5-28 13:19:15 | 显示全部楼层 |阅读模式
  1. template <class X, class ACE_LOCK> inline ACE_Refcounted_Auto_Ptr_Rep<X, ACE_LOCK> *
  2. ACE_Refcounted_Auto_Ptr_Rep<X, ACE_LOCK>::attach (ACE_Refcounted_Auto_Ptr_Rep<X, ACE_LOCK>*& rep)
  3. {
  4.   if (rep == 0)
  5.     return 0;
  6.   ++rep->ref_count_;
  7.   return rep;
  8. }
复制代码
这个地方是指针引用计数++的地方,没用用锁,安全吗,请大侠指教
发表于 2012-5-28 16:37:02 | 显示全部楼层
代码里面不是写了,rep便是锁的实例啊。
 楼主| 发表于 2012-5-28 17:24:13 | 显示全部楼层
  1. ACE_INLINE long
  2. ACE_Atomic_Op<ACE_Thread_Mutex, long>::operator++ (void)
  3. {
  4. #if defined (ACE_HAS_INTRINSIC_INTERLOCKED)
  5.   return ::_InterlockedIncrement (const_cast<long *> (&this->value_));
  6. #elif defined (WIN32)
  7.   return ::InterlockedIncrement (const_cast<long *> (&this->value_));
  8. #else /* WIN32 */
  9.   return (*increment_fn_) (&this->value_);
  10. #endif /* WIN32 */
  11. }
复制代码
3q
++那个地方还搞了好多东西哦,呵呵,看到
您需要登录后才可以回帖 登录 | 用户注册

本版积分规则

Archiver|手机版|小黑屋|ACE Developer ( 京ICP备06055248号 )

GMT+8, 2024-4-26 03:05 , Processed in 0.013377 second(s), 7 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表