You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by "Andrew Stitcher (JIRA)" <ji...@apache.org> on 2016/07/28 17:34:20 UTC

[jira] [Commented] (PROTON-1241) proton::messaging_handler is not copyable (because it contains a pn_unique_ptr)

    [ https://issues.apache.org/jira/browse/PROTON-1241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15397869#comment-15397869 ] 

Andrew Stitcher commented on PROTON-1241:
-----------------------------------------

Oops, I appear to have been ambiguous in my description of this problem and placed the symptoms ahead of the cause.

The API visible problem here is indeed that the API user can't copy their own class, however that can't sensibly be solved by just giving {{proton::messaging_handler}} copy and move operations, as the actual problem is that it contains a {{proton::pn_unique_ptr}}.

This prevents it from being a pure interface (abstract class). {{proton::messaging_handler}} is intended to be an interface that is implemented by the user (with some default behaviours) and if it was then there would be no bar to copying or moving.

So the solution to this issue is to change the library implementation so that {{proton::messaging_handler}} becomes  an interface and loses its pointer to a {{proton::messaging_adapter}}

> proton::messaging_handler is not copyable (because it contains a pn_unique_ptr)
> -------------------------------------------------------------------------------
>
>                 Key: PROTON-1241
>                 URL: https://issues.apache.org/jira/browse/PROTON-1241
>             Project: Qpid Proton
>          Issue Type: Bug
>          Components: cpp-binding
>            Reporter: Andrew Stitcher
>            Assignee: Cliff Jansen
>             Fix For: 0.14.0
>
>
> One fundamental of the Proton C++ API is that the user supplies their own handler class.
> We should strive in our implementation to limit the API user as little as possible. Unfortunately , because of some historical implementation decisions the messaging_handler class contains a single member which is not copyable (this is a unique_ptr to the associated internal messaging_adapter).
> This stops the user being able to natural things with her own classes like:
> {noformat}
> class MyHandler: public messaging_handler {
> ...
> }
> ...
> auto h = MyHandler{};
> ...
> Myhandler g;
> auto i = g;
> {noformat}
> The user knows what she wants to do with her classes and there is no real intrinsic requirement for the messaging_handler to keep hold of a messaging_adapter. So we need to get out of the users way and remove the pn_unique_ptr from messaging_handler.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org