//
        //#if !DEBUG
        //		// [MethodImpl(MethodImplOptions.AggressiveInlining)]
        //#endif
        //		public uint? GetMinReadingGate()
        //		{
        //			uint minGatePos = uint.MaxValue;
        //			bool hadSomeMin = false;
        //
        //			lock (_gateLocker)
        //			{
        //				long oldGateState = 0;
        //				uint oldAbaPrevention = 0;
        //
        //				do
        //				{
        //					oldGateState = Volatile.Read(ref _gateState);
        //					if (oldGateState == 0L) return null;
        //
        //					// Possibly ABA problem here! so..
        //					oldAbaPrevention = _abaPrevention;
        //
        //					for (int i = 0; i < MaxGates; i++)
        //					{
        //						// if ((oldGateState & (1L << i)) != 0L)
        //						{
        //							var el = _gates[i];
        //							if (el == null || !el.inEffect) // race
        //								continue;
        //
        //							// if (el.inEffect) // otherwise ignored
        //							{
        ////								lock (el)
        //								if (minGatePos > el.gpos)
        //								{
        //									hadSomeMin = true;
        //									minGatePos = el.gpos;
        //								}
        //							}
        //						}
        //					}
        //					// if it changed in the meantime, we need to recalculate
        //				} while (oldGateState != Volatile.Read(ref _gateState) || oldAbaPrevention != _abaPrevention);
        //			}
        //
        ////			if (hadSomeMin)
        ////				Console.WriteLine("\t[Min] Min reading gate is " + minGatePos);
        ////			else
        ////				Console.WriteLine("\t[Min] ---- ");
        //
        //			if (!hadSomeMin) return null;
        //
        //			return minGatePos;
        //		}

        public void ReenableBuffers()
        {
            // Reset(); // ensure positions are properly set

            _state._readPosition  = _state._readPositionCopy = 0;
            _state._writePosition = _state._writePositionCopy = 0;

            _writeLock.Restore();
            _readLock.Restore();

            _state._resetApplied = false;

            //			Thread.MemoryBarrier();
        }