1 #include "ace/config-lite.h"
2 #if defined (ACE_HAS_THREADS)
5 #include "ace/Guard_T.h"
10 enum { CRITICAL
, NORMAL
};
12 virtual ~LogMessage ()
16 virtual int priority ()
22 class CriticalLogMessage
: public LogMessage
24 virtual int priority ()
26 return LogMessage::CRITICAL
;
30 // Listing 1 code/ch14
31 typedef ACE_Thread_Mutex MUTEX
;
35 void log (LogMessage
*msg
)
37 ACE_GUARD (MUTEX
, mon
, mutex_
);
38 if (msg
->priority () == LogMessage::CRITICAL
)
42 void logCritical (LogMessage
*)
44 // Acquires the same mutex as log()!
45 ACE_GUARD(MUTEX
, mon
, mutex_
);
54 int ACE_TMAIN (int, ACE_TCHAR
*[])
56 CriticalLogMessage cm
;
57 logger
.log(&cm
); // Will cause deadlock.
63 #include "ace/OS_main.h"
64 #include "ace/OS_NS_stdio.h"
66 int ACE_TMAIN (int, ACE_TCHAR
*[])
68 ACE_OS::puts (ACE_TEXT ("This example requires threads."));
72 #endif /* ACE_HAS_THREADS */