peakzhang 发表于 2007-12-27 23:35:04

ACE_LOCK和ACE_Mutex之间的关系

请问ACE_LOCK和ACE_Mutex之间的关系是怎样的?
在ACE_GAURD模版中的参数是ACE_LOCK,但举例中
ACE_GAURD模版中的参数却是ACE_Mutex类型。
为什么?

peakzhang 发表于 2007-12-27 23:35:15

ACE_Mutex 是ACE_GUARD 锁中的一种

peakzhang 发表于 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;

代码里面说的很清楚啊

peakzhang 发表于 2007-12-27 23:35:37

上面已经回答你了,ACE_Mutex 是ACE_GUARD 锁中的一种。
它是ACE_GUARD宏的参数,定义在Global_Macros.h
页: [1]
查看完整版本: ACE_LOCK和ACE_Mutex之间的关系