main
 1using System;
 2using System.Collections.Generic;
 3
 4namespace jive
 5{
 6  public class SynchronousCommandProcessor : CommandProcessor
 7  {
 8    readonly Queue<Command> queued_commands;
 9
10    public SynchronousCommandProcessor()
11    {
12      queued_commands = new Queue<Command>();
13    }
14
15    public void add(Action command)
16    {
17      add(new AnonymousCommand(command));
18    }
19
20    public void add(Command command_to_process)
21    {
22      queued_commands.Enqueue(command_to_process);
23    }
24
25    public void run()
26    {
27      while (queued_commands.Count > 0) queued_commands.Dequeue().run();
28    }
29
30    public void stop()
31    {
32      queued_commands.Clear();
33    }
34  }
35}