Internals\System\Runtime\IOThreadScheduler.cs (33)
75private int _headTail = -2 << Bits.HiShift;
138int slot = Interlocked.Add(ref _headTail, Bits.HiOne);
142bool wasIdle = Bits.Count(slot) == 0;
145slot = Interlocked.Add(ref _headTail, Bits.HiOne);
146Contract.Assert(Bits.Count(slot) != 0, "IOTS went idle when it shouldn't have.");
150if (Bits.Count(slot) == -1)
158bool queued = _slots[slot >> Bits.HiShift & SlotMask].TryEnqueueWorkItem(callback, state, out bool wrapped);
182Contract.Assert(Bits.Count(slot) != -1, "CompletionCallback called on idle IOTS!");
184bool wasEmpty = Bits.Count(slot) == 0;
186if (slot == (slot = Interlocked.CompareExchange(ref _headTail, Bits.IncrementLo(slot), slot)))
208if (Bits.Count(slot) > 0)
210if (slot == (slot = Interlocked.CompareExchange(ref _headTail, Bits.IncrementLo(slot), slot)))
265Contract.Assert(Bits.Count(_headTail) == -1, "IOTS finalized while not idle.");
325wrapped = (gateSnapshot & Bits.LoCountMask) != 1;
328if ((gateSnapshot & Bits.LoHiBit) != 0 && Bits.IsComplete(gateSnapshot))
336Contract.Assert((gateSnapshot & Bits.HiBits) == 0, "Slot already marked.");
342gateSnapshot = Interlocked.Add(ref _gate, Bits.LoHiBit);
343Contract.Assert((gateSnapshot & Bits.HiBits) == Bits.LoHiBit, "Slot already empty.");
345if ((gateSnapshot & Bits.HiCountMask) == 0)
356if (gateSnapshot >> Bits.HiShift != (gateSnapshot & Bits.LoCountMask) ||
359gateSnapshot = Interlocked.Add(ref _gate, Bits.HiHiBit);
360if (Bits.IsComplete(gateSnapshot))
372int gateSnapshot = Interlocked.Add(ref _gate, Bits.HiOne);
374if ((gateSnapshot & Bits.LoHiBit) == 0)
386if ((gateSnapshot & Bits.HiCountMask) == Bits.HiOne)
395if ((gateSnapshot & Bits.LoCountMask) != 1 ||
398gateSnapshot = Interlocked.Add(ref _gate, Bits.HiHiBit);
399if (Bits.IsComplete(gateSnapshot))
411if (Bits.IsComplete(gateSnapshot))