コード例 #1
0
        /// <summary>
        /// Sends the current chunked op. Happens when an op's data cannot fit the write buffer in one pass.
        /// </summary>
        /// <returns>returns true if further IO is required; false if no inprogress op present or the last chunk was successfully added to the buffer</returns>
        private bool ContinueWritingCurrentOp()
        {
            // check if we have an op in progress
            if (currentWriteCopier == null)
            {
                return(false);
            }
            if (currentWriteCopier.WriteTo(socket.WriteBuffer))
            {
                return(true);
            }

            // last chunk was sent
            if (LogTraceEnabled)
            {
                log.Trace("Sent & finished " + currentWriteOp.Op);
            }


            // op is sent fully; response can be expected
            readQueue.Enqueue(currentWriteOp);
            counterReadQueue.Increment();
            if (trace.IsEnabled())
            {
                trace.EnqueueReadOp(name);
            }

            // clean up
            currentWriteCopier.Dispose();
            currentWriteCopier = null;
            currentWriteOp     = Data.Empty;

            return(false);
        }
コード例 #2
0
        /// <summary>
        /// Writes an operation to the output buffer. Handles the case where the op does not fit the buffer fully.
        /// </summary>
        /// <param name="data"></param>
        protected virtual void WriteOp(OpQueueEntry data)
        {
            if (currentWriteCopier != null)
            {
                throw new InvalidOperationException("Cannot write an operation while another is in progress.");
            }

            var request = data.Op.CreateRequest();

            if (!request.WriteTo(socket.WriteBuffer))             // no pending IO => fully written
            {
                readQueue.Enqueue(data);
                request.Dispose();

                #region Diagnostics
                npm.EnqueueReadOp();
                CoreEventSource.EnqueueReadOp(name);

                LogTo.Trace($"Full send of {data.Op}");
                #endregion
            }
            else
            {
                // it did not fit into the write buffer, so save the current op
                // as "in-progress"; DoRun will loop until it's fully sent
                currentWriteOp     = data;
                currentWriteCopier = request;

                LogTo.Trace($"Partial send of {data.Op}");
            }
        }
コード例 #3
0
        /// <summary>
        /// Sends the current chunked op. Happens when an op's data cannot fit the write buffer in one pass.
        /// </summary>
        /// <returns>returns true if further IO is required; false if no inprogress op present or the last chunk was successfully added to the buffer</returns>
        private bool ContinueWritingCurrentOp()
        {
            // check if we have an op in progress
            if (currentWriteCopier == null)
            {
                return(false);
            }
            if (currentWriteCopier.WriteTo(socket.WriteBuffer))
            {
                return(true);
            }

            // last chunk was sent
            LogTo.Trace($"Sent & finished {currentWriteOp.Op}");

            // op is sent fully; response can be expected
            readQueue.Enqueue(currentWriteOp);

            #region Diagnostics
            npm.EnqueueReadOp();
            CoreEventSource.EnqueueReadOp(name);
            #endregion

            // clean up
            currentWriteCopier.Dispose();
            currentWriteCopier = null;
            currentWriteOp     = OpQueueEntry.Empty;

            return(false);
        }