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

New forwarder demo in C++ #285

Merged
merged 5 commits into from
Feb 11, 2025

Conversation

bernardnormier
Copy link
Member

This is the C++ counterpart of #283.

target.ice_invokeAsync(
current.operation,
current.mode,
make_pair(inEncapsulationStart, inEncapsulationStart + inEncapsulationSize),
Copy link
Member

Choose a reason for hiding this comment

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

This is safe because the encapsulation for the input parameters is synchronously copied to OutgoingAsync. We don’t have a way to avoid this copy, right?

Copy link
Member Author

@bernardnormier bernardnormier Feb 11, 2025

Choose a reason for hiding this comment

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

Yes, the "marshaling" is always synchronous for Ice invocations, including ice_invokeAsync.

And indeed, the marshaling - even of bytes - always allocates a new buffer. There is no public API to transfer the ownership of the in-params InputStream to the in-params OutputStream.

For colloc, we have an internal API that does the opposite: "converts" an OutputStream into an InputStream.
https://github.com/zeroc-ice/ice/blob/4f7ba6a20a54c43c54891fc74494843107d78cd4/cpp/src/Ice/CollocatedRequestHandler.cpp#L136

https://github.com/zeroc-ice/ice/blob/4f7ba6a20a54c43c54891fc74494843107d78cd4/cpp/include/Ice/InputStream.h#L103

Note that adopt is false, most likely for retries.

We do use "adopt = true" in the same file, in the implementation of sendResponse for colloc:
https://github.com/zeroc-ice/ice/blob/4f7ba6a20a54c43c54891fc74494843107d78cd4/cpp/src/Ice/CollocatedRequestHandler.cpp#L333

slice2cpp_generate(server)
target_link_libraries(server Ice::Ice)

add_executable(forwardingserver Forwarder.cpp Forwarder.h ForwardingServer.cpp)
Copy link
Member

Choose a reason for hiding this comment

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

I would just call it forwarder

Copy link
Member Author

Choose a reason for hiding this comment

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

forwarding server is more consistent with the file names and C# names.

Copy link
Member

@InsertCreativityHere InsertCreativityHere left a comment

Choose a reason for hiding this comment

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

Looks good.
I built and tested it out on Windows, everything worked fine, and was very clear IMO.

csharp/Ice/Forwarder/ForwardingServer/Forwarder.cs Outdated Show resolved Hide resolved
Comment on lines -26 to -27
// Make the invocation asynchronously. If `ice_invokeAsync` throws an Ice.LocalException that cannot be
// marshaled (such as Ice.ConnectionRefusedException), the object adapter that calls `dispatchAsync` converts it

Choose a reason for hiding this comment

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

Why remove these?
I think using quotes to distinguish between english and code is helpful to comprehension, and wish that we did more of this. Although I would use single quotes instead of backticks for these (personally).

Co-authored-by: Austin Henriksen <austin.r.henriksen79@gmail.com>
@bernardnormier bernardnormier merged commit 9d0cb9e into zeroc-ice:main Feb 11, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants