846 $type$ x = ($type$) vh.get(array, i); |
846 $type$ x = ($type$) vh.get(array, i); |
847 assertEquals(x, VALUE_1, "failing compareAndExchangeRelease $type$ value"); |
847 assertEquals(x, VALUE_1, "failing compareAndExchangeRelease $type$ value"); |
848 } |
848 } |
849 |
849 |
850 { |
850 { |
851 boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); |
851 boolean success = false; |
852 assertEquals(r, true, "weakCompareAndSet $type$"); |
852 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
|
853 success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); |
|
854 } |
|
855 assertEquals(success, true, "weakCompareAndSet $type$"); |
853 $type$ x = ($type$) vh.get(array, i); |
856 $type$ x = ($type$) vh.get(array, i); |
854 assertEquals(x, VALUE_2, "weakCompareAndSet $type$ value"); |
857 assertEquals(x, VALUE_2, "weakCompareAndSet $type$ value"); |
855 } |
858 } |
856 |
859 |
857 { |
860 { |
858 boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); |
861 boolean success = false; |
859 assertEquals(r, true, "weakCompareAndSetAcquire $type$"); |
862 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
|
863 success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); |
|
864 } |
|
865 assertEquals(success, true, "weakCompareAndSetAcquire $type$"); |
860 $type$ x = ($type$) vh.get(array, i); |
866 $type$ x = ($type$) vh.get(array, i); |
861 assertEquals(x, VALUE_1, "weakCompareAndSetAcquire $type$"); |
867 assertEquals(x, VALUE_1, "weakCompareAndSetAcquire $type$"); |
862 } |
868 } |
863 |
869 |
864 { |
870 { |
865 boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); |
871 boolean success = false; |
866 assertEquals(r, true, "weakCompareAndSetRelease $type$"); |
872 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
|
873 success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); |
|
874 } |
|
875 assertEquals(success, true, "weakCompareAndSetRelease $type$"); |
867 $type$ x = ($type$) vh.get(array, i); |
876 $type$ x = ($type$) vh.get(array, i); |
868 assertEquals(x, VALUE_2, "weakCompareAndSetRelease $type$"); |
877 assertEquals(x, VALUE_2, "weakCompareAndSetRelease $type$"); |
869 } |
878 } |
870 |
879 |
871 // Compare set and get |
880 // Compare set and get |
992 $type$ x = ($type$) vh.get(array, i); |
1001 $type$ x = ($type$) vh.get(array, i); |
993 assertEquals(x, VALUE_1, "failing compareAndExchangeRelease $type$ value"); |
1002 assertEquals(x, VALUE_1, "failing compareAndExchangeRelease $type$ value"); |
994 } |
1003 } |
995 |
1004 |
996 { |
1005 { |
997 boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); |
1006 boolean success = false; |
998 assertEquals(r, true, "weakCompareAndSet $type$"); |
1007 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
|
1008 success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); |
|
1009 } |
|
1010 assertEquals(success, true, "weakCompareAndSet $type$"); |
999 $type$ x = ($type$) vh.get(array, i); |
1011 $type$ x = ($type$) vh.get(array, i); |
1000 assertEquals(x, VALUE_2, "weakCompareAndSet $type$ value"); |
1012 assertEquals(x, VALUE_2, "weakCompareAndSet $type$ value"); |
1001 } |
1013 } |
1002 |
1014 |
1003 { |
1015 { |
1004 boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); |
1016 boolean success = false; |
1005 assertEquals(r, true, "weakCompareAndSetAcquire $type$"); |
1017 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
|
1018 success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); |
|
1019 } |
|
1020 assertEquals(success, true, "weakCompareAndSetAcquire $type$"); |
1006 $type$ x = ($type$) vh.get(array, i); |
1021 $type$ x = ($type$) vh.get(array, i); |
1007 assertEquals(x, VALUE_1, "weakCompareAndSetAcquire $type$"); |
1022 assertEquals(x, VALUE_1, "weakCompareAndSetAcquire $type$"); |
1008 } |
1023 } |
1009 |
1024 |
1010 { |
1025 { |
1011 boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); |
1026 boolean success = false; |
1012 assertEquals(r, true, "weakCompareAndSetRelease $type$"); |
1027 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
|
1028 success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); |
|
1029 } |
|
1030 assertEquals(success, true, "weakCompareAndSetRelease $type$"); |
1013 $type$ x = ($type$) vh.get(array, i); |
1031 $type$ x = ($type$) vh.get(array, i); |
1014 assertEquals(x, VALUE_2, "weakCompareAndSetRelease $type$"); |
1032 assertEquals(x, VALUE_2, "weakCompareAndSetRelease $type$"); |
1015 } |
1033 } |
1016 |
1034 |
1017 // Compare set and get |
1035 // Compare set and get |