Cleanup ACE_HAS_PTHREAD_SIGMASK_PROTOTYPE, all platforms support it so far as I can...
[ACE_TAO.git] / ACE / performance-tests / Synch-Benchmarks / Perf_Test / conds_test.cpp
blob66bea60448d6fa999f7fdbf2ccace0267d19d28d
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_Signal_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_Signal_Test::mutex;
21 int Cond_Signal_Test::resources;
22 ACE_Condition_Thread_Mutex Cond_Signal_Test::notfull (Cond_Signal_Test::mutex);
23 ACE_Condition_Thread_Mutex Cond_Signal_Test::notempty (Cond_Signal_Test::mutex);
25 int
26 Cond_Signal_Test::svc ()
28 int ni = this->thr_id ();
29 synch_count = 2;
31 // This is a horrible hack and only works for Solaris threads. This
32 // clearly needs to change...
33 if (ni == 4)
34 while (!this->done ())
36 mutex.acquire ();
38 while (resources > 0)
39 notfull.wait ();
41 performance_test_options.thr_work_count[ni]++;
42 resources = performance_test_options.thr_count () - 1;
43 buffer++;
44 notempty.signal ();
45 mutex.release ();
47 else
48 while (!this->done ())
50 mutex.acquire ();
51 while (resources == 0)
52 notempty.wait ();
53 performance_test_options.thr_work_count[ni]++;
54 buffer++;
55 if (--resources == 0)
56 notfull.signal ();
57 mutex.release ();
60 /* NOTREACHED */
61 return 0;
64 ACE_SVC_FACTORY_DECLARE (Cond_Signal_Test)
65 ACE_SVC_FACTORY_DEFINE (Cond_Signal_Test)
67 // ACE_Service_Object_Type cst (&cond_signal_test, "Condition_Signal_Test");
68 #endif /* ACE_HAS_THREADS */