feat(data): persistent job engine with checkpoints, pause/resume and crash recovery
JobEngine claims queued jobs atomically, persists progress at most every checkpoint interval, stops a handler when its job is cancelled or paused elsewhere and requeues jobs a crash left running. Also installs the SQLite import resolver under a lock so a concurrent first caller cannot reach a P/Invoke before the resolver is in place. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
4 files changed
+521
-2
No files matched your search
@@ -11,7 +11,9 @@ namespace Titano.Data.Sqlite;
|
||||
internal static unsafe class SqliteNative
|
||||
{
|
||||
private const string Library = "titano-sqlite3";
|
||||
private static int _resolverInstalled;
|
||||
// Set only after the resolver is in place: a concurrent first caller must not reach a P/Invoke before that.
|
||||
private static readonly Lock ResolverGate = new();
|
||||
private static bool _resolverInstalled;
|
||||
|
||||
public const int SQLITE_OK = 0;
|
||||
public const int SQLITE_INTERRUPT = 9;
|
||||
@@ -43,8 +45,13 @@ internal static unsafe class SqliteNative
|
||||
/// <summary>Routes the logical library name to the platform's system SQLite (once per process).</summary>
|
||||
public static void EnsureResolver()
|
||||
{
|
||||
if (Interlocked.Exchange(ref _resolverInstalled, 1) == 0)
|
||||
if (Volatile.Read(ref _resolverInstalled)) return;
|
||||
lock (ResolverGate)
|
||||
{
|
||||
if (_resolverInstalled) return;
|
||||
NativeLibrary.SetDllImportResolver(typeof(SqliteNative).Assembly, Resolve);
|
||||
Volatile.Write(ref _resolverInstalled, true);
|
||||
}
|
||||
}
|
||||
|
||||
private static nint Resolve(string name, Assembly assembly, DllImportSearchPath? searchPath)
|
||||
|
||||
Reference in new issue
Block a user