x) Added enum for CommitResults x) Created interface IID<TS> x) Implemented DB class with lock, objects, committed lists x) Updated lookup and checkout methods in DB class x) Added TxStates enum and implemented Tx class with checkout, add, dispose methods x) Implemented commit method in DB class to handle transactions efficiently
42 lines
1.0 KiB
C#
42 lines
1.0 KiB
C#
using System.Collections.Generic;
|
|
|
|
namespace Tracing
|
|
{
|
|
public class AddressStack
|
|
{
|
|
// the first frame is the address of the last called method
|
|
private readonly List<ulong> _stack;
|
|
|
|
public AddressStack(int capacity)
|
|
{
|
|
_stack = new List<ulong>(capacity);
|
|
}
|
|
|
|
// No need to override GetHashCode because we don't want to use it as a key in a dictionary
|
|
public override bool Equals(object obj)
|
|
{
|
|
if (obj == null) return false;
|
|
|
|
var stack = obj as AddressStack;
|
|
if (stack == null) return false;
|
|
|
|
var frameCount = _stack.Count;
|
|
if (frameCount != stack._stack.Count) return false;
|
|
|
|
for (int i = 0; i < frameCount; i++)
|
|
{
|
|
if (_stack[i] != stack._stack[i]) return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public IReadOnlyList<ulong> Stack => _stack;
|
|
|
|
public void AddFrame(ulong address)
|
|
{
|
|
_stack.Add(address);
|
|
}
|
|
}
|
|
}
|