瀏覽代碼

New functions

This is to support the peek-and-publish model for the managed client
release/3.x.x
Paul Fake 6 年之前
committed by GitHub
父節點
當前提交
9ff39c1fd9
沒有發現已知的金鑰在資料庫的簽署中 GPG 金鑰 ID: 4AEE18F83AFDEB23
共有 1 個檔案被更改,包括 32 行新增0 行删除
  1. +32
    -0
      Source/MQTTnet/Internal/BlockingQueue.cs

+ 32
- 0
Source/MQTTnet/Internal/BlockingQueue.cs 查看文件

@@ -55,6 +55,38 @@ namespace MQTTnet.Internal
_gate.WaitOne();
}
}
public TItem PeekAndWait()
{
while (true)
{
lock (_syncRoot)
{
if (_items.Count > 0)
{
return _items.First.Value;
}

if (_items.Count == 0)
{
_gate.Reset();
}
}

_gate.WaitOne();
}
}

public void RemoveFirstIfEqual(TItem item)
{
lock (_syncRoot)
{
if (_items.Count > 0 && EqualityComparer<TItem>.Default.Equals(_items.First.Value, item))
{
_items.RemoveFirst();
}
}
}

public TItem RemoveFirst()
{


Loading…
取消
儲存