-
Notifications
You must be signed in to change notification settings - Fork 34
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
Offer better Send/Receive API #85
Comments
Was discussing this with Matthias a bit more. Actually, I think we should not expose pointer types to the user at all, but just take and give plain move-only @rbx What do you think? |
What I have in mind now, especially after considering possibility of having our own header and some other discussions we had, is to offer a new
Internally it can be just built out of FairMQParts (which are also move only and non pointer), where one or more parts are reserved for our headers or anything really, since we will not expose internal parts to user. Regarding what factory returns i am not certain, it indeed can return those move-only types, but then it has to give up ownership. |
This article has a lot of answers on how to implement our interfaces with value semantics: https://akrzemi1.wordpress.com/2012/02/03/value-semantics/
Indeed, I was not telling all the details. After thinking about it, the sockets should have shared ownership on the transport, device also has shared ownership on transport. When we need to communicate something to the sockets, we also need to track (non-owning) pointers to the sockets in the transport. Once a socket is destructed, it will deregister itself from the transport. I believe this would be the cleanest implementation. But there is no rush, let's take the time and think it through another couple of times.
This would be a great migration strategy. If I may rephrase Use the overdue namespacing of some of our classes to introduce a new API in parallel and then deprecate the old API at some point. |
Is your feature request related to a problem? Please describe.
The current Send API takes message pointers by reference. The users should not touch the messages after calling Send on it, because it can be sent out at any moment and will be deleted automatically. However if a timeout or some error condition happen, Send will return an status value and the user can touch the message, change it, or resend it. This is not clear with the current API.
Describe the solution you'd like
Instead we should take messages as
unique_ptr
that user has tostd::move
to us, giving up the ownership to the transport. To further support giving back the ownership in case of error or a timeout to the user, we should introduce a custom return value that contains a status flag and optional unique_ptr that will contain the message in case of timeout/error. This return value can override the comparison operators for checking of the status flag, which will make it more compatible with the old interface and ease the transition.Same convention can be used for Receive, where the returned type will contain the received message.
The text was updated successfully, but these errors were encountered: