blob: 051fedd9dca770cb8954bcc6d34043a3909eec09 (
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
30
31
32
33
34
35
36
|
using System;
using System.Collections.Generic;
using gorilla.utility;
namespace gorilla.infrastructure.threading
{
public class SynchronousCommandProcessor : CommandProcessor
{
readonly Queue<Command> queued_commands;
public SynchronousCommandProcessor()
{
queued_commands = new Queue<Command>();
}
public void add(Action command)
{
add(new AnonymousCommand(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();
}
}
}
|