other/Scripts/Network/RPCNet/Base/AsyncCollection.cs
/// <summary>
/// Adds the item to the AsyncCollection.
/// </summary>
/// <param name="item">The item to be added to the collection. The value can be a null reference.</param>
/// <exception cref="T:System.InvalidOperationException">The AsyncCollection has been marked as complete with regards to additions.</exception>
/// <exception cref="T:System.ObjectDisposedException">The AsyncCollection has been disposed.</exception>
Adds the item to the AsyncCollection.
Adds the item to the AsyncCollection .
public void Add(T item)
        {
            CheckDisposed();
            SpinWait spinner = new SpinWait();
            while (true)
            {
                int observedAdders = currentAdders;
                if ((observedAdders & COMPLETE_ADDING_ON_MASK) != 0)
                {
                    spinner.Reset();
                    while (currentAdders != COMPLETE_ADDING_ON_MASK) spinner.SpinOnce();
                    throw new InvalidOperationException("Adding is completed");
                }
                if (Interlocked.CompareExchange(ref currentAdders, observedAdders + 1, observedAdders) == observedAdders)
                {
                    break;
                }
                spinner.SpinOnce();
            }
            queue.Enqueue(item);
            semaphore.Release();
            Interlocked.Decrement(ref currentAdders);
        }
public void Add ( T item ) { CheckDisposed ( ) ; SpinWait spinner = new SpinWait ( ) ; while ( true ) { int observedAdders = currentAdders ; if ( ( observedAdders & COMPLETE_ADDING_ON_MASK ) != 0 ) { spinner . Reset ( ) ; while ( currentAdders != COMPLETE_ADDING_ON_MASK ) spinner . SpinOnce ( ) ; throw new InvalidOperationException ( " " ) ; } if ( Interlocked . CompareExchange ( ref currentAdders , observedAdders + 1 , observedAdders ) == observedAdders ) { break ; } spinner . SpinOnce ( ) ; } queue . Enqueue ( item ) ; semaphore . Release ( ) ; Interlocked . Decrement ( ref currentAdders ) ; }
Adds the item to the AsyncCollection.
Adds the item to the AsyncCollection .
The AsyncCollection has been marked as complete with regards to additions.
The AsyncCollection has been marked as complete with regards to additions .
The AsyncCollection has been disposed.
The AsyncCollection has been disposed .
item
T
The item to be added to the collection. The value can be a null reference.
The item to be added to the collection . The value can be a null reference .