Changed various locking mechanism.

This commit is contained in:
Tom
2025-03-29 20:18:09 +00:00
parent c80f1f2aa0
commit c7904f120d
10 changed files with 282 additions and 143 deletions

View File

@@ -30,7 +30,8 @@ namespace HermesSocketServer.Store
await _database.Execute(sql, data, (reader) =>
{
var chatterId = reader.GetInt32(0).ToString();
lock (_lock)
_rwls.EnterWriteLock();
try
{
_store.Add(chatterId, new GroupChatter()
{
@@ -40,6 +41,10 @@ namespace HermesSocketServer.Store
ChatterLabel = reader.GetString(1),
});
}
finally
{
_rwls.ExitWriteLock();
}
});
_logger.Information($"Loaded {_store.Count} group chatters from database [group id: {_groupId}]");
}