-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommandTracing.cs
More file actions
executable file
·41 lines (34 loc) · 955 Bytes
/
CommandTracing.cs
File metadata and controls
executable file
·41 lines (34 loc) · 955 Bytes
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
37
38
39
40
41
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace TeamDev.Redis
{
internal class CommandTracing
{
private Queue<CommandTrace> _commandsequence = new Queue<CommandTrace>();
private int _nextcommandid = 0;
public int TraceCommand(RedisCommand command)
{
return TraceCommand(command.ToString());
}
public int TraceCommand(string command)
{
_nextcommandid++;
_commandsequence.Enqueue(new CommandTrace() { Id = _nextcommandid, Command = command });
return _nextcommandid;
}
public void CheckBalancing(int commandid)
{
var c = _commandsequence.Dequeue();
if (c.Id == commandid)
return;
throw new UnbalancedReadException(string.Format("Discovered an unbalanced Read for command : {1} {0} ", c.Command, c.Id));
}
}
internal struct CommandTrace
{
public int Id;
public string Command;
}
}