From b6226b68c942fd93c41d5acd3fcb201f15be0e34 Mon Sep 17 00:00:00 2001 From: Mikhail Mitrofanov Date: Sat, 22 Feb 2025 10:06:41 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=BE=D0=B7=D0=B2=D1=80=D0=B0=D1=89?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BF=D0=BE=D0=BB=D0=BD=D0=BE=D0=B9?= =?UTF-8?q?=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BE=D1=81=D0=BF=D0=BE=D1=81?= =?UTF-8?q?=D0=BE=D0=B1=D0=BD=D0=BE=D1=81=D1=82=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Example.Frontend/Program.cs | 1 + mROA/Abstract/IRequestExtractor.cs | 2 +- .../Backend/BasicExecutionModule.cs | 21 ++++++++++++++----- .../Frontend/RequestExtractor.cs | 1 + 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Example.Frontend/Program.cs b/Example.Frontend/Program.cs index 842c0dd..f5323d2 100644 --- a/Example.Frontend/Program.cs +++ b/Example.Frontend/Program.cs @@ -69,6 +69,7 @@ class Program Console.WriteLine(string.Join(", ", names)); var page = printer.Value.Print("Test Page", new CancellationToken()).GetAwaiter().GetResult(); + Console.WriteLine("Page printed"); var data = page.Value.GetData(); Console.WriteLine("Data : {0}", Encoding.UTF8.GetString(data)); diff --git a/mROA/Abstract/IRequestExtractor.cs b/mROA/Abstract/IRequestExtractor.cs index d49194b..30711fc 100644 --- a/mROA/Abstract/IRequestExtractor.cs +++ b/mROA/Abstract/IRequestExtractor.cs @@ -4,6 +4,6 @@ namespace mROA.Abstract { public interface IRequestExtractor : IInjectableModule { - Task StartExtraction(); + Task StartExtraction(); } } \ No newline at end of file diff --git a/mROA/Implementation/Backend/BasicExecutionModule.cs b/mROA/Implementation/Backend/BasicExecutionModule.cs index ec57413..3207c34 100644 --- a/mROA/Implementation/Backend/BasicExecutionModule.cs +++ b/mROA/Implementation/Backend/BasicExecutionModule.cs @@ -41,10 +41,12 @@ namespace mROA.Implementation.Backend if (currentCommand.ReturnType.BaseType == typeof(Task) && currentCommand.ReturnType.GenericTypeArguments.Length == 1) - return TypedExecuteAsync(currentCommand, context, parameter, command, _cancellationRepo, representationModule); + return TypedExecuteAsync(currentCommand, context, parameter, command, _cancellationRepo, + representationModule); if (currentCommand.ReturnType == typeof(Task)) - return ExecuteAsync(currentCommand, context, parameter, command, _cancellationRepo, representationModule); + return ExecuteAsync(currentCommand, context, parameter, command, _cancellationRepo, + representationModule); return Execute(currentCommand, context, parameter, command); } @@ -76,7 +78,8 @@ namespace mROA.Implementation.Backend } private static ICommandExecution ExecuteAsync(MethodInfo currentCommand, object context, object? parameter, - ICallRequest command, ICancellationRepository cancellationRepository, IRepresentationModule representationModule) + ICallRequest command, ICancellationRepository cancellationRepository, + IRepresentationModule representationModule) { var tokenSource = new CancellationTokenSource(); cancellationRepository.RegisterCancellation(command.Id, tokenSource); @@ -96,14 +99,17 @@ namespace mROA.Implementation.Backend Id = command.Id, CommandId = command.CommandId }; + var multiClientOwnershipRepository = + TransmissionConfig.OwnershipRepository as MultiClientOwnershipRepository; + multiClientOwnershipRepository?.RegisterOwnership(representationModule.Id); representationModule.PostCallMessage(command.Id, MessageType.FinishedCommandExecution, payload); + multiClientOwnershipRepository?.FreeOwnership(); }, token); return new AsyncCommandExecution { Id = command.Id, CommandId = command.CommandId }; - } catch (Exception e) { @@ -116,7 +122,8 @@ namespace mROA.Implementation.Backend } private static ICommandExecution TypedExecuteAsync(MethodInfo currentCommand, object context, object? parameter, - ICallRequest command, ICancellationRepository cancellationRepository, IRepresentationModule representationModule) + ICallRequest command, ICancellationRepository cancellationRepository, + IRepresentationModule representationModule) { var tokenSource = new CancellationTokenSource(); cancellationRepository.RegisterCancellation(command.Id, tokenSource); @@ -140,7 +147,11 @@ namespace mROA.Implementation.Backend CommandId = command.CommandId, Type = finalResult?.GetType() }; + var multiClientOwnershipRepository = + TransmissionConfig.OwnershipRepository as MultiClientOwnershipRepository; + multiClientOwnershipRepository?.RegisterOwnership(representationModule.Id); representationModule.PostCallMessage(command.Id, MessageType.FinishedCommandExecution, payload); + multiClientOwnershipRepository?.FreeOwnership(); }, token); return new AsyncCommandExecution diff --git a/mROA/Implementation/Frontend/RequestExtractor.cs b/mROA/Implementation/Frontend/RequestExtractor.cs index 6d58ce6..fe89331 100644 --- a/mROA/Implementation/Frontend/RequestExtractor.cs +++ b/mROA/Implementation/Frontend/RequestExtractor.cs @@ -99,5 +99,6 @@ namespace mROA.Implementation.Frontend multiClientOwnershipRepository?.FreeOwnership(); } } + } } \ No newline at end of file