Skip to content

Commit

Permalink
Remove semaphore from RobotService
Browse files Browse the repository at this point in the history
  • Loading branch information
MuhammadUsama-afk-equinor authored and UsamaEquinorAFK committed Jan 9, 2024
1 parent 1dcb56c commit 50e1df0
Showing 1 changed file with 0 additions and 5 deletions.
5 changes: 0 additions & 5 deletions backend/api/Services/RobotService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,9 @@ public class RobotService(
IAreaService areaService,
IMissionRunService missionRunService) : IRobotService, IDisposable
{
private readonly Semaphore _robotSemaphore = new(1, 1);

public void Dispose()
{
_robotSemaphore.Dispose();
GC.SuppressFinalize(this);
}

Expand Down Expand Up @@ -324,13 +322,11 @@ public async Task SetRobotOffline(string robotId)

private async Task<Robot> UpdateRobotProperty(string robotId, string propertyName, object? value)
{
_robotSemaphore.WaitOne();
var robot = await ReadById(robotId);
if (robot is null)
{
string errorMessage = $"Robot with ID {robotId} was not found in the database";
logger.LogError("{Message}", errorMessage);
_robotSemaphore.Release();
throw new RobotNotFoundException(errorMessage);
}

Expand All @@ -344,7 +340,6 @@ private async Task<Robot> UpdateRobotProperty(string robotId, string propertyNam
}

robot = await Update(robot);
_robotSemaphore.Release();
return robot;
}

Expand Down

0 comments on commit 50e1df0

Please sign in to comment.