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

Randy Abernethy commented on THRIFT-2471:
-----------------------------------------

unique_ptr is a great implementation. In its C++98 world I think Thrift uses 
boost::share_ptr in several places where std::unique_ptr is the right answer.

I do think that sending multiple copies of repeated nodes in a DAG is a 
reasonable thing for Thrift to do, which as Dave mentions is what shared_ptr 
would give us. Another problem this fixes is the case where the user is using 
the object yet wants to serialize it by adding an additional reference to it in 
the interface structure. The ref count goes up, thrift serializes it, the ref 
count goes down. Quite a bit less expensive than copy construct/destroy. Given 
that the Thrift interface is rife with shared_ptr I would expect developers to 
understand this implementation fairly quickly. It would also mirror the 
behavior of the dynamic programming languages. 

I agree with Ben that we should at least detect cycles and throw rather than 
crashing the stack (!). In explicable errors are not a hallmark of a great 
framework, using shared_ptr to eliminate double deletes would also aid us here.



> Make cpp.ref annotation language agnostic
> -----------------------------------------
>
>                 Key: THRIFT-2471
>                 URL: https://issues.apache.org/jira/browse/THRIFT-2471
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (General)
>            Reporter: Jens Geyer
>
> The proposal is to make the new {{cpp.ref}} annotation introduced with 
> THRIFT-2421 language agnostic instead of a C++ specialty only. 
> The annotation changes inlined nested structs into pointers to structs. This 
> behaviour is potentially relevant with all languages using value semantics 
> for nested structs etc.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to