Skip to content

Commit

Permalink
fix: 🐛 fix the misuse of ReaderWriterLockSlim
Browse files Browse the repository at this point in the history
  • Loading branch information
shangfengh committed Oct 26, 2023
1 parent d8c2397 commit b0e9d0d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions logic/GameClass/GameObj/ObjOfCharacter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,27 @@ public ICharacter? Parent
{
get
{
lock (objOfCharacterReaderWriterLock)
objOfCharacterReaderWriterLock.EnterReadLock();
try
{
return parent;
}
finally
{
objOfCharacterReaderWriterLock.ExitReadLock();
}
}
set
{
lock (objOfCharacterReaderWriterLock)
objOfCharacterReaderWriterLock.EnterWriteLock();
try
{
parent = value;
}
finally
{
objOfCharacterReaderWriterLock.ExitWriteLock();
}
}
}
// LHR注:本来考虑在构造函数里设置parent属性,见THUAI4在游戏引擎中才设置该属性,作罢。——2021/9/24
Expand Down

0 comments on commit b0e9d0d

Please sign in to comment.