Files
ThreadPilot/Services/ProcessPolicyApplyGate.cs
Prime Build 2665d2be9f feat: release experimental Game Boost preview 1.7.8-beta.1
Restore the complete local Game Boost/runtime topology work from 6c36ea6, including Activity diagnostics, while preserving the stable 1.7.7 release and channel guards. Preview notes document pending dual-CCD Ryzen/X3D, Intel hybrid, benchmarks and anti-cheat validation, with tester instructions.
2026-10-16 12:09:56 +02:00

35 lines
1.1 KiB
C#

namespace ThreadPilot.Services
{
using System;
using System.Threading;
using System.Threading.Tasks;
/// <summary>
/// One gate for everything that applies policies to running processes on its own (persistent rules,
/// Game Boost), so the two never write CPU Sets or priorities to the same process at the same time.
/// </summary>
public sealed class ProcessPolicyApplyGate
{
private readonly SemaphoreSlim semaphore = new(1, 1);
public async Task<IDisposable> EnterAsync(CancellationToken cancellationToken = default)
{
await this.semaphore.WaitAsync(cancellationToken).ConfigureAwait(false);
return new Releaser(this.semaphore);
}
private sealed class Releaser(SemaphoreSlim semaphore) : IDisposable
{
private int released;
public void Dispose()
{
if (Interlocked.Exchange(ref this.released, 1) == 0)
{
semaphore.Release();
}
}
}
}
}