private ThreadAheadReadable(CharReadable actual, int bufferSize) : base(actual)
 {
     this._actual            = actual;
     this._theOtherBuffer    = new SectionedCharBuffer(bufferSize);
     this._sourceDescription = actual.SourceDescription();
     start();
 }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public SectionedCharBuffer read(SectionedCharBuffer buffer, int from) throws java.io.IOException
        public override SectionedCharBuffer Read(SectionedCharBuffer buffer, int from)
        {
            buffer.Compact(buffer, from);
            buffer.ReadFrom(_reader);
            _position += buffer.Available();
            return(buffer);
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: protected boolean readAhead() throws java.io.IOException
        protected internal override bool ReadAhead()
        {
            _theOtherBuffer = _actual.read(_theOtherBuffer, _theOtherBuffer.front());
            string sourceDescriptionAfterRead = _actual.sourceDescription();

            if (!_sourceDescription.Equals(sourceDescriptionAfterRead))
            {
                _newSourceDescription = sourceDescriptionAfterRead;
            }

            return(_theOtherBuffer.hasAvailable());
        }
        /// <summary>
        /// The one calling read doesn't actually read, since reading is up to the thread in here.
        /// Instead the caller just waits for this thread to have fully read the next buffer and
        /// flips over to that buffer, returning it.
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public SectionedCharBuffer read(SectionedCharBuffer buffer, int from) throws java.io.IOException
        public override SectionedCharBuffer Read(SectionedCharBuffer buffer, int from)
        {
            WaitUntilReadAhead();

            // flip the buffers
            SectionedCharBuffer resultBuffer = _theOtherBuffer;

            buffer.Compact(resultBuffer, from);
            _theOtherBuffer = buffer;

            // make any change in source official
            if (!string.ReferenceEquals(_newSourceDescription, null))
            {
                _sourceDescription    = _newSourceDescription;
                _newSourceDescription = null;
            }

            PokeReader();
            return(resultBuffer);
        }
Exemple #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public Source_Chunk nextChunk(int seekStartPos) throws java.io.IOException
        public override Source_Chunk NextChunk(int seekStartPos)
        {
            _charBuffer = _reader.read(_charBuffer, seekStartPos == -1 ? _charBuffer.pivot() : seekStartPos);

            return(new Source_ChunkAnonymousInnerClass(this));
        }
Exemple #6
0
 public AutoReadingSource(CharReadable reader, SectionedCharBuffer charBuffer)
 {
     this._reader     = reader;
     this._charBuffer = charBuffer;
 }
Exemple #7
0
 public abstract SectionedCharBuffer Read(SectionedCharBuffer buffer, int from);