Exemplo n.º 1
0
 protected OpenCountFileSystem(ref ReferenceCountedDisposable <IFileSystem> baseFileSystem,
                               ref ReferenceCountedDisposable <IEntryOpenCountSemaphoreManager> entryCountSemaphore,
                               ref IUniqueLock mountCountSemaphore) : base(ref baseFileSystem)
 {
     Shared.Move(out _entryCountSemaphore, ref entryCountSemaphore);
     Shared.Move(out _mountCountSemaphore, ref mountCountSemaphore);
 }
Exemplo n.º 2
0
        public static ReferenceCountedDisposable <IFileSystem> CreateShared(
            ref ReferenceCountedDisposable <IFileSystem> baseFileSystem,
            ref ReferenceCountedDisposable <IEntryOpenCountSemaphoreManager> entryCountSemaphore,
            ref IUniqueLock mountCountSemaphore)
        {
            var filesystem =
                new OpenCountFileSystem(ref baseFileSystem, ref entryCountSemaphore, ref mountCountSemaphore);

            return(new ReferenceCountedDisposable <IFileSystem>(filesystem));
        }
Exemplo n.º 3
0
        public static Result MakeUniqueLockWithPin <T>(out IUniqueLock uniqueLock, SemaphoreAdaptor semaphore,
                                                       ref ReferenceCountedDisposable <T> objectToPin) where T : class, IDisposable
        {
            UnsafeHelpers.SkipParamInit(out uniqueLock);

            UniqueLockSemaphore tempUniqueLock = default;

            try
            {
                Result rc = TryAcquireCountSemaphore(out tempUniqueLock, semaphore);
                if (rc.IsFailure())
                {
                    return(rc);
                }

                uniqueLock = new UniqueLockWithPin <T>(ref tempUniqueLock, ref objectToPin);
                return(Result.Success);
            }
            finally
            {
                tempUniqueLock.Dispose();
            }
        }