From: ken@cs.cornell.edu (Ken Birman)
Subject: Re: Question about isis and C++
Organization: Cornell Univ. CS Dept, Ithaca NY 14853
Distribution: comp
Date: Thu, 7 Jan 1993 20:45:06 GMT

In article <MTC.93Jan7194423@latina.inesc.pt> mtc@inesc.pt writes:
>I am trying to use isis from a C++ program and I'm having a problem :
>
>When I call :
>
>        isis_entry(QUERY_ENTRY, (void (*) (message*))cback_receive_query,
>                                                    "cback_receive_query");
>
>        I would like to send an extra parameter to the "cback _receive_query"
>        callback function, namely the "this" pointer.
>
>        I can do it successfully with the "isis_mainloop" call, but not with the
>        "isis_entry". isis_mainloop expects a (void (*) (void *)) callback
>        parameter, instead of a (void (*) (message*)) as isis_entry does.
>
>Could anyone help me solving this problem ?

This is a common complaint about Isis from C++...  Most
C++ users (we have plenty of them) specify a straight C function for
these callbacks, and then have that function demultiplex incoming
messages by passing them to the correct object instance.  Normally,
this involved including enough information at the front of each messaghe
to figure which object(s) will need to see the message.

An alternative is to create what is called a "closure", namely
a function that is defined in a scope for which a value of one or
more variables, such as "this", would be visible each time it is
invoked.  Unfortunately, in C this is sort of awkward to do,
although in other languages it may make sense.

This points to another limitation.  If you try and think of individual
objects as members of groups, instead of thinking of the process in which
they live as the group member, you might have one object try to become a
client of a group G, while two others try and join G and yet another
decides to leave G.  

This is because the objects in a C++ system tend not to know about
each other and so if an object class includes code to join,leave or
call pg_client, each separate instance will try to do that, possibly
on the same group.

But, Isis doesn't let one address space -- one heavyweight program --
belong to a group multiple times.  Olof Hagsand did a nice paper on
this with Holger Herzog, Robert Cooper and I when visiting.  He
can send a copy (email: olof@sics.se).  So, you need to avoid such
behavior, and this says that individual object instances should
normally not join and leave groups directly, unless you have a different
group for each object instance.

Brad Glade has been working on a new kind of "lighweight" object interface
for Isis that would work much better.  Perhaps he could post something
about this to the newsgroup -- Brad?

Summary: pass a standard C function, and have the C function do a callback
to your object, or perhaps to a set of objects depending on what you are
trying to do.  Have the incoming message itself identify the object(s)
that it should be delivered to.
-- 
Kenneth P. Birman                              E-mail:  ken@cs.cornell.edu
4105 Upson Hall, Dept. of Computer Science     TEL:     607 255-9199 (office)
Cornell University Ithaca, NY 14853 (USA)      FAX:     607 255-4428