Skip to content

Commit 65af099

Browse files
committed
OrderBookIncrementManager: RemoveSubscription returns bool, log only on actual removal
1 parent b8ec626 commit 65af099

3 files changed

Lines changed: 11 additions & 9 deletions

File tree

Algo/IOrderBookIncrementManagerState.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ public interface IOrderBookIncrementManagerState
6868
/// <summary>
6969
/// Remove subscription.
7070
/// </summary>
71-
void RemoveSubscription(long id);
71+
/// <returns><see langword="true"/> if subscription was found and removed.</returns>
72+
bool RemoveSubscription(long id);
7273

7374
/// <summary>
7475
/// Clear all state.

Algo/OrderBookIncrementManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ public sealed class OrderBookIncrementManager(ILogReceiver logReceiver, IOrderBo
162162

163163
private void RemoveSubscription(long id)
164164
{
165-
_state.RemoveSubscription(id);
166-
_logReceiver.AddInfoLog("Unsubscribed {0}.", id);
165+
if (_state.RemoveSubscription(id))
166+
_logReceiver.AddInfoLog("Unsubscribed {0}.", id);
167167
}
168168

169169
/// <inheritdoc/>

Algo/OrderBookIncrementManagerState.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public bool ContainsSubscription(long subscriptionId)
154154
}
155155

156156
/// <inheritdoc />
157-
public void RemoveSubscription(long id)
157+
public bool RemoveSubscription(long id)
158158
{
159159
using (_sync.EnterScope())
160160
{
@@ -168,17 +168,16 @@ public void RemoveSubscription(long id)
168168

169169
if (info == null)
170170
{
171-
_passThrough.Remove(id);
172-
_allSecSubscriptions.Remove(id);
173-
_allSecSubscriptionsPassThrough.Remove(id);
174-
return;
171+
return _passThrough.Remove(id) |
172+
_allSecSubscriptions.Remove(id) |
173+
_allSecSubscriptionsPassThrough.Remove(id);
175174
}
176175
}
177176

178177
var secId = info.Builder.SecurityId;
179178

180179
if (info != _online.TryGetValue(secId))
181-
return;
180+
return false;
182181

183182
info.SubscriptionIds.Remove(id);
184183

@@ -188,6 +187,8 @@ public void RemoveSubscription(long id)
188187
_online.Remove(secId);
189188
else if (changeId && !_byId.ContainsKey(ids[0]))
190189
_byId.Add(ids[0], info);
190+
191+
return true;
191192
}
192193
}
193194

0 commit comments

Comments
 (0)