using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BPASmartClient.Helper
{
///
/// 数据仓库
///
public class DataStorage
{
private ConcurrentQueue cache = new ConcurrentQueue();
public void PutData(T data)
{
cache.Enqueue(data);
}
public void PutData(T[] data)
{
foreach (var item in data)
cache.Enqueue(item);
}
public T GetData()
{
if (cache.Count >= 0)
{
cache.TryDequeue(out T data);
return data;
}
return default(T);
}
public int GetSize()
{
return cache.Count;
}
}
}