207 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); |
207 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); |
208 assertEquals(x, $value1$, "failing compareAndExchangeRelease $type$ value"); |
208 assertEquals(x, $value1$, "failing compareAndExchangeRelease $type$ value"); |
209 } |
209 } |
210 |
210 |
211 { |
211 { |
212 boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, $value1$, $value2$); |
212 boolean success = false; |
213 assertEquals(r, true, "weakCompareAndSet $type$"); |
213 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
|
214 success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, $value1$, $value2$); |
|
215 } |
|
216 assertEquals(success, true, "weakCompareAndSet $type$"); |
214 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); |
217 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); |
215 assertEquals(x, $value2$, "weakCompareAndSet $type$ value"); |
218 assertEquals(x, $value2$, "weakCompareAndSet $type$ value"); |
216 } |
219 } |
217 |
220 |
218 { |
221 { |
219 boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, $value2$, $value1$); |
222 boolean success = false; |
220 assertEquals(r, true, "weakCompareAndSetAcquire $type$"); |
223 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
|
224 success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, $value2$, $value1$); |
|
225 } |
|
226 assertEquals(success, true, "weakCompareAndSetAcquire $type$"); |
221 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); |
227 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); |
222 assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$"); |
228 assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$"); |
223 } |
229 } |
224 |
230 |
225 { |
231 { |
226 boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, $value1$, $value2$); |
232 boolean success = false; |
227 assertEquals(r, true, "weakCompareAndSetRelease $type$"); |
233 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
|
234 success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, $value1$, $value2$); |
|
235 } |
|
236 assertEquals(success, true, "weakCompareAndSetRelease $type$"); |
228 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); |
237 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); |
229 assertEquals(x, $value2$, "weakCompareAndSetRelease $type$"); |
238 assertEquals(x, $value2$, "weakCompareAndSetRelease $type$"); |
230 } |
239 } |
231 |
240 |
232 { |
|
233 boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, $value2$, $value1$); |
|
234 assertEquals(r, true, "weakCompareAndSetVolatile $type$"); |
|
235 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); |
|
236 assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$ value"); |
|
237 } |
|
238 |
|
239 // Compare set and get |
241 // Compare set and get |
240 { |
242 { |
241 $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET).invokeExact(recv, $value2$); |
243 $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET).invokeExact(recv, $value1$); |
242 assertEquals(o, $value1$, "getAndSet $type$"); |
244 assertEquals(o, $value2$, "getAndSet $type$"); |
243 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); |
245 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); |
244 assertEquals(x, $value2$, "getAndSet $type$ value"); |
246 assertEquals(x, $value1$, "getAndSet $type$ value"); |
245 } |
247 } |
246 #end[CAS] |
248 #end[CAS] |
247 |
249 |
248 #if[AtomicAdd] |
250 #if[AtomicAdd] |
249 hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); |
251 hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); |
378 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
380 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
379 assertEquals(x, $value1$, "failing compareAndExchangeRelease $type$ value"); |
381 assertEquals(x, $value1$, "failing compareAndExchangeRelease $type$ value"); |
380 } |
382 } |
381 |
383 |
382 { |
384 { |
383 boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact($value1$, $value2$); |
385 boolean success = false; |
384 assertEquals(r, true, "weakCompareAndSet $type$"); |
386 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
|
387 success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact($value1$, $value2$); |
|
388 } |
|
389 assertEquals(success, true, "weakCompareAndSet $type$"); |
385 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
390 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
386 assertEquals(x, $value2$, "weakCompareAndSet $type$ value"); |
391 assertEquals(x, $value2$, "weakCompareAndSet $type$ value"); |
387 } |
392 } |
388 |
393 |
389 { |
394 { |
390 boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact($value2$, $value1$); |
395 boolean success = false; |
391 assertEquals(r, true, "weakCompareAndSetAcquire $type$"); |
396 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
|
397 success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact($value2$, $value1$); |
|
398 } |
|
399 assertEquals(success, true, "weakCompareAndSetAcquire $type$"); |
392 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
400 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
393 assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$"); |
401 assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$"); |
394 } |
402 } |
395 |
403 |
396 { |
404 { |
397 boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact($value1$, $value2$); |
405 boolean success = false; |
398 assertEquals(r, true, "weakCompareAndSetRelease $type$"); |
406 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
|
407 success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact($value1$, $value2$); |
|
408 } |
|
409 assertEquals(success, true, "weakCompareAndSetRelease $type$"); |
399 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
410 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
400 assertEquals(x, $value2$, "weakCompareAndSetRelease $type$"); |
411 assertEquals(x, $value2$, "weakCompareAndSetRelease $type$"); |
401 } |
412 } |
402 |
413 |
403 { |
|
404 boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact($value2$, $value1$); |
|
405 assertEquals(r, true, "weakCompareAndSetVolatile $type$"); |
|
406 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
|
407 assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$ value"); |
|
408 } |
|
409 |
|
410 // Compare set and get |
414 // Compare set and get |
411 { |
415 { |
412 $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET).invokeExact($value2$); |
416 $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET).invokeExact( $value1$); |
413 assertEquals(o, $value1$, "getAndSet $type$"); |
417 assertEquals(o, $value2$, "getAndSet $type$"); |
414 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
418 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); |
415 assertEquals(x, $value2$, "getAndSet $type$ value"); |
419 assertEquals(x, $value1$, "getAndSet $type$ value"); |
416 } |
420 } |
417 #end[CAS] |
421 #end[CAS] |
418 |
422 |
419 #if[AtomicAdd] |
423 #if[AtomicAdd] |
420 hs.get(TestAccessMode.SET).invokeExact($value1$); |
424 hs.get(TestAccessMode.SET).invokeExact($value1$); |
552 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
556 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
553 assertEquals(x, $value1$, "failing compareAndExchangeRelease $type$ value"); |
557 assertEquals(x, $value1$, "failing compareAndExchangeRelease $type$ value"); |
554 } |
558 } |
555 |
559 |
556 { |
560 { |
557 boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, $value1$, $value2$); |
561 boolean success = false; |
558 assertEquals(r, true, "weakCompareAndSet $type$"); |
562 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
|
563 success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, $value1$, $value2$); |
|
564 } |
|
565 assertEquals(success, true, "weakCompareAndSet $type$"); |
559 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
566 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
560 assertEquals(x, $value2$, "weakCompareAndSet $type$ value"); |
567 assertEquals(x, $value2$, "weakCompareAndSet $type$ value"); |
561 } |
568 } |
562 |
569 |
563 { |
570 { |
564 boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, $value2$, $value1$); |
571 boolean success = false; |
565 assertEquals(r, true, "weakCompareAndSetAcquire $type$"); |
572 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
|
573 success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, $value2$, $value1$); |
|
574 } |
|
575 assertEquals(success, true, "weakCompareAndSetAcquire $type$"); |
566 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
576 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
567 assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$"); |
577 assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$"); |
568 } |
578 } |
569 |
579 |
570 { |
580 { |
571 boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, $value1$, $value2$); |
581 boolean success = false; |
572 assertEquals(r, true, "weakCompareAndSetRelease $type$"); |
582 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { |
|
583 success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, $value1$, $value2$); |
|
584 } |
|
585 assertEquals(success, true, "weakCompareAndSetRelease $type$"); |
573 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
586 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
574 assertEquals(x, $value2$, "weakCompareAndSetRelease $type$"); |
587 assertEquals(x, $value2$, "weakCompareAndSetRelease $type$"); |
575 } |
588 } |
576 |
589 |
577 { |
|
578 boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, $value2$, $value1$); |
|
579 assertEquals(r, true, "weakCompareAndSetVolatile $type$"); |
|
580 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
|
581 assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$ value"); |
|
582 } |
|
583 |
|
584 // Compare set and get |
590 // Compare set and get |
585 { |
591 { |
586 $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, $value2$); |
592 $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, $value1$); |
587 assertEquals(o, $value1$, "getAndSet $type$"); |
593 assertEquals(o, $value2$, "getAndSet $type$"); |
588 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
594 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); |
589 assertEquals(x, $value2$, "getAndSet $type$ value"); |
595 assertEquals(x, $value1$, "getAndSet $type$ value"); |
590 } |
596 } |
591 #end[CAS] |
597 #end[CAS] |
592 |
598 |
593 #if[AtomicAdd] |
599 #if[AtomicAdd] |
594 hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); |
600 hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); |