Skip to content

Commit

Permalink
Make _batchRequestQueue const
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardnormier committed Feb 8, 2024
1 parent d939b57 commit ff60c74
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
10 changes: 4 additions & 6 deletions cpp/include/Ice/Proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -522,9 +522,7 @@ class ICE_API ObjectPrx : public Proxy<ObjectPrx>, public ::std::enable_shared_f
virtual ~ObjectPrx() = default;

/// \cond INTERNAL
ObjectPrx(const IceInternal::ReferencePtr& ref) noexcept : _reference(ref)
{
}
ObjectPrx(const IceInternal::ReferencePtr& ref) noexcept;
/// \endcond

/**
Expand Down Expand Up @@ -1162,7 +1160,7 @@ class ICE_API ObjectPrx : public Proxy<ObjectPrx>, public ::std::enable_shared_f
void _checkTwowayOnly(const ::std::string&) const;

::IceInternal::RequestHandlerPtr _getRequestHandler();
::IceInternal::BatchRequestQueuePtr _getBatchRequestQueue();
::IceInternal::BatchRequestQueuePtr _getBatchRequestQueue() const { return _batchRequestQueue; }
::IceInternal::RequestHandlerPtr _setRequestHandler(const ::IceInternal::RequestHandlerPtr&);
void _updateRequestHandler(const ::IceInternal::RequestHandlerPtr&, const ::IceInternal::RequestHandlerPtr&);

Expand Down Expand Up @@ -1225,9 +1223,9 @@ class ICE_API ObjectPrx : public Proxy<ObjectPrx>, public ::std::enable_shared_f
IceInternal::ReferencePtr _timeout(int) const;
IceInternal::ReferencePtr _twoway() const;

const ::IceInternal::ReferencePtr _reference;
const IceInternal::ReferencePtr _reference;
::IceInternal::RequestHandlerPtr _requestHandler;
::IceInternal::BatchRequestQueuePtr _batchRequestQueue;
const IceInternal::BatchRequestQueuePtr _batchRequestQueue;
mutable std::mutex _mutex;
};

Expand Down
21 changes: 7 additions & 14 deletions cpp/src/Ice/Proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,13 @@ operator==(const ObjectPrx& lhs, const ObjectPrx& rhs)

}

Ice::ObjectPrx::ObjectPrx(const ObjectPrx& other) noexcept :
enable_shared_from_this<ObjectPrx>(), // the copy is independent of other
_reference(other._reference)
Ice::ObjectPrx::ObjectPrx(const ReferencePtr& ref) noexcept :
_reference(ref),
_batchRequestQueue(ref->isBatch() ? _reference->getBatchRequestQueue() : nullptr)
{
}

Ice::ObjectPrx::ObjectPrx(const ObjectPrx& other) noexcept : ObjectPrx(other._reference)
{
lock_guard lock(other._mutex);
_requestHandler = other._requestHandler;
Expand Down Expand Up @@ -501,17 +505,6 @@ Ice::ObjectPrx::_getRequestHandler()
return _reference->getRequestHandler(shared_from_this());
}

IceInternal::BatchRequestQueuePtr
Ice::ObjectPrx::_getBatchRequestQueue()
{
lock_guard lock(_mutex);
if(!_batchRequestQueue)
{
_batchRequestQueue = _reference->getBatchRequestQueue();
}
return _batchRequestQueue;
}

::IceInternal::RequestHandlerPtr
Ice::ObjectPrx::_setRequestHandler(const ::IceInternal::RequestHandlerPtr& handler)
{
Expand Down
1 change: 1 addition & 0 deletions cpp/src/Ice/Reference.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class Reference : public std::enable_shared_from_this<Reference>
};

Mode getMode() const { return _mode; }
bool isBatch() const { return _mode == ModeBatchOneway || _mode == ModeBatchDatagram; }
bool getSecure() const { return _secure; }
const Ice::ProtocolVersion& getProtocol() const { return _protocol; }
const Ice::EncodingVersion& getEncoding() const { return _encoding; }
Expand Down

0 comments on commit ff60c74

Please sign in to comment.