コード例 #1
0
        public virtual Task <IOperation> Enqueue(IOperation op)
        {
            var tcs = new TaskCompletionSource <IOperation>();

            counterItemCount.Increment();

            if (IsAlive)
            {
                writeQueue.Enqueue(new Data {
                    Op = op, Task = tcs
                });
                counterEnqueuePerSec.Increment();
                counterWriteQueue.Increment();

                if (trace.IsEnabled())
                {
                    trace.EnqueueWriteOp(name);
                }
            }
            else
            {
                counterErrorPerSec.Increment();
                tcs.SetException(new IOException(endpoint + " is not alive"));
            }

            return(tcs.Task);
        }
コード例 #2
0
        public void ScheduleSend(Action <bool> whenDone)
        {
            if (trace.IsEnabled())
            {
                trace.SendStart(name, IsAlive, sendBuffer.Position);
            }

            if (!IsAlive)
            {
                whenDone(false);
                return;
            }

            IsBusy             = true;
            sendArgs.UserToken = whenDone;

            PerformSend(sendBuffer.BufferOffset, sendBuffer.Position);
        }