Shuxia Ning
2024-10-08 cf4967a0aebab18c5a37137f3e4c61b2d73a54bb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Concurrent;
 
namespace IStation
{
    /// <summary>
    /// 简单内存通道辅助类
    /// </summary>
    public class SimpleMemoryQueueHelper<T>
    {
        private static readonly BlockingCollection<T> _queue = new BlockingCollection<T>(new ConcurrentQueue<T>());
 
        /// <summary>
        /// 推送
        /// </summary>
        public static bool Push(T model)
        {
            _queue.Add(model);
            return true;
        }
 
        /// <summary>
        /// 获取
        /// </summary>
        public static T Take()
        {
            return _queue.Take();
        }
 
 
    }
}