Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / ACE / tests / Message_Queue_Test_Ex.h
blobcf2417410c69c2e4350fc8593fd80ca50b8bbf6e
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file Message_Queue_Test_Ex.h
7 * Define class needed for generating templates. IBM C++ requires this
8 * to be in its own file for auto template instantiation.
10 * @author Michael Vitlo <mvitalo@sprynet.com>
11 * @author Irfan Pyarali <irfan@cs.wustl.edu>
12 * @author David L. Levine <levine@cs.wustl.edu>
13 * @author Guy Peleg <guy.peleg@amdocs.com>
15 //=============================================================================
17 #ifndef ACE_TESTS_MESSAGE_QUEUE_TEST_EX_H
18 #define ACE_TESTS_MESSAGE_QUEUE_TEST_EX_H
20 #include "ace/OS_NS_string.h"
22 // User-defined class used for queue data.
23 class User_Class
25 public:
26 User_Class (const char inputMsg[])
27 : message_ (0),
28 next_(0)
30 ACE_NEW (this->message_, char[ACE_OS::strlen (inputMsg) + 1]);
31 ACE_OS::strcpy (this->message_, inputMsg);
34 ~User_Class (void) { delete [] this->message_; }
36 const char *message (void) const
38 return this->message_;
41 // This is for checking the ACE_Message_Queue_Ex_N
42 User_Class *next () const
44 return this->next_;
47 void next (User_Class *uc)
49 this->next_ = uc;
52 private:
53 char *message_;
54 User_Class *next_;
57 // The main tests for the ACE_Message_Queue_Ex_N
58 struct Receive_Messages;
60 class MQ_Ex_N_Tester
62 public:
63 int single_thread_performance_test (void);
65 #if defined (ACE_HAS_THREADS)
66 int performance_test (void);
68 /// Sender runs with an autonomous thread
69 static ACE_THR_FUNC_RETURN sender (void *);
71 /// Receiver runs with an autonomous thread
72 static ACE_THR_FUNC_RETURN receiver (void *);
74 /// Multi threaded tests use this queue
75 ACE_Message_Queue_Ex_N<User_Class, ACE_MT_SYNCH> mt_queue_;
76 #endif /* ACE_HAS_THREADS */
78 /// Single threaded tests use this queue
79 ACE_Message_Queue_Ex_N<User_Class, ACE_NULL_SYNCH> st_queue_;
81 private:
82 /// Helper methods
83 int test_enqueue_head (void);
84 int test_enqueue_tail (void);
87 #endif /* ACE_TESTS_MESSAGE_QUEUE_TEST_EX_H */