Use =default for skeleton copy constructor
[ACE_TAO.git] / ACE / performance-tests / Synch-Benchmarks / Perf_Test / pipe_thr_test.cpp
blobc63cbd2af1f96d3a77df83035012c0918598bc06
1 #define ACE_BUILD_SVC_DLL
2 #include "ace/OS_NS_stdio.h"
3 #include "ace/OS_NS_unistd.h"
4 #include "ace/Thread_Manager.h"
5 #include "Performance_Test_Options.h"
6 #include "Benchmark_Performance.h"
8 #if defined (ACE_HAS_THREADS)
10 class ACE_Svc_Export Pipe_Thr_Test : public Benchmark_Performance
12 public:
13 virtual int init (int, ACE_TCHAR **);
14 virtual int svc ();
16 private:
17 ACE_HANDLE pipe_handles[2];
19 static void *reader (Pipe_Thr_Test *);
22 void *
23 Pipe_Thr_Test::reader (Pipe_Thr_Test *t)
25 ACE_HANDLE handle = t->pipe_handles[0];
26 int ni = t->thr_id ();
27 size_t length = performance_test_options.msg_size ();
28 char *to;
29 ACE_NEW_RETURN (to, char[length], 0);
31 while (ACE_OS::read (handle, to, length) > 0)
32 performance_test_options.thr_work_count[ni]++;
34 return 0;
37 int
38 Pipe_Thr_Test::init (int, ACE_TCHAR **)
40 synch_count = 1;
42 if (ACE_OS::pipe (this->pipe_handles) == -1)
43 ACE_OS::perror (ACE_TEXT("pipe")), ACE_OS::exit (1);
45 if (ACE_Thread_Manager::instance ()->spawn
46 (ACE_THR_FUNC (Pipe_Thr_Test::reader),
47 (void *) this, performance_test_options.t_flags ()) == -1)
48 ACE_OS::perror (ACE_TEXT("thr_create")), ACE_OS::exit (1);
50 return 1;
53 int
54 Pipe_Thr_Test::svc ()
56 ssize_t length = performance_test_options.msg_size ();
57 ACE_HANDLE handle = this->pipe_handles[1];
58 char *from;
59 ACE_NEW_RETURN (from, char[length], -1);
61 while (!this->done ())
62 if (ACE_OS::write (handle, from, length) != length)
63 ACE_OS::perror (ACE_TEXT("write"));
65 ACE_OS::close (this->pipe_handles[0]);
66 ACE_OS::close (this->pipe_handles[1]);
68 return 0;
71 ACE_SVC_FACTORY_DECLARE (Pipe_Thr_Test)
72 ACE_SVC_FACTORY_DEFINE (Pipe_Thr_Test)
74 // ACE_Service_Object_Type ptt (&pipe_thr_test, "Pipe_Thr_Test");
75 #endif /* ACE_HAS_THREADS */