Show / Hide Table of Contents

Class NamedInterlocked

Provides functionality similar to the Interlocked class executed over a named slot. All operations are THREAD-SAFE for calling concurrently. The name comparison is that of Registry's which is OrdinalIgnoreCase. This class was designed to better organize named counters incremented from different threads, i.e. this is needed to keep a count of calls to remote host identified by their names. This class is NOT designed for frequent additions/deletions of named slots, nor was it designed to keep millions of slots. Use it in cases when there are thousands at most slots and new slots appear infrequently. You must delete un-needed slots

Inheritance
System.Object
NamedInterlocked
NamedInterlocked<TContext>
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: NFX.Collections
Assembly: NFX.dll
Syntax
public class NamedInterlocked

Properties

AllNames

Enumerates all slot names. This operation is thread-safe, and returns a snapshot of the instance taken at the time of the first call

Declaration
public IEnumerable<string> AllNames { get; }
Property Value
Type Description
System.Collections.Generic.IEnumerable<System.String>

Count

Returns the current number of named slots in the instance

Declaration
public int Count { get; }
Property Value
Type Description
System.Int32

Methods

Add(NamedInterlocked, Nullable<Int64>)

Adds slot snapshot from another source. Pass exchange to flip the existing slots to the exchanged value

Declaration
public void Add(NamedInterlocked source, long ? exchangeSource = default (long ? ))
Parameters
Type Name Description
NamedInterlocked source
System.Nullable<System.Int64> exchangeSource

Add(Amount)

Declaration
public Amount Add(Amount arg)
Parameters
Type Name Description
Amount arg
Returns
Type Description
Amount

AddLong(String, Int64)

Declaration
public long AddLong(string name, long arg)
Parameters
Type Name Description
System.String name
System.Int64 arg
Returns
Type Description
System.Int64

Clear()

Deletes all state for all slots

Declaration
public void Clear()

Clear(String)

Deletes all state for the named slot returning true if the slot was found and removed

Declaration
public bool Clear(string name)
Parameters
Type Name Description
System.String name
Returns
Type Description
System.Boolean

DecrementLong(String)

Declaration
public long DecrementLong(string name)
Parameters
Type Name Description
System.String name
Returns
Type Description
System.Int64

ExchangeLong(String, Int64)

Captures the current value of a named long value and atomically sets it to the passed value

Declaration
public long ExchangeLong(string name, long value)
Parameters
Type Name Description
System.String name
System.Int64 value
Returns
Type Description
System.Int64

Exists(String)

Returns true when the instance contains the named slot

Declaration
public bool Exists(string name)
Parameters
Type Name Description
System.String name
Returns
Type Description
System.Boolean

IncrementLong(String)

Declaration
public long IncrementLong(string name)
Parameters
Type Name Description
System.String name
Returns
Type Description
System.Int64

ReadAtomicLong(String)

Returns a 64-bit value, loaded as an atomic operation even on a 32bit platform

Declaration
public long ReadAtomicLong(string name)
Parameters
Type Name Description
System.String name
Returns
Type Description
System.Int64

SnapshotAllAmounts(Nullable<Decimal>)

Enumerates all named amounts. This operation is thread-safe, and returns a snapshot of the instance taken at the time of the first call If exchange is specified, atomicaly flips the value of every slot

Declaration
public IEnumerable<KeyValuePair<string, Amount>> SnapshotAllAmounts(decimal ? exchange = default (decimal ? ))
Parameters
Type Name Description
System.Nullable<System.Decimal> exchange
Returns
Type Description
System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.String, Amount>>

SnapshotAllLongs(Nullable<Int64>)

Enumerates all named integers. This operation is thread-safe, and returns a snapshot of the instance taken at the time of the first call. If exchange is specified, atomicaly flips the value of every slot

Declaration
public IEnumerable<KeyValuePair<string, long>> SnapshotAllLongs(long ? exchange = default (long ? ))
Parameters
Type Name Description
System.Nullable<System.Int64> exchange
Returns
Type Description
System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.String, System.Int64>>

SnapshotAllLongsInto<TDatum>(Nullable<Int64>, IInstrumentation)

Records a snapshot of all longs converted into TDatum. The TDatum must have a public .ctor(string, long) or runtime exception is thrown (this is because C# does not have a contract/constraint for parameterized cosntructors)

Declaration
public void SnapshotAllLongsInto<TDatum>(long ? exchange = default (long ? ), IInstrumentation instrumentation = null)where TDatum : Datum
Parameters
Type Name Description
System.Nullable<System.Int64> exchange
IInstrumentation instrumentation
Type Parameters
Name Description
TDatum

VolatileReadLong(String)

Captures the current value of a named long value. If slot does not exist, creates it and captures the value (which may be non-zero even if the slot was just created)

Declaration
public long VolatileReadLong(string name)
Parameters
Type Name Description
System.String name
Returns
Type Description
System.Int64

Extension Methods

MiscUtils.NonNull<T>(T, Func<Exception>, String)
ObjectValueConversion.AsString(Object, String, ConvertErrorHandling)
ObjectValueConversion.AsNonNullOrEmptyString(Object)
ObjectValueConversion.AsLaconicConfig(Object, ConfigSectionNode, String, ConvertErrorHandling)
ObjectValueConversion.AsJSONConfig(Object, ConfigSectionNode, String, ConvertErrorHandling)
ObjectValueConversion.AsXMLConfig(Object, ConfigSectionNode, ConvertErrorHandling)
ObjectValueConversion.AsChar(Object, Char, ConvertErrorHandling)
ObjectValueConversion.AsNullableChar(Object, Nullable<Char>, ConvertErrorHandling)
ObjectValueConversion.AsByte(Object, Byte, ConvertErrorHandling)
ObjectValueConversion.AsNullableByte(Object, Nullable<Byte>, ConvertErrorHandling)
ObjectValueConversion.AsSByte(Object, SByte, ConvertErrorHandling)
ObjectValueConversion.AsNullableSByte(Object, Nullable<SByte>, ConvertErrorHandling)
ObjectValueConversion.AsShort(Object, Int16, ConvertErrorHandling)
ObjectValueConversion.AsNullableShort(Object, Nullable<Int16>, ConvertErrorHandling)
ObjectValueConversion.AsUShort(Object, UInt16, ConvertErrorHandling)
ObjectValueConversion.AsNullableUShort(Object, Nullable<UInt16>, ConvertErrorHandling)
ObjectValueConversion.AsInt(Object, Int32, ConvertErrorHandling)
ObjectValueConversion.AsNullableInt(Object, Nullable<Int32>, ConvertErrorHandling)
ObjectValueConversion.AsUInt(Object, UInt32, ConvertErrorHandling)
ObjectValueConversion.AsNullableUInt(Object, Nullable<UInt32>, ConvertErrorHandling)
ObjectValueConversion.AsLong(Object, Int64, ConvertErrorHandling)
ObjectValueConversion.AsNullableLong(Object, Nullable<Int64>, ConvertErrorHandling)
ObjectValueConversion.AsULong(Object, UInt64, ConvertErrorHandling)
ObjectValueConversion.AsNullableULong(Object, Nullable<UInt64>, ConvertErrorHandling)
ObjectValueConversion.AsDouble(Object, Double, ConvertErrorHandling)
ObjectValueConversion.AsNullableDouble(Object, Nullable<Double>, ConvertErrorHandling)
ObjectValueConversion.AsFloat(Object, Single, ConvertErrorHandling)
ObjectValueConversion.AsNullableFloat(Object, Nullable<Single>, ConvertErrorHandling)
ObjectValueConversion.AsDecimal(Object, Decimal, ConvertErrorHandling)
ObjectValueConversion.AsNullableDecimal(Object, Nullable<Decimal>, ConvertErrorHandling)
ObjectValueConversion.AsBool(Object, Boolean, ConvertErrorHandling)
ObjectValueConversion.AsNullableBool(Object, Nullable<Boolean>, ConvertErrorHandling)
ObjectValueConversion.AsGUID(Object, Guid, ConvertErrorHandling)
ObjectValueConversion.AsNullableGUID(Object, Nullable<Guid>, ConvertErrorHandling)
ObjectValueConversion.AsDateTime(Object)
ObjectValueConversion.AsDateTime(Object, DateTime, ConvertErrorHandling)
ObjectValueConversion.AsNullableDateTime(Object, Nullable<DateTime>, ConvertErrorHandling)
ObjectValueConversion.AsGDID(Object)
ObjectValueConversion.AsGDID(Object, GDID, ConvertErrorHandling)
ObjectValueConversion.AsNullableGDID(Object, Nullable<GDID>, ConvertErrorHandling)
ObjectValueConversion.AsGDIDSymbol(Object)
ObjectValueConversion.AsGDIDSymbol(Object, GDIDSymbol, ConvertErrorHandling)
ObjectValueConversion.AsNullableGDIDSymbol(Object, Nullable<GDIDSymbol>, ConvertErrorHandling)
ObjectValueConversion.AsTimeSpan(Object)
ObjectValueConversion.AsTimeSpan(Object, TimeSpan, ConvertErrorHandling)
ObjectValueConversion.AsNullableTimeSpan(Object, Nullable<TimeSpan>, ConvertErrorHandling)
ObjectValueConversion.AsEnum<TEnum>(Object, TEnum, ConvertErrorHandling)
ObjectValueConversion.AsNullableEnum<TEnum>(Object, Nullable<TEnum>, ConvertErrorHandling)
ObjectValueConversion.AsUri(Object, Uri, ConvertErrorHandling)
JSONExtensions.ToJSON(Object, JSONWritingOptions)
JSONExtensions.ToJSON(Object, TextWriter, JSONWritingOptions)
JSONExtensions.ToJSON(Object, Stream, JSONWritingOptions, Encoding)
ErlObject.ToErlObject(Object)
ErlObject.ToErlObject(Object, ErlTypeOrder, Boolean)
Back to top Copyright © 2006-2018 Agnicore Inc
Generated by DocFX