diff --git a/src/DataStreamSuite/SharedStreams/Business/MarketData/BookStream.cs b/src/DataStreamSuite/SharedStreams/Business/MarketData/BookStream.cs index 2fa2dcb8d..1a4ec4dab 100644 --- a/src/DataStreamSuite/SharedStreams/Business/MarketData/BookStream.cs +++ b/src/DataStreamSuite/SharedStreams/Business/MarketData/BookStream.cs @@ -95,7 +95,7 @@ namespace bts.BlueOrb{ new_state.addRow(r); } } - DataPacket dp = null; + DataPacket? dp; if (myLastValue == null) { dp = new DataPacket(new_state, new_state, new BlueTable(_bbo_schema)); } else { diff --git a/src/DataStreamSuite/SharedStreams/Business/MarketData/OHLCVStream.cs b/src/DataStreamSuite/SharedStreams/Business/MarketData/OHLCVStream.cs index ae5523fb3..e5b501fe2 100644 --- a/src/DataStreamSuite/SharedStreams/Business/MarketData/OHLCVStream.cs +++ b/src/DataStreamSuite/SharedStreams/Business/MarketData/OHLCVStream.cs @@ -168,7 +168,9 @@ namespace bts.BlueOrb { } private Source _sourse = Source.SQL; // get from config - private readonly string _location = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "C:\\BlueOrb_Data\\":Path.Combine(Environment.GetEnvironmentVariable("HOME") , "BlueOrb_Data"); + readonly string _location = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) + ? "C:\\BlueOrb_Data\\" + : Path.Combine(Environment.GetEnvironmentVariable("HOME") ?? string.Empty, "BlueOrb_Data"); private readonly string _db_name = "stream_data.db"; // the symbol is used ot retreive the correct table, the data flows as-is from the table // with some name / type changes diff --git a/src/cs/Bts.Spark.Sdk/OrderPool.cs b/src/cs/Bts.Spark.Sdk/OrderPool.cs index 666e31d5c..cd31b87f0 100644 --- a/src/cs/Bts.Spark.Sdk/OrderPool.cs +++ b/src/cs/Bts.Spark.Sdk/OrderPool.cs @@ -32,10 +32,22 @@ class OrderPool { } public void Replenish() { - int nUsed = Math.Min(cursor, orderPool.Length); - for (int i = 0; i < nUsed; i++) { - orderPool[i] = factory(); + if (this.cursor == 0) { + return; } - Volatile.Write(ref cursor, 0); + int cursor; + int nUsed; + int nReplenished = 0; + while (nReplenished < orderPool.Length) { + cursor = Volatile.Read(ref this.cursor); + nUsed = Math.Min(cursor, orderPool.Length); + for (; nReplenished < nUsed; nReplenished++) { + orderPool[nReplenished] = factory(); + } + if (Interlocked.CompareExchange(ref this.cursor, 0, cursor) == cursor) { + return; + } + } + Volatile.Write(ref this.cursor, 0); } }