// Copyright (C) 2024 Intro-Skipper Contributors // SPDX-License-Identifier: GNU General Public License v3.0 only. using System; using System.Threading; namespace ConfusedPolarBear.Plugin.IntroSkipper; internal sealed class ScheduledTaskSemaphore : IDisposable { private static readonly SemaphoreSlim _semaphore = new SemaphoreSlim(1, 1); private ScheduledTaskSemaphore() { } public static int CurrentCount => _semaphore.CurrentCount; public static bool Wait(int timeout, CancellationToken cancellationToken) { return _semaphore.Wait(timeout, cancellationToken); } public static int Release() { return _semaphore.Release(); } /// /// Dispose. /// public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } /// /// Protected dispose. /// /// Dispose. private void Dispose(bool disposing) { if (!disposing) { return; } _semaphore.Dispose(); } }