cleanup: Fix numerous build warnings in DataStreamSuite

Nearly all warnings were due to nullability issues, since the concept of
nullable reference types did not exist when the DataStream code was
originally written.

* Compression related files
  - BZip2InputStream  (disable nullability warnings)
  - BZip2OutputStream (disable nullability warnings)
  - DeflaterHuffman   (disable nullability warnings)
  - Inflater          (disable nullability warnings)
  - InflaterDynHeader (disable nullability warnings)
  - ParallelJoinTest  (disable nullability warnings)
  - TarHeader
  - TarInputStream    (disable nullability warnings)
  - ZipEntry
  - ZipFile
  - ZipInputStream

* AsyncTCPConnection_APM
* AsyncTCPConnection_APM
* InflaterHuffmanTree
* ManagedSubscriber
* ManagedTCPMessageHub
* MapStream
* PubSubClientMessage
  - Normalize indentation/whitespace
  - Fix some typos
  - Address nullability issues to fix build warnings
  - Modernize code
* PubSubMessageReactor
* PubSubServerManagedTCPConnection
* PubSubSingleTagStateEvent
* PubSubState
* PublisherCore
* PubsubDeserializationController
* RemoteMessage
  - make 'message' nullable to resolve warnings elsewhere (in calling code)
* SharedStreamConfig
* SingleTagData
* SubscriberCore
* SuperMapStream
* SystemHeartbeatPublisher
* SystemStatsPublisher
* SystemSubscriptionMapPublisher
* ThreadSafeQueue
* TradeBarsStream

Only use Registry on windows.
This commit is contained in:
John Colvin committed 2025-12-30 11:38:20 -05:00
1 parent 02f566a970
commit 7d6e4efa4f
45 files changed
+859 -828

No files matched your search

@@ -14,7 +14,7 @@ namespace BCG
public class ThreadSafeQueue<T>
{
private readonly int _max_size = Int32.MaxValue;
private Queue<T> _main_queue = new Queue<T>();
private Queue<T?> _main_queue = new();
private DateTime _last_dequeque_time = DateTime.MinValue;
private string _queue_name = String.Empty;
@@ -41,7 +41,7 @@ namespace BCG
_warning_log_period = warning_log_period;
}
public virtual bool enqueue(T t)
public virtual bool enqueue(T? t)
{
lock (this)
{
@@ -98,9 +98,9 @@ namespace BCG
return rv;
}
public virtual T dequeue()
public virtual T? dequeue()
{
T rv;
T? rv;
lock (this)
{
if (_main_queue.Count > 0)
@@ -109,14 +109,14 @@ namespace BCG
rv = _main_queue.Dequeue();
}
else
rv = default(T);
rv = default;
}
return rv;
}
public virtual List<T> dequeueAll()
public virtual List<T?> dequeueAll()
{
List<T> rv = new List<T>();
var rv = new List<T?>();
lock (this)
{
int sz = getCount();
@@ -126,13 +126,13 @@ namespace BCG
return rv;
}
public virtual bool enqueue_and_crush(T new_elem, Comparison<T> comp)
public virtual bool enqueue_and_crush(T new_elem, Comparison<T?> comp)
{
bool rv;
lock (this)
{
Dictionary<int, bool> marked_for_deletion = new Dictionary<int,bool> ();
List<T> all_elements = dequeueAll();
var all_elements = dequeueAll();
for (int i = 0; i < all_elements.Count; i++)
if (_compare (new_elem, all_elements[i], comp))
marked_for_deletion.Add (i,true);
@@ -144,7 +144,7 @@ namespace BCG
return rv;
}
private static bool _compare(T t1, T t2, Comparison<T> comp)
private static bool _compare(T? t1, T? t2, Comparison<T?> comp)
{
if (comp != null)
return comp (t1, t2) == 0;
@@ -152,9 +152,9 @@ namespace BCG
return t1 != null && t1.Equals(t2);
}
public virtual List<T> dequeueLimited(int max)
public virtual List<T?> dequeueLimited(int max)
{
List<T> rv = new List<T>();
var rv = new List<T?>();
lock (this)
{
int limit = Math.Min (max, _main_queue.Count);