other/Scripts/Network/RPCNet/Base/AsyncCollection.cs
/// <summary>
/// Marks the AsyncCollection instance as not accepting any more additions.
/// </summary>
/// <remarks>
/// After a collection has been marked as complete for adding, adding to the collection is not permitted
/// and attempts to remove from the collection will not wait when the collection is empty.
/// </remarks>
/// <exception cref="T:System.ObjectDisposedException">The AsyncCollection has been disposed.</exception>
Marks the AsyncCollection instance as not accepting any more additions.
Marks the AsyncCollection instance as not accepting any more additions .
public void CompleteAdding()
        {
            CheckDisposed();
            if (IsAddingCompleted)
                return;
            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();
                    return;
                }
                if (Interlocked.CompareExchange(ref currentAdders, observedAdders | COMPLETE_ADDING_ON_MASK, observedAdders) == observedAdders)
                {
                    spinner.Reset();
                    while (currentAdders != COMPLETE_ADDING_ON_MASK) spinner.SpinOnce();
                    if (queue.Count == 0)
                        doneCancellationToken.Cancel();
                    return;
                }
                spinner.SpinOnce();
            }
        }
public void CompleteAdding ( ) { CheckDisposed ( ) ; if ( IsAddingCompleted ) return ; 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 ( ) ; return ; } if ( Interlocked . CompareExchange ( ref currentAdders , observedAdders | COMPLETE_ADDING_ON_MASK , observedAdders ) == observedAdders ) { spinner . Reset ( ) ; while ( currentAdders != COMPLETE_ADDING_ON_MASK ) spinner . SpinOnce ( ) ; if ( queue . Count == 0 ) doneCancellationToken . Cancel ( ) ; return ; } spinner . SpinOnce ( ) ; } }
Marks the AsyncCollection instance as not accepting any more additions.
Marks the AsyncCollection instance as not accepting any more additions .
The AsyncCollection has been disposed.
The AsyncCollection has been disposed .
remarks
After a collection has been marked as complete for adding, adding to the collection is not permitted
and attempts to remove from the collection will not wait when the collection is empty.
After a collection has been marked as complete for adding adding to the collection is not permitted and attempts to remove from the collection will not wait when the collection is empty .