PvWay.SemaphoreService.Abstractions.nc8 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package PvWay.SemaphoreService.Abstractions.nc8 --version 1.0.0
NuGet\Install-Package PvWay.SemaphoreService.Abstractions.nc8 -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PvWay.SemaphoreService.Abstractions.nc8" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PvWay.SemaphoreService.Abstractions.nc8 --version 1.0.0
#r "nuget: PvWay.SemaphoreService.Abstractions.nc8, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install PvWay.SemaphoreService.Abstractions.nc8 as a Cake Addin
#addin nuget:?package=PvWay.SemaphoreService.Abstractions.nc8&version=1.0.0

// Install PvWay.SemaphoreService.Abstractions.nc8 as a Cake Tool
#tool nuget:?package=PvWay.SemaphoreService.Abstractions.nc8&version=1.0.0

SemaphoreService abstractions for .Net Core 8 by pvWay

This nuGet brings the abstraction interfaces for the SemaphoreService

Interfaces and enums

SemaphoreStatus enum

This enum enumerates the different possible statuses of a semaphore when trying to acquire it

  • Acquired: (success status) the semaphore was acquired
  • ReleasedInTheMeanTime: the semaphore was locked by someone else but when getting more info it finally appeared released.
  • OwnedBySomeoneElse: another process currently owns the semaphore. Other processes will have to wait until the semaphore will be released by the owner process.
  • ForcedReleased: the semaphore was locked by another process that seems not being responding for a while. As such, the release of the semaphore was forced.
namespace PvWay.SemaphoreService.Abstractions.nc8;

public enum SemaphoreStatusEnu
{
    Acquired,
    ReleasedInTheMeanTime,
    OwnedSomeoneElse,
    ForcedReleased
}

IDbSemaphore

Small object that holds the name of the semaphore owner as well as the UTC date and time the owner process was touching(refreshing) the lock.

namespace PvWay.SemaphoreService.Abstractions.nc8;

public interface ISemaphoreInfo
{
    string Owner { get; }
    DateTime LastTouchUtcDate { get; }
}

ISemaphoreService

namespace PvWay.SemaphoreService.Abstractions.nc8;

public interface ISemaphoreService
{
    /// <summary>
    /// This method will actually try to acquire the semaphore
    /// </summary>
    /// <param name="name">The semaphore name</param>
    /// <param name="owner">
    /// The name of the process that tries to acquire the semaphore
    /// </param>
    /// <param name="timeout">
    /// The estimated time out timespan that the lock will stay active (if not refreshed).
    /// If the semaphore is locked longer than the timeout period it will be forced release
    /// by any other process trying to acquire the semaphore</param>
    /// <returns>On success the status will be Acquired.</returns>
    Task<SemaphoreStatusEnu> AcquireSemaphoreAsync(
        string name, string owner, TimeSpan timeout);
    
    /// <summary>
    /// Extend the validity timespan of the semaphore
    /// </summary>
    /// <param name="name"></param>
    /// <returns></returns>
    Task TouchSemaphoreAsync(string name);
    
    /// <summary>
    /// Free the semaphore so that any other process can now acquire it
    /// </summary>
    /// <param name="name"></param>
    /// <returns></returns>
    Task ReleaseSemaphoreAsync(string name);
    
    /// <summary>
    /// Get some info about a given semaphore
    /// </summary>
    /// <param name="name"></param>
    /// <returns></returns>
    Task<ISemaphoreInfo?> GetSemaphoreAsync(string name);
}

Happy coding

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on PvWay.SemaphoreService.Abstractions.nc8:

Package Downloads
PvWay.MsSqlSemaphoreService.nc8

This nuGet implements the SemaphoreService interfaces using a tiny DAO connection towards an Ms Sql Server Database.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.2 185 12/18/2023
1.0.1 99 12/18/2023
1.0.0 96 12/17/2023

initial