[Date Prev][Date Next][Thread Prev][Thread Next][Author Index][Date Index][Thread Index]

rewriting proxies' sending half



Here's how I'd like to re-design the code that proxies use to send
messages across the wire.  For good reasons they have a message
interface that directly mirrors that of the object they mimic.  That
won't change.  Each of those methods is currently implemented as a
series of messages to a CommXcvr which follow the protocol that the
CommXcvr uses over the wire.  It would clean up the public interface
of the CommXcvrs, while reducing the code in the proxies, if proxies
would send a single message to the CommXcvr which included all the
parts of the message send that should be sent over the wire, and let
the CommXcvr turn that into wire protocol.

This hides the protocol that the different kinds of CommXcvrs use, (if
we also make the old protocol private.)  This scheme reduces the code
in a proxy method from:

    SP2_Rational pop ()
      {
	SP2_Rational result;
	SPTR(CommXcvr) trans = commHandler->newCommXcvr ();

	trans->hello (cat_Calc, objectNumber, "pop2");
	trans->over ();
	trans->startGetResults ();
	result = CAST(Rational, trans->receive (cat_Rational));
	trans->endGetResults ();
	trans->goodbye ();
	CommXcvr * temp = trans;
	delete temp;
	return result;
    }

to something more like:

    SP2_Rational pop () {
        SP2_Rational result;
 	SPTR(CommXcvr) trans = commHandler->newCommXcvr ();
        result = CAST(Rational,
                      trans->handleSend(cat_Rational,
                                        cat_Calc, objectNumber, "pop2"));
        CommXcvr * temp = trans;
	delete temp;
        return result
    }


The handleSend method is pretty simple.  It uses VARARGS, and knows
that the first few arguments describe the return value type, receiver
type, receiver object number, and the message to be sent.  The rest of
the arguments describe, in pairs, each of the arguments and its type.
If we need to support output args, then there can be a marker
somewhere along the way that marks the transition.  handleSend()
doesn't need to know anything about particular messages, it just
transmits whatever the proxy claims its message looks like.

Is there anything wrong with this scheme?  Is there any reason I
shouldn't add the handleSend interface to CommXcvr's public interface
(and make the old protocol private and non-virtual)?  

Should handleSend go in commHandler instead?  It'd save the three
lines of code per proxy method that create and throw away the
CommXcvr.   

Chris