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