package se.l4.vibe.probes;

import java.util.concurrent.atomic.AtomicLong;

/**
 * Probe used for counting values.
 */
public class CountingProbe
	implements Probe<Long>
{
	private final AtomicLong counter;

	public CountingProbe()
	{
		counter = new AtomicLong();
	}

	/**
	 * Increase the count with one.
	 *
	 */
	public void increase()
	{
		counter.incrementAndGet();
	}

	/**
	 * Decrease the count with one.
	 *
	 */
	public void decrease()
	{
		counter.decrementAndGet();
	}

	/**
	 * Add the given delta to the count.
	 *
	 * @param count
	 */
	public void add(long delta)
	{
		counter.addAndGet(delta);
	}

	/**
	 * Subtract the given delta from the count.
	 *
	 * @param delta
	 */
	public void remove(long delta)
	{
		counter.addAndGet(-delta);
	}

	/**
	 * Set a new value.
	 *
	 * @param value
	 */
	public void set(long value)
	{
		counter.set(value);
	}

	@Override
	public Long read()
	{
		return counter.get();
	}
}

@@ -56,26 +56,25 @@
 .atomic.
-AtomicLong
+LongAdder
 ;%0A%0A/**%0A 
@@ -179,26 +179,25 @@
 e final 
-AtomicLong
+LongAdder
  counter
@@ -246,18 +246,17 @@
 new 
-AtomicLong
+LongAdder
 ();%0A
@@ -348,30 +348,24 @@
 er.increment
-AndGet
 ();%0A%09%7D%0A%0A%09/**
@@ -453,22 +453,16 @@
 ecrement
-AndGet
 ();%0A%09%7D%0A%0A
@@ -575,22 +575,16 @@
 nter.add
-AndGet
 (delta);
@@ -716,14 +716,8 @@
 .add
-AndGet
 (-de
@@ -730,118 +730,8 @@
 %09%7D%0A%0A
-%09/**%0A%09 * Set a new value.%0A%09 *%0A%09 * @param value%0A%09 */%0A%09public void set(long value)%0A%09%7B%0A%09%09counter.set(value);%0A%09%7D%0A%0A
 %09@Ov
@@ -781,11 +781,11 @@
 ter.
-get
+sum
 ();%0A

Use LongAdder for CountingProbe