org.jjoost.util
Class Counters

java.lang.Object
  extended by org.jjoost.util.Counters

public class Counters
extends java.lang.Object

Some default Counter implementations

Author:
b.elliottsmith

Nested Class Summary
static class Counters.DontCounter
          a Counter which ignores all updates to its value and always returns a value less than zero.
static class Counters.SerialCounter
          Returns a regular Counter which performs ordinary addition with no concurrency guarantees
static class Counters.ThreadSafeCounter
          a thread safe Counter which uses compare and set operations to modify its value
 
Constructor Summary
Counters()
           
 
Method Summary
static Counter newCounter()
          Returns a regular Counter which performs ordinary addition with no concurrency guarantees
static Counter newDoNothingCounter()
          Returns a Counter which ignores all updates to its value and always returns a value less than zero.
static Counter newThreadSafeCounter()
          Returns a new thread safe Counter which uses compare and set operations to modify its value
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Counters

public Counters()
Method Detail

newThreadSafeCounter

public static Counter newThreadSafeCounter()
Returns a new thread safe Counter which uses compare and set operations to modify its value

Returns:
a new thread safe Counter which uses compare and set operations to modify its value

newDoNothingCounter

public static Counter newDoNothingCounter()
Returns a Counter which ignores all updates to its value and always returns a value less than zero.

Returns:
a Counter which ignores all updates to its value and always returns a value less than zero.

newCounter

public static Counter newCounter()
Returns a regular Counter which performs ordinary addition with no concurrency guarantees

Returns:
a regular Counter which performs ordinary addition with no concurrency guarantees