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.
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user