Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Count

Implements System.Collections.ICollection.

Definition at line 39 of file ConcurrentQueue.cs.

40 {
41 get
42 {
43 SpinWait spinWait = default(SpinWait);
46 int num;
47 int num2;
48 int num3;
49 int num4;
50 while (true)
51 {
52 head = _head;
53 tail = _tail;
54 num = Volatile.Read(ref head._headAndTail.Head);
55 num2 = Volatile.Read(ref head._headAndTail.Tail);
56 if (head == tail)
57 {
58 if (head == _head && tail == _tail && num == Volatile.Read(ref head._headAndTail.Head) && num2 == Volatile.Read(ref head._headAndTail.Tail))
59 {
60 return GetCount(head, num, num2);
61 }
62 }
63 else if (head._nextSegment == tail)
64 {
65 num3 = Volatile.Read(ref tail._headAndTail.Head);
66 num4 = Volatile.Read(ref tail._headAndTail.Tail);
67 if (head == _head && tail == _tail && num == Volatile.Read(ref head._headAndTail.Head) && num2 == Volatile.Read(ref head._headAndTail.Tail) && num3 == Volatile.Read(ref tail._headAndTail.Head) && num4 == Volatile.Read(ref tail._headAndTail.Tail))
68 {
69 break;
70 }
71 }
72 else
73 {
75 {
76 if (head == _head && tail == _tail)
77 {
78 int num5 = Volatile.Read(ref tail._headAndTail.Head);
79 int num6 = Volatile.Read(ref tail._headAndTail.Tail);
80 if (num == Volatile.Read(ref head._headAndTail.Head) && num2 == Volatile.Read(ref head._headAndTail.Tail) && num5 == Volatile.Read(ref tail._headAndTail.Head) && num6 == Volatile.Read(ref tail._headAndTail.Tail))
81 {
82 int num7 = GetCount(head, num, num2) + GetCount(tail, num5, num6);
83 for (ConcurrentQueueSegment<T> nextSegment = head._nextSegment; nextSegment != tail; nextSegment = nextSegment._nextSegment)
84 {
85 num7 += nextSegment._headAndTail.Tail - nextSegment.FreezeOffset;
86 }
87 return num7;
88 }
89 }
90 }
91 }
92 spinWait.SpinOnce();
93 }
94 return GetCount(head, num, num2) + GetCount(tail, num3, num4);
95 }
96 }
volatile ConcurrentQueueSegment< T > _tail
static int GetCount(ConcurrentQueueSegment< T > s, int head, int tail)
volatile ConcurrentQueueSegment< T > _head
static bool Read(ref bool location)
Definition Volatile.cs:67

Referenced by System.Collections.Concurrent.ConcurrentQueue< T >.ConcurrentQueue().