fix(threads): mark PendingMessage thread as background, document RetentionSweep rationale
This commit is contained in:
@@ -66,7 +66,15 @@ internal class MessageManager : IAsyncDisposable
|
|||||||
|
|
||||||
Store = new MessageStore(DatabasePath());
|
Store = new MessageStore(DatabasePath());
|
||||||
|
|
||||||
PendingMessageThread = new Thread(() => ProcessPendingMessages(PendingThreadCancellationToken.Token));
|
// 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.
|
||||||
|
PendingMessageThread = new Thread(() => ProcessPendingMessages(PendingThreadCancellationToken.Token))
|
||||||
|
{
|
||||||
|
IsBackground = true,
|
||||||
|
};
|
||||||
PendingMessageThread.Start();
|
PendingMessageThread.Start();
|
||||||
|
|
||||||
ContentIdResolverHook = Plugin.GameInteropProvider.HookFromAddress<RaptureLogModule.Delegates.AddMsgSourceEntry>(RaptureLogModule.MemberFunctionPointers.AddMsgSourceEntry, ContentIdResolver);
|
ContentIdResolverHook = Plugin.GameInteropProvider.HookFromAddress<RaptureLogModule.Delegates.AddMsgSourceEntry>(RaptureLogModule.MemberFunctionPointers.AddMsgSourceEntry, ContentIdResolver);
|
||||||
|
|||||||
@@ -691,6 +691,11 @@ public sealed class Plugin : IDalamudPlugin
|
|||||||
policy[(int)(ushort)type] = days;
|
policy[(int)(ushort)type] = days;
|
||||||
var defaultDays = Config.RetentionDefaultDays;
|
var defaultDays = Config.RetentionDefaultDays;
|
||||||
|
|
||||||
|
// IsBackground = true for the same reason as PendingMessageThread:
|
||||||
|
// a stuck sweep must never block plugin unload. RunRetentionSweepIfDue
|
||||||
|
// guards the run-frequency, and the sweep itself uses the framework's
|
||||||
|
// cooperative cancellation pattern. The background flag is the safety
|
||||||
|
// net if the sweep ever takes longer than expected.
|
||||||
new Thread(() =>
|
new Thread(() =>
|
||||||
{
|
{
|
||||||
// Bail out cheaply if a manual sweep is already in flight; the
|
// Bail out cheaply if a manual sweep is already in flight; the
|
||||||
|
|||||||
Reference in New Issue
Block a user