Use =default for skeleton copy constructor
[ACE_TAO.git] / ACE / performance-tests / Synch-Benchmarks / Perf_Test / condb_test.cpp
blobc71d3eb6bfb38378a726777310afe5e4bb33d666
1 #define ACE_BUILD_SVC_DLL
2 #include "Performance_Test_Options.h"
3 #include "Benchmark_Performance.h"
5 #if defined (ACE_HAS_THREADS)
7 class ACE_Svc_Export Cond_Brdcast_Test : public Benchmark_Performance
9 public:
10 virtual int svc ();
12 private:
13 static ACE_Thread_Mutex mutex;
14 static int resources;
16 static ACE_Condition_Thread_Mutex notfull;
17 static ACE_Condition_Thread_Mutex notempty;
20 ACE_Thread_Mutex Cond_Brdcast_Test::mutex;
21 int Cond_Brdcast_Test::resources;
22 ACE_Condition_Thread_Mutex Cond_Brdcast_Test::notfull (Cond_Brdcast_Test::mutex);
23 ACE_Condition_Thread_Mutex Cond_Brdcast_Test::notempty (Cond_Brdcast_Test::mutex);
25 int
26 Cond_Brdcast_Test::svc ()
28 int ni = this->thr_id ();
29 synch_count = 2;
31 // Special case for first thread...
32 if (ni == 4)
33 while (!this->done ())
35 mutex.acquire ();
36 while (resources > 0)
37 notfull.wait ();
38 performance_test_options.thr_work_count[ni]++;
39 resources = performance_test_options.thr_count () - 1;
40 buffer++;
41 notempty.broadcast ();
42 mutex.release ();
44 else
45 while (!this->done ())
47 mutex.acquire ();
48 while (resources == 0)
49 notempty.wait ();
50 performance_test_options.thr_work_count[ni]++;
51 buffer++;
52 if (--resources == 0)
53 notfull.signal ();
54 mutex.release ();
57 /* NOTREACHED */
58 return 0;
61 ACE_SVC_FACTORY_DECLARE (Cond_Brdcast_Test)
62 ACE_SVC_FACTORY_DEFINE (Cond_Brdcast_Test)
64 // ACE_Service_Object_Type cbt (&cond_brdcast_test, "Condition_Broadcast_Test");
65 #endif /* ACE_HAS_THREADS */