Information
We are currently investigating an issue with the editor of some pages. Please save your work and avoid to create new pages until this banner is gone.
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
#include <AsyncClientImpl.h> #include <ACSErrTypeOK.h> AsyncClientImpl::AsyncClientImpl(const ACE_CString& name, maci::ContainerServices* containerServices) : acscomponent::ACSComponentImpl(name, containerServices) { } AsyncClientImpl::~AsyncClientImpl() { } void AsyncClientImpl::delay(ACS::uLong delay) { examples::Async_var comp = getContainerServices().getComponent<examples::Async>("ASYNC_CPP", 0, true); MyCBImpl cb; ACS::OffShoot_var offshoot = getContainerServices().activateOffShoot(&cb); examples::MyCallback_var cbObj = examples::MyCallback::_narrow(offshoot); ACS_SHORT_LOG((LM_INFO, "%s", cb.status)); comp->delayAsync(delay, cbObj.in()); ACS_SHORT_LOG((LM_INFO, "%s", cb.status)); sleep(delay/2+1); ACS_SHORT_LOG((LM_INFO, "%s", cb.status)); sleep(delay/2+1); ACS_SHORT_LOG((LM_INFO, "%s", cb.status)); getContainerServices().releaseComponent("ASYNC_CPP"); getContainerServices().deactivateOffShoot(&cb) } /* --------------- [ MACI DLL support functions ] -----------------*/ #include <maciACSComponentDefines.h> MACI_DLL_SUPPORT_FUNCTIONS(AsyncClientImpl) /* ----------------------------------------------------------------*/ |
When working with standalone clients, we need to handle the servant lifecycle of the offshoots/callbacks. There are two approaches:
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
MyCBImpl* cb = new MyCBImpl(); examples::MyCallback_var cbObj = cb->_this(); ... // Stop ORB ... // Delete the heap OffShoot servant instance delete cb; |
When working with standalone clients in a component, we need to handle the servant lifecycle of the offshoots/callbacks. There are three approaches:
...
It is possible to use this approach both for stack and heap variables with the same restrictions:
...