On Tue, 2008-04-08 at 22:38 +0200, Henrik Nordstrom wrote:
> in commSetTimeout there is the following fragment which looks very odd
> to me
>
> if (callback != NULL) {
> typedef CommTimeoutCbParams Params;
> Params ¶ms = GetCommParams<Params>(callback);
> params.fd = fd;
> F->timeoutHandler = callback;
> }
>
> Does this do anything?
>
> If it does, is this really the proper way? That params variable is only
> junk, right?
> I guess it actually does something, with params being a reference..
Yes, it is setting the fd member of the call[back].
You will find this style throughout the comm module. Since calls have to
support old-style function pointer calls and new-style method calls, and
since they can call any object or function, you cannot get from the
generic call pointer to comm-specific parameters without some casting.
The syntax may improve a little once/if we drop support for old-style
function pointer calls (I am not sure we will), but I think it is not
too bad. Is it?
Thanks,
Alex.
P.S. The params reference is not needed, especially when you set just
one member, but I think it makes things more clear and makes similar
code look similar, regardless of the number of data members being set.