[omniORB] RefCountServantBase Question

Duncan Grisby duncan at grisby.org
Wed Feb 1 23:07:17 GMT 2006


On Wednesday 1 February, Brian Neal wrote:

> It's my understanding that in a recent change to the C++ mapping, the
> powers that be changed RefCountServantBase. It no longer inherits from
> PortableServer::ServantBase, and it just becomes an empty struct.

Yes.

> I take it this going to bust my code when I upgrade to 4.0.7 (or newer)?

No. That's far too significant a change for a micro release. The change
is in omniORB 4.1.0.

> I also think that they changed ServantBase, making reference counting
> mandatory and built-in.

Yes. The exceedingly rare case of instantiating servants on the stack is
still supported, though.

> So what are the migration options? When I upgrade is it a simple
> matter to replace RefCountServantBase with ServantBase in my code?

Almost certainly you don't have to do anything. Your old code will still
work just the same. The only time you'll have to change anything is if
you implemented _add_ref and _remove_ref in your servant classes in a
way that called the versions in RefCountServantBase, which is unusual.
If you have code that does that, you need to modify it to call the
methods in ServantBase.

New code doesn't need to inherit RefCountServantBase to get reference
counting behaviour. You just inherit from the POA skeleton class. See
the examples in the omniORB 4.1 distribution.

> And how does this new Servant_var fit in?

It has nothing to do with the RefCountServantBase changes. It's just a
template class that does type-safe servant reference counting for you.
Where before code had to explicitly call _remove_ref() on servants, or
assign the pointers to a ServantBase_var, you can now use a
single Servant_var<> instance. i.e. instead of

  MyServant* svt = new MyServant();
  ObjectId_var oid = poa->activate_object(svt);
  svt->_remove_ref();

you can now do

  Servant_var<MyServant> svt = new MyServant();
  ObjectId_var oid = poa->activate_object(svt);

and not have to worry about the _remove_ref().

Cheers,

Duncan.

-- 
 -- Duncan Grisby         --
  -- duncan at grisby.org     --
   -- http://www.grisby.org --



More information about the omniORB-list mailing list