Backends/SiaNet.Backend.TensorSharp/RefCounted.cs
/// <summary>
/// Increments the reference count. If the object has previously been destroyed, an exception is thrown.
/// </summary>
/// <exception cref="InvalidOperationException">Cannot AddRef - object has already been destroyed</exception>
Increments the reference count. If the object has previously been destroyed, an exception is thrown.
Increments the reference count . If the object has previously been destroyed an exception is thrown .
public void AddRef()
        {
            int curRefCount;
            int original;
            var spin = new SpinWait();
            while (true)
            {
                curRefCount = refCount;
                if (curRefCount == 0) throw new InvalidOperationException("Cannot AddRef - object has already been destroyed");
                var desiredRefCount = curRefCount + 1;
                original = Interlocked.CompareExchange(ref refCount, desiredRefCount, curRefCount);
                if (original == curRefCount) break;
                spin.SpinOnce();
            }
        }
public void AddRef ( ) { int curRefCount ; int original ; var spin = new SpinWait ( ) ; while ( true ) { curRefCount = refCount ; if ( curRefCount == 0 ) throw new InvalidOperationException ( " " ) ; var desiredRefCount = curRefCount + 1 ; original = Interlocked . CompareExchange ( ref refCount , desiredRefCount , curRefCount ) ; if ( original == curRefCount ) break ; spin . SpinOnce ( ) ; } }
Increments the reference count.
Increments the reference count .
Cannot AddRef - object has already been destroyed
Cannot AddRef - object has already been destroyed