示例#1
0
    public void ShouldGetTheValue() {
      AtomicLong atl = new AtomicLong();
      Assert.AreEqual(0, atl.Value);

      atl = new AtomicLong(15);
      Assert.AreEqual(15, atl.Value);
    }
示例#2
0
    public void ShouldAtomiccallyCompareAndExchange() {
      AtomicLong atl = new AtomicLong(69);
      long lg = atl.CompareExchange(69, 70);
      Assert.AreEqual(69, lg);

      atl = new AtomicLong(80);
      lg = atl.CompareExchange(85, 90);
      Assert.AreEqual(lg, 80);

    }
示例#3
0
 /// <summary>
 /// Compare the value of <see cref="other"/> with the current
 /// <see cref="AtomicLong"/> value.
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public bool Equals(AtomicLong other)
 {
     // We are assuming that value does not change.
     return(Value == other.Value);
 }
示例#4
0
 /// <summary>
 /// Compare the value of <see cref="other"/> with the current
 /// <see cref="AtomicLong"/> value.
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public bool Equals(AtomicLong other) {
   // We are assuming that value does not change.
   return Value == other.Value;
 }
示例#5
0
 public void ShouldAtomicallyIncrement() {
   AtomicLong atl = new AtomicLong(45);
   long lg = atl.Increment();
   Assert.AreEqual(46, lg);
 }
示例#6
0
 public void ShouldAtomicallyExchange() {
   AtomicLong atl = new AtomicLong(10);
   long lg = atl.Exchange(21);
   Assert.AreEqual(10, lg);
 }
示例#7
0
 public void ShouldAtomicallyDecrement() {
   AtomicLong atl = new AtomicLong(15);
   long lg = atl.Decrement();
   Assert.AreEqual(14, lg);
 }
示例#8
0
 public void ShouldAtomicallyAdd() {
   AtomicLong atl = new AtomicLong(0);
   long lg = atl.Add(1);
   Assert.AreEqual(1, lg);
 }