// Schedules a command for later execution.
        public override void ScheduleCommand(AsyncCommand command)
        {
            SocketAsyncEventArgs e;

            // Try to dequeue one SocketAsyncEventArgs object from the queue and execute it.
            if (_argsQueue.TryDequeue(out e))
            {
                // If there are no awaiting command, the current command can be executed immediately.
                if (_commandQueue.IsEmpty)                 // NB: We could make the choice to always execute the command synchronously in this case. Might be better for performance.
                {
                    command.ExecuteInline(e);
                    return;
                }
                else
                {
                    _argsQueue.Enqueue(e);
                }
            }
            else
            {
                // In blocking mode, the command can be queued for later execution.
                _commandQueue.Enqueue(command);
            }

            TriggerCommandScheduling();
        }
예제 #2
0
        // Schedules a command for later execution.
        // Throws <see cref="AerospikeException.CommandRejected"/> if command is rejected.
        public override void ScheduleCommand(AsyncCommand command)
        {
            SocketAsyncEventArgs e;

            // Try to dequeue one SocketAsyncEventArgs object from the queue and execute the command.
            if (argsQueue.TryDequeue(out e))
            {
                command.ExecuteInline(e);
            }
            else
            {
                // Queue is empty. Reject command.
                throw new AerospikeException.CommandRejected();
            }
        }
예제 #3
0
        // Schedules a command for later execution.
        public override bool ScheduleCommand(AsyncCommand command)
        {
            SocketAsyncEventArgs e;

            // Try to dequeue one SocketAsyncEventArgs object from the queue and execute the command.
            if (_argsQueue.TryDequeue(out e))
            {
                command.ExecuteInline(e);
                return(true);
            }
            else
            {
                return(false);
            }
        }
 // Schedules a command for later execution.
 public override bool ScheduleCommand(AsyncCommand command)
 {
     command.ExecuteInline(_argsQueue.Take());
     return(true);
 }
 // Schedules a command for later execution.
 public override void ScheduleCommand(AsyncCommand command)
 {
     // Block until EventArgs becomes available.
     command.ExecuteInline(argsQueue.Take());
 }