Skip to content

Commit

Permalink
Use work-threads for ordering instead of IO threads.
Browse files Browse the repository at this point in the history
  • Loading branch information
NiclasOlofsson committed Jul 9, 2016
1 parent 6ce846e commit 79b9fdb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/MiNET/MiNET/MiNetServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ internal void HandlePackage(Package message, PlayerNetworkSession playerSession)

if (message.Reliability == Reliability.ReliableOrdered)
{
playerSession.AddToProcessing(message);
Task.Run(() => playerSession.AddToProcessing(message));
return;
}

Expand Down
4 changes: 1 addition & 3 deletions src/MiNET/MiNET/PlayerNetworkSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ public void Clean()
private AutoResetEvent _mainWaitEvent = new AutoResetEvent(false);
private object _eventSync = new object();

//private BlockingCollection<KeyValuePair<int, Package>> _queue = new BlockingCollection<KeyValuePair<int, Package>>();
//private BlockingCollection<KeyValuePair<int, Package>> _queue = new BlockingCollection<KeyValuePair<int, Package>>(new ConcurrentPriorityQueue<int, Package>());
private ConcurrentPriorityQueue<int, Package> _queue = new ConcurrentPriorityQueue<int, Package>();
private CancellationTokenSource _cancellationToken;

Expand All @@ -123,7 +121,7 @@ public void AddToProcessing(Package message)

lock (_eventSync)
{
if(_queue.Count == 0 && message.OrderingIndex == _lastSequenceNumber + 1)
if (_queue.Count == 0 && message.OrderingIndex == _lastSequenceNumber + 1)
{
_lastSequenceNumber = message.OrderingIndex;
HandlePackage(message, this);
Expand Down

0 comments on commit 79b9fdb

Please sign in to comment.