Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make _batchRequestQueue const #1769

Merged
merged 2 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a change in behavior? In the previous implementation of _getBatchRequestQueue we always grabbed the request queue from reference.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a slight change of behavior:

  • for regular proxies: no change in behavior
  • for fixed proxies:
    • before: calling flushBatchRequest on any fixed proxy flushes the batch request queue of the underlying connection
    • after: calling flushBatchRequest on a fixed proxy that is not batch does not flush the batch request queue of the underlying connection

If desired, I can restore the old behavior.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with either behavior.

{
}

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
Loading