Discussion:
[omniORB] How can I wait for object deactivation with deactivate_object() ?
Martin B.
2011-01-03 22:42:00 UTC
Permalink
Hi!

I'm using the omniINSPOA to activate one CORBA object, but at the point
where I want to "destroy" the object I want only to deactivate this
object but keep the omniINSPOA running.

For objects in "normal" POA, I have always simply used
...
PortableServer::POAManager_var pman ...
pman->deactivate(true, true);
...
to simply wait for all objects and destroy them (implicitly via
ServantBase::_remove_ref())

Now, if I do not want to destroy the POA (manager), I can only call
deactivate_object(..) for my omniINS object, but this does not allow for
waiting until all requests have terminated.

Any tips?

cheers,
Martin
Duncan Grisby
2011-01-06 18:08:02 UTC
Permalink
Post by Martin B.
I'm using the omniINSPOA to activate one CORBA object, but at the point
where I want to "destroy" the object I want only to deactivate this
object but keep the omniINSPOA running.
For objects in "normal" POA, I have always simply used
...
PortableServer::POAManager_var pman ...
pman->deactivate(true, true);
...
to simply wait for all objects and destroy them (implicitly via
ServantBase::_remove_ref())
Now, if I do not want to destroy the POA (manager), I can only call
deactivate_object(..) for my omniINS object, but this does not allow for
waiting until all requests have terminated.
Do you really need to wait for deactivation? If you're just waiting so
you can call _remove_ref at the right time, you can just call
_remove_ref at any point earlier, and then when the object is
deactivated the POA will call _remove_ref and trigger deletion of the
servant.

If you really want to know, the way to do it is to provide your own
_remove_ref implementation so you know when the POA calls it.

Cheers,

Duncan.
--
-- Duncan Grisby --
-- ***@grisby.org --
-- http://www.grisby.org --
Martin B.
2011-01-06 22:22:12 UTC
Permalink
Post by Duncan Grisby
Post by Martin B.
I'm using the omniINSPOA to activate one CORBA object, but at the point
where I want to "destroy" the object I want only to deactivate this
object but keep the omniINSPOA running.
For objects in "normal" POA, I have always simply used
...
PortableServer::POAManager_var pman ...
pman->deactivate(true, true);
...
to simply wait for all objects and destroy them (implicitly via
ServantBase::_remove_ref())
Now, if I do not want to destroy the POA (manager), I can only call
deactivate_object(..) for my omniINS object, but this does not allow for
waiting until all requests have terminated.
Do you really need to wait for deactivation? If you're just waiting so
you can call _remove_ref at the right time, you can just call
_remove_ref at any point earlier, and then when the object is
deactivated the POA will call _remove_ref and trigger deletion of the
servant.
Yes, I'm already relying on the POA to finally delete my servant object.
It was just that at the moment where I called deactivate_object, I
wanted to wait for all calls to complete to avoid any timing related
problems.
Post by Duncan Grisby
If you really want to know, the way to do it is to provide your own
_remove_ref implementation so you know when the POA calls it.
Thanks for the tip about _remove_ref() ... what I did in the end was to
add some code to the servants d'tor so that I could mark the object as
finally deactivated from there.

cheers,
Martin

Loading...