#if FAT using System; using System.Threading; namespace LinqInternal.Threading.Needles { internal sealed class LockableContext { internal readonly LockContext Context; private readonly StructNeedle> _slots; public LockableContext(int capacity) { Context = new LockContext(capacity); _slots.Value = new TrackingThreadLocal(() => null); } internal LockableSlot Slot { get { return _slots.Value.Value; } set { _slots.Value.Value = value; } } public IDisposable Enter() { return new LockableSlot(this); } internal bool TryGetSlot(out LockableSlot slot) { return _slots.Value.TryGetValue(Thread.CurrentThread, out slot) && slot != null; } } } #endif