Skip to content

Commit 0c90797

Browse files
A bunch of general cleanup
1 parent a1f6dbb commit 0c90797

20 files changed

+186
-264
lines changed
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Diagnostics;
33
using System.Globalization;
44
using System.IO;
5-
using System.Text;
65

76
namespace RB4InstrumentMapper
87
{

Program/MainWindow/FixedSizeConcurrentQueue.cs

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,39 @@
1-
using System;
2-
using System.Collections.Concurrent;
3-
using System.Collections.Generic;
4-
using System.Linq;
5-
using System.Text;
6-
using System.Threading.Tasks;
1+
using System.Collections.Concurrent;
72

83
namespace RB4InstrumentMapper
94
{
105
/// <summary>
11-
/// Implementation of a fixed-size concurrent queue.
6+
/// A concurrent queue with a size limit.
127
/// </summary>
13-
/// <typeparam name="T"></typeparam>
148
public class FixedSizeConcurrentQueue<T> : ConcurrentQueue<T>
159
{
16-
/// <summary>
17-
/// Sync root of the queue for locking.
18-
/// </summary>
19-
private readonly object privateLockObject = new object();
10+
private readonly object queueLock = new object();
2011

2112
/// <summary>
2213
/// Size of the queue.
2314
/// </summary>
24-
public int Size { get; private set; }
15+
public int MaxSize { get; private set; }
2516

2617
/// <summary>
27-
/// Create a new instance of the FixedSizeConcurrentQueue.
18+
/// Creates a new queue with the given max size.
2819
/// </summary>
29-
/// <param name="size">Size of the queue.</param>
20+
3021
public FixedSizeConcurrentQueue(int size)
3122
{
32-
Size = size;
23+
MaxSize = size;
3324
}
3425

3526
/// <summary>
36-
/// Enqueue an object into the queue. Maintains size limit of queue.
27+
/// Enqueues an object into the queue, discarding any items at the end of the queue which exceed the max count.
3728
/// </summary>
38-
/// <param name="obj">Object to enqueue</param>
3929
public new void Enqueue(T obj)
4030
{
4131
base.Enqueue(obj);
42-
lock (privateLockObject)
32+
lock (queueLock)
4333
{
44-
while (base.Count > Size)
34+
while (Count > MaxSize)
4535
{
46-
T outObj;
47-
base.TryDequeue(out outObj);
36+
TryDequeue(out _);
4837
}
4938
}
5039
}

0 commit comments

Comments
 (0)