changeset 108:fd9cb15e9cad

Migrate unsafe.* test descriptions to new API.
author shade
date Fri, 14 Mar 2014 02:59:43 +0400
parents c0600aa1b85f
children 49f7af8a9a04
files tests-custom/src/main/java/org/openjdk/jcstress/tests/unsafe/UnsafeAddLong1.java tests-custom/src/main/java/org/openjdk/jcstress/tests/unsafe/UnsafeAddLong42.java
diffstat 2 files changed, 54 insertions(+), 68 deletions(-) [+]
line wrap: on
line diff
--- a/tests-custom/src/main/java/org/openjdk/jcstress/tests/unsafe/UnsafeAddLong1.java	Fri Mar 14 02:52:34 2014 +0400
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/unsafe/UnsafeAddLong1.java	Fri Mar 14 02:59:43 2014 +0400
@@ -24,50 +24,43 @@
  */
 package org.openjdk.jcstress.tests.unsafe;
 
+import org.openjdk.jcstress.infra.annotations.Actor;
+import org.openjdk.jcstress.infra.annotations.ConcurrencyStressTest;
+import org.openjdk.jcstress.infra.annotations.State;
 import org.openjdk.jcstress.infra.results.LongResult2;
 import org.openjdk.jcstress.tests.Actor2_Test;
 import org.openjdk.jcstress.util.UnsafeHolder;
 import sun.misc.Contended;
 
-public class UnsafeAddLong1 implements Actor2_Test<UnsafeAddLong1.State, LongResult2> {
+@ConcurrencyStressTest
+@State
+public class UnsafeAddLong1 {
 
-    @Override
-    public State newState() {
-        return new State();
+    public static long OFFSET;
+
+    static {
+        try {
+            OFFSET = UnsafeHolder.U.objectFieldOffset(UnsafeAddLong1.class.getDeclaredField("x"));
+        } catch (NoSuchFieldException e) {
+            throw new IllegalStateException(e);
+        }
     }
 
-    @Override
-    public void actor1(State s, LongResult2 r) {
-        UnsafeHolder.U.getAndAddLong(s, State.OFFSET, 1L << 1);
-        s.written = 1;
+    long x;
+
+    @Contended
+    volatile int written;
+
+    @Actor
+    public void actor1() {
+        UnsafeHolder.U.getAndAddLong(this, OFFSET, 1L << 1);
+        written = 1;
     }
 
-    @Override
-    public void actor2(State s, LongResult2 r) {
-        r.r1 = s.written;
-        r.r2 = s.x;
-    }
-
-    @Override
-    public LongResult2 newResult() {
-        return new LongResult2();
-    }
-
-    public static class State {
-        public static long OFFSET;
-
-        static {
-            try {
-                OFFSET = UnsafeHolder.U.objectFieldOffset(State.class.getDeclaredField("x"));
-            } catch (NoSuchFieldException e) {
-                throw new IllegalStateException(e);
-            }
-        }
-
-        long x;
-
-        @Contended
-        volatile int written;
+    @Actor
+    public void actor2(LongResult2 r) {
+        r.r1 = written;
+        r.r2 = x;
     }
 
 }
--- a/tests-custom/src/main/java/org/openjdk/jcstress/tests/unsafe/UnsafeAddLong42.java	Fri Mar 14 02:52:34 2014 +0400
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/unsafe/UnsafeAddLong42.java	Fri Mar 14 02:59:43 2014 +0400
@@ -24,50 +24,43 @@
  */
 package org.openjdk.jcstress.tests.unsafe;
 
+import org.openjdk.jcstress.infra.annotations.Actor;
+import org.openjdk.jcstress.infra.annotations.ConcurrencyStressTest;
+import org.openjdk.jcstress.infra.annotations.State;
 import org.openjdk.jcstress.infra.results.LongResult2;
 import org.openjdk.jcstress.tests.Actor2_Test;
 import org.openjdk.jcstress.util.UnsafeHolder;
 import sun.misc.Contended;
 
-public class UnsafeAddLong42 implements Actor2_Test<UnsafeAddLong42.State, LongResult2> {
+@ConcurrencyStressTest
+@State
+public class UnsafeAddLong42 {
 
-    @Override
-    public State newState() {
-        return new State();
+    public static long OFFSET;
+
+    static {
+        try {
+            OFFSET = UnsafeHolder.U.objectFieldOffset(UnsafeAddLong42.class.getDeclaredField("x"));
+        } catch (NoSuchFieldException e) {
+            throw new IllegalStateException(e);
+        }
     }
 
-    @Override
-    public void actor1(State s, LongResult2 r) {
-        UnsafeHolder.U.getAndAddLong(s, State.OFFSET, 1L << 42);
-        s.written = 1;
+    long x;
+
+    @Contended
+    volatile int written;
+
+    @Actor
+    public void actor1() {
+        UnsafeHolder.U.getAndAddLong(this, OFFSET, 1L << 42);
+        written = 1;
     }
 
-    @Override
-    public void actor2(State s, LongResult2 r) {
-        r.r1 = s.written;
-        r.r2 = s.x;
-    }
-
-    @Override
-    public LongResult2 newResult() {
-        return new LongResult2();
-    }
-
-    public static class State {
-        public static long OFFSET;
-
-        static {
-            try {
-                OFFSET = UnsafeHolder.U.objectFieldOffset(State.class.getDeclaredField("x"));
-            } catch (NoSuchFieldException e) {
-                throw new IllegalStateException(e);
-            }
-        }
-
-        long x;
-
-        @Contended
-        volatile int written;
+    @Actor
+    public void actor2(LongResult2 r) {
+        r.r1 = written;
+        r.r2 = x;
     }
 
 }