Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / ACE / tests / Message_Queue_Test_Ex.h
blobbe8f9b2752348a9e0c5a5324ec105a90ea5ea481
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file Message_Queue_Test_Ex.h
7 * Define class needed for generating templates.
9 * @author Michael Vitlo <mvitalo@sprynet.com>
10 * @author Irfan Pyarali <irfan@cs.wustl.edu>
11 * @author David L. Levine <levine@cs.wustl.edu>
12 * @author Guy Peleg <guy.peleg@amdocs.com>
14 //=============================================================================
16 #ifndef ACE_TESTS_MESSAGE_QUEUE_TEST_EX_H
17 #define ACE_TESTS_MESSAGE_QUEUE_TEST_EX_H
19 #include "ace/OS_NS_string.h"
21 // User-defined class used for queue data.
22 class User_Class
24 public:
25 User_Class (const char inputMsg[])
27 ACE_NEW (this->message_, char[ACE_OS::strlen (inputMsg) + 1]);
28 ACE_OS::strcpy (this->message_, inputMsg);
31 ~User_Class () { delete [] this->message_; }
33 const char *message () const
35 return this->message_;
38 // This is for checking the ACE_Message_Queue_Ex_N
39 User_Class *next () const
41 return this->next_;
44 void next (User_Class *uc)
46 this->next_ = uc;
49 private:
50 char *message_ {};
51 User_Class *next_ {};
54 // The main tests for the ACE_Message_Queue_Ex_N
55 struct Receive_Messages;
57 class MQ_Ex_N_Tester
59 public:
60 int single_thread_performance_test ();
62 #if defined (ACE_HAS_THREADS)
63 int performance_test ();
65 /// Sender runs with an autonomous thread
66 static ACE_THR_FUNC_RETURN sender (void *);
68 /// Receiver runs with an autonomous thread
69 static ACE_THR_FUNC_RETURN receiver (void *);
71 /// Multi threaded tests use this queue
72 ACE_Message_Queue_Ex_N<User_Class, ACE_MT_SYNCH> mt_queue_;
73 #endif /* ACE_HAS_THREADS */
75 /// Single threaded tests use this queue
76 ACE_Message_Queue_Ex_N<User_Class, ACE_NULL_SYNCH> st_queue_;
78 private:
79 /// Helper methods
80 int test_enqueue_head ();
81 int test_enqueue_tail ();
84 #endif /* ACE_TESTS_MESSAGE_QUEUE_TEST_EX_H */