summaryrefslogtreecommitdiff
path: root/performance-tests/Synch-Benchmarks/mutex_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'performance-tests/Synch-Benchmarks/mutex_test.cpp')
-rw-r--r--performance-tests/Synch-Benchmarks/mutex_test.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/performance-tests/Synch-Benchmarks/mutex_test.cpp b/performance-tests/Synch-Benchmarks/mutex_test.cpp
new file mode 100644
index 00000000000..ea4933945f7
--- /dev/null
+++ b/performance-tests/Synch-Benchmarks/mutex_test.cpp
@@ -0,0 +1,46 @@
+#include "ace/Synch.h"
+// @(#)mutex_test.cpp 1.1 10/18/96
+
+#include "Options.h"
+#include "Benchmark.h"
+
+#if defined (ACE_HAS_THREADS)
+
+class Mutex_Test : public Benchmark
+{
+public:
+ virtual int svc (void);
+
+private:
+ static ACE_Thread_Mutex mutex;
+};
+
+ACE_Thread_Mutex Mutex_Test::mutex;
+
+int
+Mutex_Test::svc (void)
+{
+ // Extract out the unique thread-specific value to be used as an
+ // index...
+ int ni = this->thr_id ();
+ synch_count = 2;
+
+ while (!this->done ())
+ {
+ mutex.acquire ();
+ options.thr_work_count[ni]++;
+ buffer++;
+ mutex.release ();
+ }
+ /* NOTREACHED */
+ return 0;
+}
+
+extern "C" ACE_Service_Object *mutex_test (void);
+
+ACE_Service_Object *mutex_test (void)
+{
+ return new Mutex_Test;
+}
+// ACE_Service_Object_Type mut (&mutex_test, "Mutex_Test");
+#endif /* ACE_HAS_THREADS */