Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • The CORBA details are encapsulated in an ACS framework method
  • A special POA is used instead of the default one, providing special policies recommended for transient CORBA objects

It is possible to use this approach both for stack and heap variables with the same restrictions:

Stack OffShoot

For the OffShoot servant instance on the stack, you need to make sure to deactivate the OffShoot servant before cb variable goes out of scope. Here you will get compilation issues if you try to deactivate it after going out of scope.

Code Block
languagecpp
linenumberstrue
collapsetrue
MyCBImpl cb;
ACS::OffShoot_var offshoot = getContainerServices().activateOffShoot(&cb);
examples::MyCallback_var cbObj = examples::MyCallback::_narrow(offshoot.in());
...
//Deactivate the Offshoot servant
getContainerServices().deactivateOffShoot(&cb);
Heap OffShoot

For the OffShoot servant instance on the heap, you need to make sure to deactivate the OffShoot servant before destroying the cb variable. Doing it in the reverse order has undefined behavior, usually ending in segmentation fault.

Code Block
languagecpp
linenumberstrue
collapsetrue
MyCBImpl* cb = new MyCBImpl();
ACS::OffShoot_var offshoot = getContainerServices().activateOffShoot(cb);
examples::MyCallback_var cbObj = examples::MyCallback::_narrow(offshoot.in());
...
//Deactivate the Offshoot servant
getContainerServices().deactivateOffShoot(cb);

// Make sure to delete the OffShoot servant instance after deactivating the CORBA object
delete cb;