Don't eagerly acquire distributed (SQL) locks (#10171)

This commit is contained in:
Shannon Deminick
2021-09-13 21:09:47 +10:00
committed by GitHub
parent b17cc47632
commit 5fadb238ee
14 changed files with 712 additions and 245 deletions

View File

@@ -0,0 +1,60 @@
using System.Collections.Generic;
namespace Umbraco.Core.Collections
{
/// <summary>
/// Collection that can be both a queue and a stack.
/// </summary>
/// <typeparam name="T"></typeparam>
public class StackQueue<T>
{
private readonly LinkedList<T> _linkedList = new LinkedList<T>();
public void Clear()
{
_linkedList.Clear();
}
public void Push(T obj)
{
_linkedList.AddFirst(obj);
}
public void Enqueue(T obj)
{
_linkedList.AddFirst(obj);
}
public T Pop()
{
var obj = _linkedList.First.Value;
_linkedList.RemoveFirst();
return obj;
}
public T Dequeue()
{
var obj = _linkedList.Last.Value;
_linkedList.RemoveLast();
return obj;
}
public T PeekStack()
{
return _linkedList.First.Value;
}
public T PeekQueue()
{
return _linkedList.Last.Value;
}
public int Count
{
get
{
return _linkedList.Count;
}
}
}
}