MdpOutboxWakeSignal.cs 646 B

1234567891011121314151617181920
  1. using System.Threading.Channels;
  2. namespace Admin.NET.Plugin.AiDOP.DataPlatform.Executors;
  3. /// <summary>
  4. /// 出站唤醒信号:入队后 Pulse,由 <see cref="MdpOutboxPushWorker"/> 立即推送;轮询 Job 仅作兜底。
  5. /// </summary>
  6. public sealed class MdpOutboxWakeSignal : ISingleton
  7. {
  8. private readonly Channel<byte> _channel = Channel.CreateBounded<byte>(new BoundedChannelOptions(1)
  9. {
  10. FullMode = BoundedChannelFullMode.DropOldest,
  11. SingleReader = true,
  12. SingleWriter = false
  13. });
  14. public void Pulse() => _channel.Writer.TryWrite(0);
  15. public ChannelReader<byte> Reader => _channel.Reader;
  16. }