找回密码
 用户注册

QQ登录

只需一步,快速开始

查看: 6057|回复: 3

ACE_LOCK和ACE_Mutex之间的关系

[复制链接]
发表于 2007-12-27 23:35:04 | 显示全部楼层 |阅读模式
请问ACE_LOCK和ACE_Mutex之间的关系是怎样的?
在ACE_GAURD模版中的参数是ACE_LOCK,但举例中
ACE_GAURD模版中的参数却是ACE_Mutex类型。
为什么?
 楼主| 发表于 2007-12-27 23:35:15 | 显示全部楼层
ACE_Mutex 是ACE_GUARD 锁中的一种
 楼主| 发表于 2007-12-27 23:35:27 | 显示全部楼层
// Convenient macro for testing for deadlock, as well as for detecting
// when mutexes fail.
#define ACE_GUARD_ACTION(MUTEX, OBJ, LOCK, ACTION, REACTION) \
   ACE_Guard< MUTEX > OBJ (LOCK); \
   if (OBJ.locked () != 0) { ACTION; } \
   else { REACTION; }
#define ACE_GUARD_REACTION(MUTEX, OBJ, LOCK, REACTION) \
  ACE_GUARD_ACTION(MUTEX, OBJ, LOCK, ;, REACTION)
#define ACE_GUARD(MUTEX, OBJ, LOCK) \
  ACE_GUARD_REACTION(MUTEX, OBJ, LOCK, return)
#define ACE_GUARD_RETURN(MUTEX, OBJ, LOCK, RETURN) \
  ACE_GUARD_REACTION(MUTEX, OBJ, LOCK, return RETURN)
# define ACE_WRITE_GUARD(MUTEX,OBJ,LOCK) \
  ACE_Write_Guard< MUTEX > OBJ (LOCK); \
    if (OBJ.locked () == 0) return;
# define ACE_WRITE_GUARD_RETURN(MUTEX,OBJ,LOCK,RETURN) \
  ACE_Write_Guard< MUTEX > OBJ (LOCK); \
    if (OBJ.locked () == 0) return RETURN;
# define ACE_READ_GUARD(MUTEX,OBJ,LOCK) \
  ACE_Read_Guard< MUTEX > OBJ (LOCK); \
    if (OBJ.locked () == 0) return;
# define ACE_READ_GUARD_RETURN(MUTEX,OBJ,LOCK,RETURN) \
  ACE_Read_Guard< MUTEX > OBJ (LOCK); \
    if (OBJ.locked () == 0) return RETURN;

代码里面说的很清楚啊
 楼主| 发表于 2007-12-27 23:35:37 | 显示全部楼层
上面已经回答你了,ACE_Mutex 是ACE_GUARD 锁中的一种。
它是ACE_GUARD宏的参数,定义在Global_Macros.h
您需要登录后才可以回帖 登录 | 用户注册

本版积分规则

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

GMT+8, 2024-12-23 03:14 , Processed in 0.017851 second(s), 7 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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