thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Zhiqiu Kong <breaddaw...@gmail.com>
Subject Why do we need both args & prags when generating cpp codes?
Date Mon, 13 Jun 2011 23:42:05 GMT
Hi,

I am a beginner on Thrift and am learning it from the tutorial. I generated
cpp codes and tried to find out how the codes are generated. But I am
confused about the co-existence of args & pargs classes. For example, Thrift
generated both Calculator_add_pargs and Calculator_add_args for the function
add().

As far as I found out, _pargs version is used by the client and is much
simpler than _args version. For example, the former lacks __is_set struct,
has only write() function. It makes sense because the client does not need
to process request thus it is unnecessary for it to read arguments. Also,
_pargs version has pointers to the arguments as its members, which is
different from _args version. I guess this is what "p" stands for
(pointers)?

I also checked the source code, which is t_cpp_generator.cc, and found
_pargs is used when generating a service client definition and _args is used
for process function. So generally the client will use _pargs, while the
server will use _args, if I understand correctly.

But my question is, why do we need the _pargs version? It seems that it is
the subset of _args, except for its pointer type members. I understand it
does not hurt to have two versions and it should work well. But I cannot
help to figure out the reason why we need to do this. It will be a great
help if you woud like to give me some insights or guidance on this.

Thanks,

Zhiqiu Kong

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message