summaryrefslogtreecommitdiff
path: root/code/common/SynchronousCommandProcessor.cs
blob: e75d9a8f5c8788a04a9cfafb4d6c2cec86d69c6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using System.Collections.Generic;

namespace common
{
    public class SynchronousCommandProcessor : CommandProcessor
    {
        readonly Queue<Command> queued_commands;

        public SynchronousCommandProcessor()
        {
            queued_commands = new Queue<Command>();
        }

        public void add(Command command_to_process)
        {
            queued_commands.Enqueue(command_to_process);
        }

        public void run()
        {
            while (queued_commands.Count > 0) queued_commands.Dequeue().run();
        }

        public void stop()
        {
            queued_commands.Clear();
        }
    }
}