/// <summary> Sets up the DirectStreamLink with a certain behaviour. </summary>
 /// <param name="bufsize"> The size of the internal  buffer to use. </param>
 /// <param name="blockOnFlush"> Specifies to block Flush until reader has read buffer empty. This is not suited for synching. </param>
 /// <param name="blockOnClose"> Specifies to block close of writer until reader has closed. Can be used for synching. </param>
 /// <param name="passWriteThrough"> A stream all written data is just passed to. For stream stacking. </param>
 public DirectStreamLink(int bufsize, bool blockOnFlush, bool blockOnClose, Stream passWriteThrough)
 {
     m_passWriteThrough = passWriteThrough;
     m_blockOnFlush     = blockOnFlush;
     m_blockOnClose     = blockOnClose;
     if (bufsize <= 0)
     {
         throw new ArgumentOutOfRangeException(nameof(bufsize), "The size of the buffer must be positive.");
     }
     m_buf          = new byte[bufsize];
     m_readerStream = new LinkedReaderStream(this);
     m_writerStream = new LinkedWriterStream(this);
 }
        private void readerClosed()
        {
            lock (m_lock)
            {
                if (m_readerClosed)
                {
                    return;
                }
                m_readerClosed = true;
                m_signalBufferAvailable.Set(); // unblock potentially waiting writer
                m_readerStream = null;
            }

            if (Interlocked.Decrement(ref m_autoDisposeCounter) == 0)
            {
                this.Dispose();
            }
        }
Beispiel #3
0
        private void readerClosed()
        {
            lock (m_lock)
            {
                if (m_readerClosed) return;
                m_readerClosed = true;
                m_signalBufferAvailable.Set(); // unblock potentially waiting writer
                m_readerStream = null;
            }

            if (Interlocked.Decrement(ref m_autoDisposeCounter) == 0)
                this.Dispose();
        }
Beispiel #4
0
 /// <summary> Sets up the DirectStreamLink with a certain behaviour. </summary>
 /// <param name="bufsize"> The size of the internal  buffer to use. </param>
 /// <param name="blockOnFlush"> Specifies to block Flush until reader has read buffer empty. This is not suited for synching. </param>
 /// <param name="blockOnClose"> Specifies to block close of writer until reader has closed. Can be used for synching. </param>
 /// <param name="passWriteThrough"> A stream all written data is just passed to. For stream stacking. </param>
 public DirectStreamLink(int bufsize, bool blockOnFlush, bool blockOnClose, Stream passWriteThrough)
 {
     m_passWriteThrough = passWriteThrough;
     m_blockOnFlush = blockOnFlush;
     m_blockOnClose = blockOnClose;
     if (bufsize <= 0) throw new ArgumentOutOfRangeException("bufsize");
     m_buf = new byte[bufsize];
     m_readerStream = new LinkedReaderStream(this);
     m_writerStream = new LinkedWriterStream(this);
 }