//**************************************************************************************************
//
// INTERLOCKED OPERATIONS (TEMPLATES):
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// RuntimeForStatic base library | C+- (SysRoutine) | Author: Sergei Y.Kitáev
#pragma once
#include "include_restrictions.h"
namespace RuntimeForStatic {
//==================================================================================================
class $interlocked { $STATIC_CLASS_PUBLIC( $interlocked )
//--------------------------------------------------------------------------------------------------

template<typename T>static T Read($A,T volatile* pSource);
template<typename T>static T Write($A,T volatile* pTarget,T value) $ret_target;
template<typename T>static T Exchange($A,T volatile* pLocation,T value) $ret_previous;
template<typename T>static T CompareExchange($A, T volatile* pLocation,
                                                 T exchange, T comparand ) $ret_initial;

//--------------------------------------------------------------------------------------------------

template<typename T>static T* ReadPointer($A, T* volatile* pPointer );
template<typename T>static T* WritePointer($A, T* volatile* pTargetPtr, T* pointerValue )
                                               $ret_target;
template<typename T>static T* ExchangePointer($A, T* volatile* pPointer, T* pointerValue )
                                                  $ret_previous;
template<typename T>static T* CompareExchangePointer($A, T* volatile* pPointer,
                                                         T* exchangePtr, T* comparandPtr )
                                                         $ret_initial;
template<typename T>static T* ResetPointer($A, T* volatile* pPointer ) $ret_previous;

template<typename T>static const T* ReadPointerC($A, const T* volatile* pPointer );
template<typename T>static const T* WritePointerC($A, const T* volatile* pTargetPtr,
                                                      const T* pointerValue );
template<typename T>static const T* ExchangePointerC($A, const T* volatile* pPointer,
                                                         const T* pointerValue ) $ret_previous;
template<typename T>static const T* CompareExchangePointerC($A, const T* volatile* pPointer,
                                                                const T* exchangePtr,
                                                                const T* comparandPtr )
                                                                $ret_initial;
template<typename T>static T* ResetPointerC($A, const T* volatile* pPointer ) $ret_previous;

//--------------------------------------------------------------------------------------------------
}; // $interlocked
//==================================================================================================
} // RuntimeForStatic
