static assert(false, "This operation is only available on 64-bit platforms.");
}
}//else static if( T.sizeof == long.sizeof )
else
{
//Not a 1, 2, 4, or 8 Byte Type
static assert(false, "Invalid template type specified.");
}
}
}
/**
* Supported MemorySemantics values:
* MemorySemantics.Raw
* MemorySemantics.SinkStoreBarrier
* MemorySemantics.Acquire
* MemorySemantics.Release
* MemorySemantics.FullFence
*/
template atomicStore(T, MemorySemantics ms = MemorySemantics.FullFence )
{
static assert( ms == MemorySemantics.Raw ||
ms == MemorySemantics.SinkStoreBarrier ||
ms == MemorySemantics.Acquire ||
ms == MemorySemantics.Release ||
ms == MemorySemantics.FullFence,
"ms must be one of: MemorySemantics.Raw, MemorySemantics.SinkStoreBarrier, MemorySemantics.Acquire, MemorySemantics.Acquire, MemorySemantics.Release, MemorySemantics.FullFence." );
/**
* Stores 'newval' to the memory referenced by 'value'. This operation
static assert(false, "This operation is only available on 64-bit platforms.");
}
}
else
{
//Not a 1, 2, 4, or 8 Byte Type
static assert(false, "Invalid template type specified.");
}
}
}
/**
* Supported MemorySemantics values:
* MemorySemantics.Raw
* MemorySemantics.SinkStoreBarrier
* MemorySemantics.Acquire
* MemorySemantics.Release
* MemorySemantics.FullFence
*/
template atomicCAS(T, MemorySemantics ms = MemorySemantics.FullFence)
{
static assert( ms == MemorySemantics.Raw ||
ms == MemorySemantics.SinkStoreBarrier ||
ms == MemorySemantics.Acquire ||
ms == MemorySemantics.Release ||
ms == MemorySemantics.FullFence,
"ms must be one of: MemorySemantics.Raw, MemorySemantics.SinkStoreBarrier, MemorySemantics.Acquire, MemorySemantics.Acquire, MemorySemantics.Release, MemorySemantics.FullFence." );
/**
* Stores 'newValue' to the memory referenced by 'value' if val is equal to
* 'equalTo'. This operation is both lock-free and atomic.
*
* Params:
* value = The destination variable.
* newValue = The value to store.
* equalTo = The comparison value.
*
* Returns:
* true if the store occurred, false if not.
*/
bool atomicCAS(ref T value, T newValue, T equalTo)
in
{
// NOTE: 32 bit x86 systems support 8 byte CAS, which only requires
// 4 byte alignment, so use size_t as the align type here.
static assert(false, "Invalid template type specified.");
}
}
}
/**
* Supported MemorySemantics values:
* MemorySemantics.Raw
* MemorySemantics.SinkStoreBarrier
* MemorySemantics.Acquire
* MemorySemantics.Release
* MemorySemantics.FullFence
*/
template atomicIncrement(T, MemorySemantics ms = MemorySemantics.FullFence)
{
// NOTE: This operation is only valid for integer or pointer types
static assert( IsValidNumericType!(T) );
static assert( ms == MemorySemantics.Raw ||
ms == MemorySemantics.SinkStoreBarrier ||
ms == MemorySemantics.Acquire ||
ms == MemorySemantics.Release ||
ms == MemorySemantics.FullFence,
"ms must be one of: MemorySemantics.Raw, MemorySemantics.SinkStoreBarrier, MemorySemantics.Acquire, MemorySemantics.Acquire, MemorySemantics.Release, MemorySemantics.FullFence." );
/**
* This operation is only legal for built-in value and pointer types,
* and is equivalent to an atomic "value = value + 1" operation. This
* function exists to facilitate use of the optimized increment
* instructions provided by some architecures. If no such instruction
* exists on the target platform then the behavior will perform the
* operation using more traditional means. This operation is both
* lock-free and atomic.
*
* Params:
* value = The value to increment.
*
* Returns:
* The result of an atomicLoad of val immediately following the
* increment operation. This value is not required to be equal to the
* newly stored value. Thus, competing writes are allowed to occur
* between the increment and successive load operation.
static assert(false, "This operation is only available on 64-bit platforms.");
}
}
else
{
//Not a 1, 2, 4, or 8 Byte Type
static assert(false, "Invalid template type specified.");
}
}
}
/**
* Supported MemorySemantics values:
* MemorySemantics.Raw
* MemorySemantics.SinkStoreBarrier
* MemorySemantics.Acquire
* MemorySemantics.Release
* MemorySemantics.FullFence
*/
template atomicDecrement(T, MemorySemantics ms = MemorySemantics.FullFence)
{
//NOTE: This operation is only valid for integer or pointer types
static assert( IsValidNumericType!(T) );
static assert( ms == MemorySemantics.Raw ||
ms == MemorySemantics.SinkStoreBarrier ||
ms == MemorySemantics.Acquire ||
ms == MemorySemantics.Release ||
ms == MemorySemantics.FullFence,
"ms must be one of: MemorySemantics.Raw, MemorySemantics.SinkStoreBarrier, MemorySemantics.Acquire, MemorySemantics.Acquire, MemorySemantics.Release, MemorySemantics.FullFence." );
/**
* This operation is only legal for built-in value and pointer types,
* and is equivalent to an atomic "value = value - 1" operation. This
* function exists to facilitate use of the optimized decrement
* instructions provided by some architecures. If no such instruction
* exists on the target platform then the behavior will perform the
* operation using more traditional means. This operation is both
* lock-free and atomic.
*
* Params:
* value = The value to decrement.
*
* Returns:
* The result of an atomicLoad of val immediately following the
* increment operation. This value is not required to be equal to the
* newly stored value. Thus, competing writes are allowed to occur
* between the increment and successive load operation.
static assert(false, "This operation is only available on 64-bit platforms.");
}
}
else
{
static assert(false, "Invalid template type specified.");
}
}
}
/**
* Supported MemorySemantics values:
* MemorySemantics.Raw
* MemorySemantics.SinkStoreBarrier
* MemorySemantics.Acquire
* MemorySemantics.Release
* MemorySemantics.FullFence
*/
template atomicAdd(T, MemorySemantics ms = MemorySemantics.FullFence)
{
static assert( IsValidNumericType!(T) );
static assert( ms == MemorySemantics.Raw ||
ms == MemorySemantics.SinkStoreBarrier ||
ms == MemorySemantics.Acquire ||
ms == MemorySemantics.Release ||
ms == MemorySemantics.FullFence,
"ms must be one of: MemorySemantics.Raw, MemorySemantics.SinkStoreBarrier, MemorySemantics.Acquire, MemorySemantics.Acquire, MemorySemantics.Release, MemorySemantics.FullFence." );
/**
* Adds two integers and replaces the first integer with the sum, as an atomic operation.