mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Use SharedRef in the bcat IPC interfaces
This commit is contained in:
parent
f07e515048
commit
e14a20b4fa
5 changed files with 16 additions and 13 deletions
|
@ -1,11 +1,12 @@
|
|||
using System;
|
||||
using LibHac.Common;
|
||||
|
||||
namespace LibHac.Bcat.Impl.Ipc
|
||||
{
|
||||
public interface IDeliveryCacheStorageService : IDisposable
|
||||
{
|
||||
Result CreateFileService(out IDeliveryCacheFileService fileService);
|
||||
Result CreateDirectoryService(out IDeliveryCacheDirectoryService directoryService);
|
||||
Result CreateFileService(ref SharedRef<IDeliveryCacheFileService> outFileService);
|
||||
Result CreateDirectoryService(ref SharedRef<IDeliveryCacheDirectoryService> outDirectoryService);
|
||||
Result EnumerateDeliveryCacheDirectory(out int namesRead, Span<DirectoryName> nameBuffer);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,32 +25,28 @@ namespace LibHac.Bcat.Impl.Service
|
|||
Access = accessControl;
|
||||
}
|
||||
|
||||
public Result CreateFileService(out IDeliveryCacheFileService service)
|
||||
public Result CreateFileService(ref SharedRef<IDeliveryCacheFileService> service)
|
||||
{
|
||||
lock (Locker)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out service);
|
||||
|
||||
if (FileServiceOpenCount >= MaxOpenCount)
|
||||
return ResultBcat.ServiceOpenLimitReached.Log();
|
||||
|
||||
service = new DeliveryCacheFileService(Server, this, ApplicationId, Access);
|
||||
service.Reset(new DeliveryCacheFileService(Server, this, ApplicationId, Access));
|
||||
|
||||
FileServiceOpenCount++;
|
||||
return Result.Success;
|
||||
}
|
||||
}
|
||||
|
||||
public Result CreateDirectoryService(out IDeliveryCacheDirectoryService service)
|
||||
public Result CreateDirectoryService(ref SharedRef<IDeliveryCacheDirectoryService> service)
|
||||
{
|
||||
lock (Locker)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out service);
|
||||
|
||||
if (DirectoryServiceOpenCount >= MaxOpenCount)
|
||||
return ResultBcat.ServiceOpenLimitReached.Log();
|
||||
|
||||
service = new DeliveryCacheDirectoryService(Server, this, ApplicationId, Access);
|
||||
service.Reset(new DeliveryCacheDirectoryService(Server, this, ApplicationId, Access));
|
||||
|
||||
DirectoryServiceOpenCount++;
|
||||
return Result.Success;
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
namespace LibHac.Common
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Struct)]
|
||||
public sealed class NonCopyableAttribute : System.Attribute { }
|
||||
public sealed class NonCopyableAttribute : Attribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Struct)]
|
||||
public sealed class NonCopyableDisposableAttribute : System.Attribute { }
|
||||
public sealed class NonCopyableDisposableAttribute : Attribute { }
|
||||
}
|
||||
|
|
|
@ -204,6 +204,8 @@ namespace LibHac.FsSrv
|
|||
serviceObject.SetByMove(ref derivedObject.Ref());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
public void Dispose() { }
|
||||
}
|
||||
|
||||
private class FileSystemProxyForLoaderService : IServiceObject
|
||||
|
@ -221,6 +223,8 @@ namespace LibHac.FsSrv
|
|||
serviceObject.SetByMove(ref derivedObject.Ref());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
public void Dispose() { }
|
||||
}
|
||||
|
||||
private class ProgramRegistryService : IServiceObject
|
||||
|
@ -238,6 +242,8 @@ namespace LibHac.FsSrv
|
|||
serviceObject.SetByMove(ref derivedObject.Ref());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
public void Dispose() { }
|
||||
}
|
||||
|
||||
private class DummyStackUsageReporter : IStackUsageReporter
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace LibHac.Sm
|
|||
{
|
||||
// This interface is being used as a stop-gap solution so we can
|
||||
// have at least some sort of service system for now
|
||||
public interface IServiceObject
|
||||
public interface IServiceObject : IDisposable
|
||||
{
|
||||
Result GetServiceObject(ref SharedRef<IDisposable> serviceObject);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue