Home Help Center

A Question about Shared and GCShared

OrNotOrNot Member Bin.LiOrganization: GE HealthcareProject: Enterprise solution
hi, there,
There are two base class in ICE , Shared and GCShared.
But I do not know what is the difference between them . Which should I use and in what circumstance to use ?
Are there any generic principles in practice?
Any help is appreciated.



Best regards
OrNot

Comments

  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    GCShared can detect cyclic references, and therefore do garbage collection. It is not intended to be used by the application programmer, because it also requires generated code to function properly.
  • OrNotOrNot Member Bin.LiOrganization: GE HealthcareProject: Enterprise solution
    hi,marc,
    Do you mean that GCShared should be transparent to application programmer? But in fact, I did not realize the GCShared until I studied the bidir demo and noticed the following comments in callbackI.h file:
    We cannot derive CallbackSenderI from IceUtil::Thread, because CallbackSenderI uses IceUtil::GCShared as base, and IceUtil::Thread uses IceUtil::Shared as base. These two base classes are not compatible. Therefore we use this helper class.

    I think if it were me to program this demo, I would much probably derive the callbacksenderI from the IceUtil::Thread because I never get any knowledge from
    docoument about GCShared and Shared. But so far as this
    demo, it seems not transparent to us application programer.




    BTW: Another elementary question ;) (sorry, I have too many newbie quesitions.)

    When introducing the Bi-directional Connections , In 33.7, it is said that "An Ice connection normally allows requests to flow in only one direction." But I can't understand why say so since ,say, a TCP connection, is duplex. Or the "uni-direction" mentioned here just is imposed by ICE ?
    Hope getting your help.

    Thanks a lot.

    OrNot
  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    You are right in that we need to better document that you cannot derive an implementation class from IceUtil::Shared (directly or indirectly). But I don't see any transparency issue here, except for those that every intrusive reference counting scheme imposes. If you would have any other base class for intrusive reference counted objects, such as from a third-party library, then you couldn't derive from this base class either.

    Regarding your other questions, of course TCP connections are bi-directional. However, if with Ice you want to use a connection both for sending and receiving requests, then you have to take the extra steps as outlined in the bi-dir demo, or you must use a router such as Glacier.
Sign In or Register to comment.