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());
|
Store = new MessageStore(DatabasePath());
|
||||||
|
|
||||||
// IsBackground = true so a stuck worker never blocks plugin unload.
|
// IsBackground so a stuck worker never blocks plugin unload.
|
||||||
// The worker has its own cancellation path via PendingThreadCancellationToken,
|
// Cooperative cancel via PendingThreadCancellationToken first, background flag is the safety net.
|
||||||
// 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.
|
|
||||||
PendingMessageThread = new Thread(() => ProcessPendingMessages(PendingThreadCancellationToken.Token))
|
PendingMessageThread = new Thread(() => ProcessPendingMessages(PendingThreadCancellationToken.Token))
|
||||||
{
|
{
|
||||||
IsBackground = true,
|
IsBackground = true,
|
||||||
|
|||||||
@@ -131,20 +131,10 @@ internal class MessageStore : IDisposable
|
|||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
// Order matters: Close releases the WAL/SHM files, Dispose then
|
// Pooling=false (set in Connect) avoids ClearAllPools, which is
|
||||||
// hands the underlying connection state back to the pool. We
|
// provider-wide and would touch other plugins' SQLite connections.
|
||||||
// intentionally configure Pooling = false in Connect(), so there
|
// GC.Collect was here as a defensive flush; removed because explicit
|
||||||
// is no pool to clear globally, which keeps HellionChat's reload
|
// Close already releases everything we hold.
|
||||||
// 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.
|
|
||||||
Connection.Close();
|
Connection.Close();
|
||||||
Connection.Dispose();
|
Connection.Dispose();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user