Modules/businessdev.ALbuild.Core/Public/Unlock-ALbuildCacheEntry.ps1

function Unlock-ALbuildCacheEntry {
    <#
    .SYNOPSIS
        Releases the cache locks taken by Lock-ALbuildCacheEntry.
 
    .DESCRIPTION
        Release is best-effort per mutex: a mutex this thread no longer owns must not stop the rest from
        being released, or a single stale handle would leave the whole cache entry locked for the
        lifetime of the process.
 
    .PARAMETER Locks
        The object returned by Lock-ALbuildCacheEntry.
 
    .EXAMPLE
        Unlock-ALbuildCacheEntry -Locks $locks
    #>

    [CmdletBinding()]
    [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingEmptyCatchBlock', '', Justification = 'Releasing a mutex this thread no longer owns must not prevent the remaining ones from being released.')]
    param(
        [Parameter(Mandatory)] [object] $Locks
    )

    foreach ($m in @($Locks.Mutexes)) {
        try { $m.ReleaseMutex() } catch { }
        $m.Dispose()
    }
}