forked from dotnet/MQTTnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add max pending messages options for ManagedClient.
- Loading branch information
Showing
14 changed files
with
308 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
Source/MQTTnet.Extensions.ManagedClient/ApplicationMessageSkippedEventArgs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
|
||
namespace MQTTnet.Extensions.ManagedClient | ||
{ | ||
public class ApplicationMessageSkippedEventArgs : EventArgs | ||
{ | ||
public ApplicationMessageSkippedEventArgs(ManagedMqttApplicationMessage applicationMessage) | ||
{ | ||
ApplicationMessage = applicationMessage ?? throw new ArgumentNullException(nameof(applicationMessage)); | ||
} | ||
|
||
public ManagedMqttApplicationMessage ApplicationMessage { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading; | ||
|
||
namespace MQTTnet.Internal | ||
{ | ||
public class BlockingQueue<TItem> | ||
{ | ||
private readonly object _syncRoot = new object(); | ||
private readonly LinkedList<TItem> _items = new LinkedList<TItem>(); | ||
private readonly ManualResetEvent _gate = new ManualResetEvent(false); | ||
|
||
public int Count | ||
{ | ||
get | ||
{ | ||
lock (_syncRoot) | ||
{ | ||
return _items.Count; | ||
} | ||
} | ||
} | ||
|
||
public void Enqueue(TItem item) | ||
{ | ||
if (item == null) throw new ArgumentNullException(nameof(item)); | ||
|
||
lock (_syncRoot) | ||
{ | ||
_items.AddLast(item); | ||
_gate.Set(); | ||
} | ||
} | ||
|
||
public TItem Dequeue() | ||
{ | ||
while (true) | ||
{ | ||
lock (_syncRoot) | ||
{ | ||
if (_items.Count > 0) | ||
{ | ||
var item = _items.First.Value; | ||
_items.RemoveFirst(); | ||
|
||
return item; | ||
} | ||
|
||
if (_items.Count == 0) | ||
{ | ||
_gate.Reset(); | ||
} | ||
} | ||
|
||
_gate.WaitOne(); | ||
} | ||
} | ||
|
||
public TItem RemoveFirst() | ||
{ | ||
lock (_syncRoot) | ||
{ | ||
var item = _items.First; | ||
_items.RemoveFirst(); | ||
return item.Value; | ||
} | ||
} | ||
|
||
public void Clear() | ||
{ | ||
lock (_syncRoot) | ||
{ | ||
_items.Clear(); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.