-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use TEXT instead of VARCHAR * Force ascending aliased rowid values * Dispose rented connection and command early * Serialize to bytes early * Notify subscribers AFTER reading * Update test * Rework SqliteIPC * Update * Use Queue instead of Stack * Cleanup ReaderLoop * Seal SqliteIPC * Add WriterLoop * Publish jobs early when in-process * ReaderLoop is for other processes * Cleanup * Cleanup * Update messages * Add EnsureWrite
- Loading branch information
Showing
6 changed files
with
586 additions
and
285 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/NexusMods.DataModel/Interprocess/SemaphoreSlimWaiter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
namespace NexusMods.DataModel.Interprocess; | ||
|
||
internal readonly struct SemaphoreSlimWaiter : IDisposable | ||
{ | ||
private readonly SemaphoreSlim _semaphoreSlim; | ||
|
||
public bool HasEntered { get; } | ||
|
||
internal SemaphoreSlimWaiter(SemaphoreSlim semaphoreSlim, bool entered) | ||
{ | ||
_semaphoreSlim = semaphoreSlim; | ||
HasEntered = entered; | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
if (!HasEntered) return; | ||
_semaphoreSlim.Release(); | ||
} | ||
} | ||
|
||
internal static class SemaphoreExtensions | ||
{ | ||
public static SemaphoreSlimWaiter CustomWait( | ||
this SemaphoreSlim semaphoreSlim, | ||
TimeSpan timeout, | ||
CancellationToken cancellationToken = default) | ||
{ | ||
var entered = semaphoreSlim.Wait(timeout, cancellationToken); | ||
return new SemaphoreSlimWaiter(semaphoreSlim, entered); | ||
} | ||
} |
Oops, something went wrong.