C# Class Ariadne.Counter

A counter designed for highly concurrent use.
This counter tends to be appreciably slower than using Interlocked.Increment(ref int) when there is little contention. However, it is much faster in the face of contending threads, with the comparable cost of Interlocked.Increment(ref int) increasing nearly exponentially to the number of contending threads.
Mostrar archivo Open project: JonHanna/Ariadne

Public Methods

Method Description
Counter ( ) : System

Creates a new Counter with an initial value of zero.

Counter ( int startingValue ) : System

Creates a new Counter with an initial value of startingValue.

Decrement ( ) : void

Atomically decrements the Counter by one.

Increment ( ) : void

Atomically increments the Counter by one.

operator ( ) : Counter

Atomically increments counter by one.

Private Methods

Method Description
GetIndex ( ) : int

Method Details

Counter() public method

Creates a new Counter with an initial value of zero.
public Counter ( ) : System
return System

Counter() public method

Creates a new Counter with an initial value of startingValue.
public Counter ( int startingValue ) : System
startingValue int The initial value for the .
return System

Decrement() public method

Atomically decrements the Counter by one.
public Decrement ( ) : void
return void

Increment() public method

Atomically increments the Counter by one.
public Increment ( ) : void
return void

operator() public static method

Atomically increments counter by one.
public static operator ( ) : Counter
return Counter