Skip to content

Commit

Permalink
fix: revise the locks in ObjOfShip.cs
Browse files Browse the repository at this point in the history
- revise ObjOfShipReaderWriterLock to ObjOfShipLock
- revise ActionLock to actionLock in Ship.cs
  • Loading branch information
asdawej committed Oct 26, 2023
1 parent 43d4009 commit 66b0b61
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions logic/GameClass/GameObj/ObjOfShip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,18 @@ namespace GameClass.GameObj
/// </summary>
public abstract class ObjOfShip : Movable, IObjOfShip
{
private ReaderWriterLockSlim objOfShipReaderWriterLock = new();
public ReaderWriterLockSlim ObjOfShipReaderWriterLock => objOfShipReaderWriterLock;
public object ObjOfShipLock { get; } = new();
private IShip? parent = null;
public IShip? Parent
{
get
{
lock (objOfShipReaderWriterLock)
lock (ObjOfShipLock)
return parent;
}
set
{
lock (objOfShipReaderWriterLock)
lock (ObjOfShipLock)
parent = value;
}
}
Expand Down
2 changes: 1 addition & 1 deletion logic/GameClass/GameObj/Ship.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public bool ResetShipStateInOneThread(long state, RunningStateType running = Run
}
public bool StartThread(long stateNum, RunningStateType runningState)
{
lock (ActionLock)
lock (actionLock)
{
if (this.StateNum == stateNum)
{
Expand Down

0 comments on commit 66b0b61

Please sign in to comment.