System\Runtime\IOThreadScheduler.cs (47)
79int headTail = -2 << Bits.HiShift;
84int headTailLowPri = -1 << Bits.HiShift;
152int slot = Interlocked.Add(ref this.headTail, Bits.HiOne);
156bool wasIdle = Bits.Count(slot) == 0;
159slot = Interlocked.Add(ref this.headTail, Bits.HiOne);
160Fx.Assert(Bits.Count(slot) != 0, "IOTS went idle when it shouldn't have.");
164if (Bits.Count(slot) == -1)
173bool queued = this.slots[slot >> Bits.HiShift & SlotMask].TryEnqueueWorkItem(callback, state, out wrapped);
198int slot = Interlocked.Add(ref this.headTailLowPri, Bits.HiOne);
202if (Bits.CountNoIdle(slot) == 1)
209if (Bits.Count(ht) == -1)
213int interlockedResult = Interlocked.CompareExchange(ref this.headTail, ht + Bits.HiOne, ht);
222if (Bits.CountNoIdle(slot) == 0)
231bool queued = this.slotsLowPri[slot >> Bits.HiShift & SlotMaskLowPri].TryEnqueueWorkItem(
258Fx.Assert(Bits.Count(slot) != -1, "CompletionCallback called on idle IOTS!");
260bool wasEmpty = Bits.Count(slot) == 0;
267while (Bits.CountNoIdle(slotLowPri) != 0)
270Bits.IncrementLo(slotLowPri), slotLowPri)))
279if (slot == (slot = Interlocked.CompareExchange(ref this.headTail, Bits.IncrementLo(slot), slot)))
298if (Bits.CountNoIdle(slotLowPri) != 0)
302slot = Bits.IncrementLo(slot);
303if (slot == Interlocked.CompareExchange(ref this.headTail, slot + Bits.HiOne, slot))
305slot += Bits.HiOne;
331if (Bits.Count(slot) > 0)
333if (slot == (slot = Interlocked.CompareExchange(ref this.headTail, Bits.IncrementLo(slot), slot)))
342if (Bits.CountNoIdle(slotLowPri) > 0)
345Bits.IncrementLo(slotLowPri), slotLowPri)))
483wrapped = (gateSnapshot & Bits.LoCountMask) != 1;
486if ((gateSnapshot & Bits.LoHiBit) != 0 && Bits.IsComplete(gateSnapshot))
494Fx.Assert((gateSnapshot & Bits.HiBits) == 0, "Slot already marked.");
500gateSnapshot = Interlocked.Add(ref this.gate, Bits.LoHiBit);
501Fx.Assert((gateSnapshot & Bits.HiBits) == Bits.LoHiBit, "Slot already empty.");
503if ((gateSnapshot & Bits.HiCountMask) == 0)
514if (gateSnapshot >> Bits.HiShift != (gateSnapshot & Bits.LoCountMask) ||
517gateSnapshot = Interlocked.Add(ref this.gate, Bits.HiHiBit);
518if (Bits.IsComplete(gateSnapshot))
531int gateSnapshot = Interlocked.Add(ref this.gate, Bits.HiOne);
533if ((gateSnapshot & Bits.LoHiBit) == 0)
545if ((gateSnapshot & Bits.HiCountMask) == Bits.HiOne)
554if ((gateSnapshot & Bits.LoCountMask) != 1 ||
557gateSnapshot = Interlocked.Add(ref this.gate, Bits.HiHiBit);
558if (Bits.IsComplete(gateSnapshot))
570if (Bits.IsComplete(gateSnapshot))