Skip to content

Commit

Permalink
Make flushBatchRequest no-op when proxy is not batch
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardnormier committed Feb 8, 2024
1 parent ff60c74 commit 7f4f9ec
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions cpp/include/Ice/Proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace IceInternal
{

//
// Class for handling the proxy's begin_ice_flushBatchRequest request.
// Class for handling the proxy's flushBatchRequest request.
//
class ICE_API ProxyFlushBatchAsync : public ProxyOutgoingAsyncBase
{
Expand Down Expand Up @@ -1130,10 +1130,21 @@ class ICE_API ObjectPrx : public Proxy<ObjectPrx>, public ::std::enable_shared_f
ice_flushBatchRequestsAsync(::std::function<void(::std::exception_ptr)> ex,
::std::function<void(bool)> sent = nullptr)
{
using LambdaOutgoing = ::IceInternal::ProxyFlushBatchLambda;
auto outAsync = ::std::make_shared<LambdaOutgoing>(shared_from_this(), std::move(ex), std::move(sent));
_iceI_flushBatchRequests(outAsync);
return [outAsync]() { outAsync->cancel(); };
if (_batchRequestQueue)
{
using LambdaOutgoing = ::IceInternal::ProxyFlushBatchLambda;
auto outAsync = ::std::make_shared<LambdaOutgoing>(shared_from_this(), std::move(ex), std::move(sent));
_iceI_flushBatchRequests(outAsync);
return [outAsync]() { outAsync->cancel(); };
}
else
{
if (sent)
{
sent(true);
}
return []() {}; // return a callable function target that does nothing.
}
}

/**
Expand All @@ -1143,10 +1154,19 @@ class ICE_API ObjectPrx : public Proxy<ObjectPrx>, public ::std::enable_shared_f
template<template<typename> class P = std::promise> auto
ice_flushBatchRequestsAsync() -> decltype(std::declval<P<void>>().get_future())
{
using PromiseOutgoing = ::IceInternal::ProxyFlushBatchPromise<P<void>>;
auto outAsync = ::std::make_shared<PromiseOutgoing>(shared_from_this());
_iceI_flushBatchRequests(outAsync);
return outAsync->getFuture();
if (_batchRequestQueue)
{
using PromiseOutgoing = ::IceInternal::ProxyFlushBatchPromise<P<void>>;
auto outAsync = ::std::make_shared<PromiseOutgoing>(shared_from_this());
_iceI_flushBatchRequests(outAsync);
return outAsync->getFuture();
}
else
{
P<void> p;
p.set_value();
return p.get_future();
}
}

/// \cond INTERNAL
Expand Down

0 comments on commit 7f4f9ec

Please sign in to comment.