Esempio n. 1
0
        /// <summary>
        /// Dispose of scope
        /// </summary>
        public virtual void Dispose()
        {
            var disposables = ImmutableLinkedList.ThreadSafeEmpty(ref _disposable);

            if (ReferenceEquals(disposables, ImmutableLinkedList <Tuple <IDisposable, Action> > .Empty))
            {
                return;
            }

            InternalDispose(disposables);
        }
Esempio n. 2
0
        private void RemoveFromList()
        {
            while (!_countdownEvent.WaitHandle.WaitOne(0))
            {
                for (var i = 0; i < 500; i++)
                {
                    var list = ImmutableLinkedList.ThreadSafeEmpty(ref _linkedList);

                    _finalList.AddRange(list);
                }
            }

            var lastList = ImmutableLinkedList.ThreadSafeEmpty(ref _linkedList);

            _finalList.AddRange(lastList);
        }
Esempio n. 3
0
        public void ImmutableLinkedList_ThreadSafeEmpty()
        {
            var list = ImmutableLinkedList.Create(5, 10, 15);

            var newList = new List <int>(list);

            Assert.Equal(3, newList.Count);
            Assert.Contains(5, newList);
            Assert.Contains(10, newList);
            Assert.Contains(15, newList);

            ImmutableLinkedList.ThreadSafeEmpty(ref list);

            newList = new List <int>(list);

            Assert.Empty(newList);
        }
Esempio n. 4
0
        public void ImmutableLinkedList_Null_Reference_Check()
        {
            var value = (ImmutableLinkedList <int>)null;

            Assert.Throws <ArgumentNullException>(() => ImmutableLinkedList.ThreadSafeAdd(ref value, 2));

            Assert.Throws <ArgumentNullException>(() => ImmutableLinkedList.ThreadSafeEmpty(ref value));

            Assert.Throws <ArgumentNullException>(() => ImmutableLinkedList.ThreadSafeAddRange(ref value, new[] { 5 }));

            value = ImmutableLinkedList <int> .Empty;

            Assert.Throws <ArgumentNullException>(() => ImmutableLinkedList.ThreadSafeAddRange(ref value, null));

            Assert.Throws <ArgumentNullException>(() => ImmutableLinkedList <int> .Empty.Visit(null));

            Assert.Throws <ArgumentNullException>(() => ImmutableLinkedList <int> .Empty.AddRange(null));

            Assert.Throws <ArgumentNullException>(() => ImmutableLinkedList.From <int>(null));
        }