Mercurial > hg > orthanc
diff OrthancServer/OrthancRestApi/OrthancRestModalities.cpp @ 2072:f8d4543e3fef
Asynchronous flags to avoid waiting for the completion of image transfers
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 14 Jul 2016 14:34:29 +0200 |
parents | 27fd34970c52 |
children | 21713ce8717b |
line wrap: on
line diff
--- a/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp Thu Jul 14 14:21:29 2016 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp Thu Jul 14 14:34:29 2016 +0200 @@ -685,6 +685,7 @@ std::string localAet = Toolbox::GetJsonStringField(request, "LocalAet", context.GetDefaultLocalApplicationEntityTitle()); bool permissive = Toolbox::GetJsonBooleanField(request, "Permissive", false); + bool asynchronous = Toolbox::GetJsonBooleanField(request, "Asynchronous", false); int moveOriginatorID = Toolbox::GetJsonIntegerField(request, "MoveOriginatorID", 0 /* By default, not a C-MOVE */); if (moveOriginatorID < 0 || @@ -705,9 +706,15 @@ job.SetDescription("HTTP request: Store-SCU to peer \"" + remote + "\""); - if (context.GetScheduler().SubmitAndWait(job)) + if (asynchronous) { - // Success + // Asynchronous mode: Submit the job, but don't wait for its completion + context.GetScheduler().Submit(job); + call.GetOutput().AnswerBuffer("{}", "application/json"); + } + else if (context.GetScheduler().SubmitAndWait(job)) + { + // Synchronous mode: We have submitted and waited for completion call.GetOutput().AnswerBuffer("{}", "application/json"); } else @@ -812,6 +819,8 @@ return; } + bool asynchronous = Toolbox::GetJsonBooleanField(request, "Asynchronous", false); + WebServiceParameters peer; Configuration::GetOrthancPeer(peer, remote); @@ -824,9 +833,15 @@ job.SetDescription("HTTP request: POST to peer \"" + remote + "\""); - if (context.GetScheduler().SubmitAndWait(job)) + if (asynchronous) { - // Success + // Asynchronous mode: Submit the job, but don't wait for its completion + context.GetScheduler().Submit(job); + call.GetOutput().AnswerBuffer("{}", "application/json"); + } + else if (context.GetScheduler().SubmitAndWait(job)) + { + // Synchronous mode: We have submitted and waited for completion call.GetOutput().AnswerBuffer("{}", "application/json"); } else