summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Huston <shuston@riverace.com>2004-12-01 20:02:59 +0000
committerSteve Huston <shuston@riverace.com>2004-12-01 20:02:59 +0000
commit0786281014f950d669151f67f15d32756947ac71 (patch)
tree30b7723af985773ad3d6558c16e837e2101cb04f
parent1215e23838e721569eaf0b317c98cdcb73ac3a4e (diff)
downloadATCD-0786281014f950d669151f67f15d32756947ac71.tar.gz
ChangeLogTag:Wed Dec 1 15:01:39 2004 Steve Huston <shuston@riverace.com>
-rw-r--r--ChangeLog8
-rw-r--r--examples/APG/Threads/Guards.cpp31
-rw-r--r--examples/APG/Threads/Message_Blocks.cpp12
3 files changed, 47 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 06abe6fc465..612101e3000 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Wed Dec 1 15:01:39 2004 Steve Huston <shuston@riverace.com>
+
+ * examples/APG/Threads/Guards.cpp:
+ * examples/APG/Threads/Message_Blocks.cpp: Enabled the code here that
+ was previously blocked out. Fixed narrow/wide-char spec for a
+ string to ACE_Log_Msg. Thanks to Johnny Willemsen for pointing
+ out that none of this code was actually getting compiled.
+
Wed Dec 1 08:49:12 UTC 2004 Martin Corino <mcorino@remedy.nl>
* include/makeinclude/platform_vxworks5.5.x.GNU:
diff --git a/examples/APG/Threads/Guards.cpp b/examples/APG/Threads/Guards.cpp
index 7553a696410..c3fa677ddd2 100644
--- a/examples/APG/Threads/Guards.cpp
+++ b/examples/APG/Threads/Guards.cpp
@@ -1,8 +1,29 @@
// $Id$
#include "ace/OS_main.h"
+#include "ace/OS_Memory.h"
+#include "ace/Guard_T.h"
+#include "ace/Log_Msg.h"
+#include "ace/Thread_Mutex.h"
+
+// This file exists primarily to get code into the book to show different
+// ways to do the same thing. For complete context and explanation, please
+// see APG chapter 12.
+
+class HA_Device_Repository {
+public:
+ int update_device (int device_id);
+
+private:
+ ACE_Thread_Mutex mutex_;
+};
+
+class Object {
+};
+static Object *object;
#if 0
+// This is less-desired way to do this...
// Listing 1 code/ch12
int
@@ -37,6 +58,8 @@ HA_Device_Repository::update_device (int device_id)
// Guard is destroyed, automatically releasing the lock.
}
// Listing 2
+#endif /* 0 */
+
// Listing 3 code/ch12
int
HA_Device_Repository::update_device (int device_id)
@@ -46,9 +69,13 @@ HA_Device_Repository::update_device (int device_id)
ACE_NEW_RETURN (object, Object, -1);
// Use the object.
// ...
+ return 0;
}
// Listing 3
-#endif /* 0 */
int ACE_TMAIN (int, ACE_TCHAR *[])
-{ return 0; }
+{
+ HA_Device_Repository rep;
+ rep.update_device (42);
+ return 0;
+}
diff --git a/examples/APG/Threads/Message_Blocks.cpp b/examples/APG/Threads/Message_Blocks.cpp
index 1bab50419e6..96cbf3e8cfe 100644
--- a/examples/APG/Threads/Message_Blocks.cpp
+++ b/examples/APG/Threads/Message_Blocks.cpp
@@ -1,10 +1,16 @@
// $Id$
#include "ace/OS_main.h"
+#include "ace/OS_Memory.h"
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_NS_string.h"
+#include "ace/Log_Msg.h"
+#include "ace/Message_Block.h"
int ACE_TMAIN (int, ACE_TCHAR **)
{
#if 0
+// Just for the book...
// Listing 1 code/ch12
ACE_Message_Block *mb;
@@ -13,6 +19,7 @@ int ACE_TMAIN (int, ACE_TCHAR **)
const char *deviceAddr= "Dev#12";
mb->copy (deviceAddr, ACE_OS::strlen (deviceAddr)+1);
// Listing 1
+#endif /* 0 */
// Listing 2 code/ch12
ACE_Message_Block *mb;
ACE_NEW_RETURN (mb, ACE_Message_Block (128), -1);
@@ -25,7 +32,7 @@ int ACE_TMAIN (int, ACE_TCHAR **)
// Listing 2
// Listing 3 code/ch12
ACE_DEBUG((LM_DEBUG,
- ACE_TEXT ("Command Sequence --> %s\n"),
+ ACE_TEXT ("Command Sequence --> %C\n"),
mb->rd_ptr ()));
mb->rd_ptr (ACE_OS::strlen (mb->rd_ptr ())+1);
mb->release ();
@@ -37,6 +44,7 @@ int ACE_TMAIN (int, ACE_TCHAR **)
// Send an error notification to the receiver.
mb->msg_type (ACE_Message_Block::MB_ERROR);
// Listing 4
-#endif
+ mb->release ();
+
return 0;
}