新增 Mjpegplayer 用来播放 Web 流
This commit is contained in:
22
SHH.MjpegPlayer/GrpcImpls/Core/ConcurrentHashSet.cs
Normal file
22
SHH.MjpegPlayer/GrpcImpls/Core/ConcurrentHashSet.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
namespace SHH.MjpegPlayer
|
||||
{
|
||||
/// <summary>
|
||||
/// 辅助类:线程安全集合
|
||||
/// </summary>
|
||||
public class ConcurrentHashSet<T> : IEnumerable<T>
|
||||
{
|
||||
private readonly ConcurrentDictionary<T, byte> _dict = new ConcurrentDictionary<T, byte>();
|
||||
|
||||
public void Add(T item) => _dict.TryAdd(item, 0);
|
||||
|
||||
public void Remove(T item) => _dict.TryRemove(item, out _);
|
||||
|
||||
public bool IsEmpty => _dict.IsEmpty;
|
||||
|
||||
public IEnumerator<T> GetEnumerator() => _dict.Keys.GetEnumerator();
|
||||
|
||||
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() => GetEnumerator();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user