summaryrefslogtreecommitdiff
path: root/docs/tutorials/011/message_queue.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'docs/tutorials/011/message_queue.cpp')
-rw-r--r--docs/tutorials/011/message_queue.cpp79
1 files changed, 0 insertions, 79 deletions
diff --git a/docs/tutorials/011/message_queue.cpp b/docs/tutorials/011/message_queue.cpp
deleted file mode 100644
index 8bd1e0cc13a..00000000000
--- a/docs/tutorials/011/message_queue.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-
-// $Id$
-
-/*
- Most of this is the same as the previous tutorial, so I'll just point out
- the differences.
- */
-#include "task.h"
-#include "block.h"
-#include "data.h"
-
-int run_test (int iterations, int threads)
-{
- Task task;
-
- if (task.open (threads) == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1);
- }
-
-ACE_OS::sleep (ACE_Time_Value (1));
-
- int i;
- for (i = 0; i < iterations; ++i)
- {
- /*
- Construct a Data object that we'll put into the Queue.
- */
- Data data (i);
-
- /*
- Create a block large enough for our Data object as well as a text
- message.
- */
- Block *message = new Block (sizeof (data) + 128);
-
- /*
- As before, put a text message into the block.
- */
- ACE_OS::sprintf (message->wr_ptr (), "This is message %d.", i);
- message->wr_ptr (strlen (message->rd_ptr ()));
-
- *(message->wr_ptr ()) = 0; // Null-terminate the string we just wrote
-
- message->wr_ptr (1); // Move beyond the NULL
-
- /*
- To copy arbitrary data into a message block, we use the copy() method.
- Since it wants a 'const char*', we have to cast our Data pointer.
- */
- message->copy ((const char *) &data, sizeof (data));
- message->wr_ptr (sizeof (data));
-
- if (task.putq (message) == -1)
- {
- break;
- }
- }
-
- Block *message = new Block ();
-message->msg_type (ACE_Message_Block::MB_HANGUP);
- task.putq (message);
-
- task.wait ();
-
- return (0);
-}
-
-int main (int argc, char *argv[])
-{
- int iterations = argc > 1 ? atoi (argv[1]) : 4;
- int threads = argc > 2 ? atoi (argv[2]) : 2;
-
- (void) run_test (iterations, threads);
-
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) Application exiting\n"));
-
- return (0);
-}