using System.Collections.Concurrent; namespace Myshipping.Core; /// /// 简单泛型队列 /// public static class SimpleQueue where T : new() { private static ConcurrentQueue _simpleQueue; static SimpleQueue() { _simpleQueue = new ConcurrentQueue(); } /// /// 新增 /// /// public static void Add(T obj) { _simpleQueue.Enqueue(obj); } /// /// 取出 /// /// /// public static bool Try(out T obj) { return _simpleQueue.TryDequeue(out obj); } /// /// 总数 /// /// public static int Count() { return _simpleQueue.Count; } /// /// 清理 /// public static void Clear() { _simpleQueue.Clear(); } }