static boolean weakCompareAndSet(AtomicLong al, long i, long j) { if (al instanceof BTraceAtomicLong) { return al.weakCompareAndSet(i, j); } else { throw new IllegalArgumentException(); } }
/** * Atomically sets the value to the given updated value * if the current value {@code ==} the expected value. * * <p>May fail spuriously * and does not provide ordering guarantees, so is only rarely an * appropriate alternative to {@code compareAndSet}. * * @param al AtomicLong whose value is compared and set. * @param expect the expected value * @param update the new value * @return true if successful. */ public static boolean weakCompareAndSet(AtomicLong al, long expect, long update) { return al.weakCompareAndSet(expect, update); }
/** * Atomically sets to the given {@code update} value if the current * value is equal to the given {@code expect} value. */ public boolean weakCompareAndSet(double expect, double update) { return value.weakCompareAndSet(Double.doubleToLongBits(expect), Double.doubleToLongBits(update)); }
/** * Atomically sets the value to the given updated value if the current value is <a * href="#bitEquals">bitwise equal</a> to the expected value. * * <p>May <a * href="http://download.oracle.com/javase/7/docs/api/java/util/concurrent/atomic/package-summary.html#Spurious"> * fail spuriously</a> and does not provide ordering guarantees, so is only rarely an appropriate * alternative to {@code compareAndSet}. * * @param expect the expected value * @param update the new value * @return {@code true} if successful */ public final boolean weakCompareAndSet(double expect, double update) { return value.weakCompareAndSet(doubleToRawLongBits(expect), doubleToRawLongBits(update)); }
/** * Atomically sets this double to the specified updated value * if the current value equals the specified expected value. * <p> * My fail spuriously, and does not provide ordering guarantees, so * is only rarely useful. * @param expect the expected value. * @param update the updated value. * @return true, if successfully set; false, if the current * value was not equal to the expected value. */ public final boolean weakCompareAndSet(double expect, double update) { return _al.weakCompareAndSet(l(expect),l(update)); }