Versions Compared

Key

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

...

Code Block
languagecpp
titleAsyncClientImpl.cpp
linenumberstrue
collapsetrue
#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)
/* ----------------------------------------------------------------*/

Notes

C++

OffShoot Standalone Client

When working with standalone clients, we need to handle the servant lifecycle of the offshoots/callbacks. There are two approaches:

...

Code Block
languagecpp
linenumberstrue
collapsetrue
MyCBImpl* cb = new MyCBImpl();
examples::MyCallback_var cbObj = cb->_this();
...
// Stop ORB
... 
// Delete the heap OffShoot servant instance
delete cb;

OffShoot Component Client

When working with standalone clients in a component, we need to handle the servant lifecycle of the offshoots/callbacks. There are three approaches:

...