Example #1
0
 /// <summary>
 /// Copies the current value to the memory location of the given view.
 /// </summary>
 /// <param name="targetView">The target view.</param>
 /// <remarks>
 /// The target view must be accessible from the this view (e.g. same accelerator).
 /// </remarks>
 public void CopyTo(VariableView <T> targetView) => targetView.Value = Value;
Example #2
0
 /// <summary>
 /// Copies the value from the memory location of the given view.
 /// </summary>
 /// <param name="sourceView">The source view.</param>
 /// <remarks>
 /// The source view must be accessible from the this view (e.g. same accelerator).
 /// </remarks>
 public void CopyFrom(VariableView <T> sourceView) => Value = sourceView.Value;
Example #3
0
 /// <summary>
 /// Atommically adds the given value and the value at the target location
 /// and returns the old value.
 /// </summary>
 /// <param name="target">The target location.</param>
 /// <param name="value">The value to add.</param>
 /// <returns>The old value that was stored at the target location.</returns>
 public static double Add(VariableView <double> target, double value)
 {
     return(MakeAtomic(target, value, new AddDouble(), new AtomicOperations.CompareExchangeDouble()));
 }
Example #4
0
 /// <summary>
 /// Atommically adds the given value and the value at the target location
 /// and returns the old value.
 /// </summary>
 /// <param name="target">the target location.</param>
 /// <param name="value">The value to add.</param>
 /// <returns>The old value that was stored at the target location.</returns>
 public static Index Add(VariableView <Index> target, Index value)
 {
     return(Add(target.Cast <int>(), value));
 }
Example #5
0
 /// <summary>
 /// Represents an atomic compare-exchange operation.
 /// </summary>
 /// <param name="target">the target location.</param>
 /// <param name="compare">The expected comparison value.</param>
 /// <param name="value">The value to add.</param>
 /// <returns>The old value.</returns>
 public static Index CompareExchange(VariableView <Index> target, Index compare, Index value)
 {
     return(CompareExchange(target.Cast <int>(), compare, value));
 }
Example #6
0
 public static float Add(VariableView <float> target, float value)
 {
     return(MakeAtomic(target, value, new AddFloat(), new AtomicOperations.CompareExchangeFloat()));
 }
Example #7
0
        /// <summary>
        /// Represents an atomic compare-exchange operation.
        /// </summary>
        /// <param name="target">The target location.</param>
        /// <param name="compare">The expected comparison value.</param>
        /// <param name="value">The target value.</param>
        /// <returns>The old value.</returns>
        public static unsafe float CompareExchange(VariableView <float> target, float compare, float value)
        {
            var result = CompareExchange(target.Cast <int>(), *(int *)&compare, *(int *)&value);

            return(*(float *)&result);
        }
Example #8
0
        /// <summary>
        /// Represents an atomic compare-exchange operation.
        /// </summary>
        /// <param name="target">The target location.</param>
        /// <param name="compare">The expected comparison value.</param>
        /// <param name="value">The target value.</param>
        /// <returns>The old value.</returns>
        public static unsafe double CompareExchange(VariableView <double> target, double compare, double value)
        {
            var result = CompareExchange(target.Cast <long>(), *(long *)&compare, *(long *)&value);

            return(*(double *)&result);
        }
Example #9
0
 public static unsafe IntPtr CompareExchange(VariableView <IntPtr> target, IntPtr compare, IntPtr value)
 {
     return(Interlocked.CompareExchange(ref Unsafe.AsRef <IntPtr>(target.Pointer.ToPointer()), value, compare));
 }
Example #10
0
        public static unsafe ulong CompareExchange(VariableView <ulong> target, ulong compare, ulong value)
        {
            var result = CompareExchange(target.Cast <long>(), *(long *)&compare, *(long *)&value);

            return(*(ulong *)&result);
        }
Example #11
0
        public static unsafe uint CompareExchange(VariableView <uint> target, uint compare, uint value)
        {
            var result = CompareExchange(target.Cast <int>(), *(int *)&compare, *(int *)&value);

            return(*(uint *)&result);
        }
Example #12
0
 /// <summary>
 /// Represents an atomic exchange operation.
 /// </summary>
 /// <param name="target">the target location.</param>
 /// <param name="value">The value to add.</param>
 /// <returns>The old value.</returns>
 public static Index Exchange(VariableView <Index> target, Index value)
 {
     return(Exchange(target.Cast <int>(), value));
 }
Example #13
0
 public static uint Decrement(VariableView <uint> target, uint value)
 {
     return(MakeAtomic(target, value, new DecUInt32(), new AtomicOperations.CompareExchangeUInt32()));
 }