From c9dfd024b2dd53fe30b43290d4237209cd09afd0 Mon Sep 17 00:00:00 2001 From: JonKazama-Hellion Date: Thu, 7 May 2026 01:10:50 +0200 Subject: [PATCH] docs(comments): trim verbose dispose and thread rationale Match the new HellionChat comment-length convention: 1-3 lines for standard pitfall notes, 5+ only for non-trivial workarounds. The previous Dispose comment was 14 lines of textbook prose, which veered into AI-slop territory and would rot on the next refactor. --- HellionChat/MessageManager.cs | 7 ++----- HellionChat/MessageStore.cs | 18 ++++-------------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/HellionChat/MessageManager.cs b/HellionChat/MessageManager.cs index 983591f..40dfb6e 100644 --- a/HellionChat/MessageManager.cs +++ b/HellionChat/MessageManager.cs @@ -66,11 +66,8 @@ internal class MessageManager : IAsyncDisposable Store = new MessageStore(DatabasePath()); - // IsBackground = true so a stuck worker never blocks plugin unload. - // The worker has its own cancellation path via PendingThreadCancellationToken, - // and DisposeAsync waits up to 10s for cooperative shutdown. The - // background flag is the safety net for the case where cooperative - // shutdown fails to drain the queue in time. + // IsBackground so a stuck worker never blocks plugin unload. + // Cooperative cancel via PendingThreadCancellationToken first, background flag is the safety net. PendingMessageThread = new Thread(() => ProcessPendingMessages(PendingThreadCancellationToken.Token)) { IsBackground = true, diff --git a/HellionChat/MessageStore.cs b/HellionChat/MessageStore.cs index 85c43e8..7ae1fc1 100644 --- a/HellionChat/MessageStore.cs +++ b/HellionChat/MessageStore.cs @@ -131,20 +131,10 @@ internal class MessageStore : IDisposable public void Dispose() { - // Order matters: Close releases the WAL/SHM files, Dispose then - // hands the underlying connection state back to the pool. We - // intentionally configure Pooling = false in Connect(), so there - // is no pool to clear globally, which keeps HellionChat's reload - // from disturbing other plugins' SQLite connections (which is - // what SqliteConnection.ClearAllPools() would do, since it acts - // provider-wide). - // - // We used to call GC.Collect() + GC.WaitForPendingFinalizers() - // here as a defensive flush, but with Pooling = false there is - // nothing left to collect that the explicit Close hasn't already - // released. The GC calls were heap pressure on every plugin - // reload and reached into other plugins' object graphs because - // GC.Collect is process-wide. + // Pooling=false (set in Connect) avoids ClearAllPools, which is + // provider-wide and would touch other plugins' SQLite connections. + // GC.Collect was here as a defensive flush; removed because explicit + // Close already releases everything we hold. Connection.Close(); Connection.Dispose(); }