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++

Standalone Client

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

  1. Manual activation/deactivation of the CORBA object
  2. Manual activation with automatic deactivation of the CORBA object through the POA cleanup process