예제 #1
0
        public bool TryEnqueue(Message message, bool isSlave)
        {
            if (isDisposed)
            {
                throw new ObjectDisposedException(Name);
            }
            if (!IsConnected)
            {
                if (message.IsInternalCall)
                {
                    // you can go in the queue, but we won't be starting
                    // a worker, because the handshake has not completed
                    queue.Push(message);
                    message.SetEnqueued();
                    return(true);
                }
                else
                {
                    // sorry, we're just not ready for you yet;
                    return(false);
                }
            }

            bool reqWrite = queue.Push(message);

            message.SetEnqueued();
            LogNonPreferred(message.Flags, isSlave);
            Trace("Now pending: " + GetPendingCount());

            if (reqWrite)
            {
                multiplexer.RequestWrite(this, false);
            }
            return(true);
        }