Skip to content

Commit

Permalink
🐛 Fix Min ↔️ Max inversion in DeviceRegistry 😥
Browse files Browse the repository at this point in the history
This would only impact setups with a high number of devices, but it does make the service quite useless.
  • Loading branch information
hexawyz committed Jul 28, 2024
1 parent 571b9e0 commit a025cbd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Exo.Service.Core/DeviceRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ public async IAsyncEnumerable<DeviceWatchNotification> WatchAllAsync([Enumerator

lock (_lock)
{
initialNotifications = ArrayPool<DeviceWatchNotification>.Shared.Rent(Math.Min(_deviceStates.Count, 10));
initialNotifications = ArrayPool<DeviceWatchNotification>.Shared.Rent(Math.Max(_deviceStates.Count, 10));
foreach (var state in _deviceStates.Values)
{
initialNotifications[initialNotificationCount++] = new(WatchNotificationKind.Enumeration, state.GetDeviceStateInformation(), state.Driver);
Expand Down Expand Up @@ -655,7 +655,7 @@ public async IAsyncEnumerable<DeviceWatchNotification> WatchAvailableAsync([Enum

lock (_lock)
{
initialNotifications = ArrayPool<DeviceWatchNotification>.Shared.Rent(Math.Min(_deviceStates.Count, 10));
initialNotifications = ArrayPool<DeviceWatchNotification>.Shared.Rent(Math.Max(_deviceStates.Count, 10));
foreach (var state in _deviceStates.Values)
{
if (state.Driver is not null)
Expand Down Expand Up @@ -728,7 +728,7 @@ public async IAsyncEnumerable<DeviceWatchNotification> WatchAllAsync<TFeature>([

lock (_lock)
{
initialNotifications = ArrayPool<DeviceWatchNotification>.Shared.Rent(Math.Min(_deviceStates.Count, 10));
initialNotifications = ArrayPool<DeviceWatchNotification>.Shared.Rent(Math.Max(_deviceStates.Count, 10));
foreach (var state in _deviceStates.Values)
{
if (state.DeviceInformation.SupportedFeatureIds.Contains(featureId))
Expand Down Expand Up @@ -801,7 +801,7 @@ public async IAsyncEnumerable<DeviceWatchNotification> WatchAvailableAsync<TFeat

lock (_lock)
{
initialNotifications = ArrayPool<DeviceWatchNotification>.Shared.Rent(Math.Min(_deviceStates.Count, 10));
initialNotifications = ArrayPool<DeviceWatchNotification>.Shared.Rent(Math.Max(_deviceStates.Count, 10));
foreach (var state in _deviceStates.Values)
{
if (state.Driver is { } driver && driver.GetFeatureSet<TFeature>() is { IsEmpty: false } featureSet)
Expand Down

0 comments on commit a025cbd

Please sign in to comment.