internal override Task <T> ExecuteAsync <T>(Message message, ResultProcessor <T> processor, ServerEndPoint server = null)
        {
            if (message == null)
            {
                return(CompletedTask <T> .Default(asyncState));
            }
            multiplexer.CheckMessage(message);

            multiplexer.Trace("Wrapping " + message.Command, "Transaction");
            // prepare the inner command as a task
            Task <T> task;

            if (message.IsFireAndForget)
            {
                task = CompletedTask <T> .Default(null); // F+F explicitly does not get async-state
            }
            else
            {
                var tcs    = TaskSource.CreateDenyExecSync <T>(asyncState);
                var source = ResultBox <T> .Get(tcs);

                message.SetSource(source, processor);
                task = tcs.Task;
            }

            // prepare an outer-command that decorates that, but expects QUEUED
            var queued    = new QueuedMessage(message);
            var wasQueued = ResultBox <bool> .Get(null);

            queued.SetSource(wasQueued, QueuedProcessor.Default);

            // store it, and return the task of the *outer* command
            // (there is no task for the inner command)
            (pending ?? (pending = new List <QueuedMessage>())).Add(queued);


            switch (message.Command)
            {
            case RedisCommand.EVAL:
            case RedisCommand.EVALSHA:
                // people can do very naughty things in an EVAL
                // including change the DB; change it back to what we
                // think it should be!
                var sel = PhysicalConnection.GetSelectDatabaseCommand(message.Db);
                queued    = new QueuedMessage(sel);
                wasQueued = ResultBox <bool> .Get(null);

                queued.SetSource(wasQueued, QueuedProcessor.Default);
                pending.Add(queued);
                break;
            }
            return(task);
        }
        internal Task <T> QueueDirectAsync <T>(Message message, ResultProcessor <T> processor, object asyncState = null, PhysicalBridge bridge = null)
        {
            var tcs    = TaskSource.CreateDenyExecSync <T>(asyncState);
            var source = ResultBox <T> .Get(tcs);

            message.SetSource(processor, source);
            if (bridge == null)
            {
                bridge = GetBridge(message.Command);
            }
            if (!bridge.TryEnqueue(message, isSlave))
            {
                ConnectionMultiplexer.ThrowFailed(tcs, ExceptionFactory.NoConnectionAvailable(multiplexer.IncludeDetailInExceptions, message.Command, message, this, multiplexer.GetServerSnapshot()));
            }
            return(tcs.Task);
        }
 internal ConditionResult(Condition condition)
 {
     this.Condition = condition;
     resultBox      = ResultBox <bool> .Get(condition);
 }