summaryrefslogtreecommitdiff
path: root/examples/ASX/Message_Queue/buffer_stream.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/ASX/Message_Queue/buffer_stream.cpp')
-rw-r--r--examples/ASX/Message_Queue/buffer_stream.cpp52
1 files changed, 31 insertions, 21 deletions
diff --git a/examples/ASX/Message_Queue/buffer_stream.cpp b/examples/ASX/Message_Queue/buffer_stream.cpp
index b17d4a85d19..7c5f098972e 100644
--- a/examples/ASX/Message_Queue/buffer_stream.cpp
+++ b/examples/ASX/Message_Queue/buffer_stream.cpp
@@ -8,6 +8,7 @@
// the use of these reusable components reduces the reliance on global
// variables, as compared with the bounded_buffer.C example.
+#include "ace/OS_main.h"
#include "ace/OS_NS_stdio.h"
#include "ace/OS_NS_string.h"
#include "ace/OS_NS_time.h"
@@ -91,8 +92,8 @@ Common_Task::open (void *)
{
if (this->activate (THR_NEW_LWP | THR_DETACHED) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
- "%p\n",
- "spawn"),
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("spawn")),
-1);
return 0;
}
@@ -101,7 +102,7 @@ int
Common_Task::close (u_long exit_status)
{
ACE_DEBUG ((LM_DEBUG,
- "(%t) thread is exiting with status %d in module %s\n",
+ ACE_TEXT ("(%t) thread is exiting with status %d in module %s\n"),
exit_status,
this->name ()));
@@ -142,8 +143,8 @@ Producer::svc (void)
if (this->put_next (mb) == -1)
ACE_ERROR ((LM_ERROR,
- "(%t) %p\n",
- "put_next"));
+ ACE_TEXT ("(%t) %p\n"),
+ ACE_TEXT ("put_next")));
break;
}
@@ -157,8 +158,8 @@ Producer::svc (void)
if (this->put_next (mb) == -1)
ACE_ERROR ((LM_ERROR,
- "(%t) %p\n",
- "put_next"));
+ ACE_TEXT ("(%t) %p\n"),
+ ACE_TEXT ("put_next")));
}
}
@@ -214,13 +215,22 @@ Consumer::svc (void)
if (result == -1 && errno == EWOULDBLOCK)
ACE_ERROR ((LM_ERROR,
- "(%t) %p\n%a",
- "timed out waiting for message",
+ ACE_TEXT ("(%t) %p\n%a"),
+ ACE_TEXT ("timed out waiting for message"),
1));
return 0;
}
// The filter prepends a line number in front of each line.
+#if defined (ACE_WIN32) || !defined (ACE_USES_WCHAR)
+# if defined (ACE_WIN64)
+# define FMTSTR "%I64u: %s"
+# else
+# define FMTSTR "%u: %s"
+# endif /* ACE_WIN64 */
+#else
+# define FMTSTR "%u: %ls"
+#endif /* ACE_WIN32 || !ACE_USES_WCHAR */
int
Filter::put (ACE_Message_Block *mb,
@@ -243,7 +253,7 @@ Filter::put (ACE_Message_Block *mb,
// Prepend the line count in front of the buffer.
ACE_OS::sprintf (mb->rd_ptr (),
- ACE_SIZE_T_FORMAT_SPECIFIER": %s",
+ FMTSTR,
this->count_++,
buf);
return this->put_next (mb, tv);
@@ -253,7 +263,7 @@ Filter::put (ACE_Message_Block *mb,
// Main driver function.
int
-main (int, char *argv[])
+ACE_TMAIN (int, ACE_TCHAR *argv[])
{
ACE_Service_Config daemon (argv[0]);
@@ -265,15 +275,15 @@ main (int, char *argv[])
MT_Module *cm;
ACE_NEW_RETURN (cm,
- MT_Module ("Consumer",
+ MT_Module (ACE_TEXT ("Consumer"),
new Consumer),
-1);
ACE_NEW_RETURN (fm,
- MT_Module ("Filter",
+ MT_Module (ACE_TEXT ("Filter"),
new Filter),
-1);
ACE_NEW_RETURN (pm,
- MT_Module ("Producer",
+ MT_Module (ACE_TEXT ("Producer"),
new Producer),
-1);
@@ -282,18 +292,18 @@ main (int, char *argv[])
if (stream.push (cm) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
- "%p\n",
- "push"),
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("push")),
1);
else if (stream.push (fm) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
- "%p\n",
- "push"),
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("push")),
1);
else if (stream.push (pm) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
- "%p\n",
- "push"),
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("push")),
1);
// Barrier synchronization: wait for the threads to exit, then exit
// ourselves.
@@ -305,7 +315,7 @@ int
main (int, char *[])
{
ACE_ERROR ((LM_ERROR,
- "threads not supported on this platform\n"));
+ ACE_TEXT ("threads not supported on this platform\n")));
return 0;
}
#endif /* ACE_HAS_THREADS */