home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / isis / 367 < prev    next >
Encoding:
Text File  |  1993-01-07  |  3.4 KB  |  73 lines

  1. Newsgroups: comp.sys.isis
  2. Path: sparky!uunet!elroy.jpl.nasa.gov!usc!rpi!batcomputer!cornell!ken
  3. From: ken@cs.cornell.edu (Ken Birman)
  4. Subject: Re: Question about isis and C++
  5. Message-ID: <1993Jan7.204506.20712@cs.cornell.edu>
  6. Organization: Cornell Univ. CS Dept, Ithaca NY 14853
  7. References: <MTC.93Jan7194423@latina.inesc.pt>
  8. Distribution: comp
  9. Date: Thu, 7 Jan 1993 20:45:06 GMT
  10. Lines: 61
  11.  
  12. In article <MTC.93Jan7194423@latina.inesc.pt> mtc@inesc.pt writes:
  13. >I am trying to use isis from a C++ program and I'm having a problem :
  14. >
  15. >When I call :
  16. >
  17. >        isis_entry(QUERY_ENTRY, (void (*) (message*))cback_receive_query,
  18. >                                                    "cback_receive_query");
  19. >
  20. >        I would like to send an extra parameter to the "cback _receive_query"
  21. >        callback function, namely the "this" pointer.
  22. >
  23. >        I can do it successfully with the "isis_mainloop" call, but not with the
  24. >        "isis_entry". isis_mainloop expects a (void (*) (void *)) callback
  25. >        parameter, instead of a (void (*) (message*)) as isis_entry does.
  26. >
  27. >Could anyone help me solving this problem ?
  28.  
  29. This is a common complaint about Isis from C++...  Most
  30. C++ users (we have plenty of them) specify a straight C function for
  31. these callbacks, and then have that function demultiplex incoming
  32. messages by passing them to the correct object instance.  Normally,
  33. this involved including enough information at the front of each messaghe
  34. to figure which object(s) will need to see the message.
  35.  
  36. An alternative is to create what is called a "closure", namely
  37. a function that is defined in a scope for which a value of one or
  38. more variables, such as "this", would be visible each time it is
  39. invoked.  Unfortunately, in C this is sort of awkward to do,
  40. although in other languages it may make sense.
  41.  
  42. This points to another limitation.  If you try and think of individual
  43. objects as members of groups, instead of thinking of the process in which
  44. they live as the group member, you might have one object try to become a
  45. client of a group G, while two others try and join G and yet another
  46. decides to leave G.  
  47.  
  48. This is because the objects in a C++ system tend not to know about
  49. each other and so if an object class includes code to join,leave or
  50. call pg_client, each separate instance will try to do that, possibly
  51. on the same group.
  52.  
  53. But, Isis doesn't let one address space -- one heavyweight program --
  54. belong to a group multiple times.  Olof Hagsand did a nice paper on
  55. this with Holger Herzog, Robert Cooper and I when visiting.  He
  56. can send a copy (email: olof@sics.se).  So, you need to avoid such
  57. behavior, and this says that individual object instances should
  58. normally not join and leave groups directly, unless you have a different
  59. group for each object instance.
  60.  
  61. Brad Glade has been working on a new kind of "lighweight" object interface
  62. for Isis that would work much better.  Perhaps he could post something
  63. about this to the newsgroup -- Brad?
  64.  
  65. Summary: pass a standard C function, and have the C function do a callback
  66. to your object, or perhaps to a set of objects depending on what you are
  67. trying to do.  Have the incoming message itself identify the object(s)
  68. that it should be delivered to.
  69. -- 
  70. Kenneth P. Birman                              E-mail:  ken@cs.cornell.edu
  71. 4105 Upson Hall, Dept. of Computer Science     TEL:     607 255-9199 (office)
  72. Cornell University Ithaca, NY 14853 (USA)      FAX:     607 255-4428
  73.