当前位置: 首页>>代码示例>>C++>>正文


C++ POA_var::deactivate_object方法代码示例

本文整理汇总了C++中portableserver::POA_var::deactivate_object方法的典型用法代码示例。如果您正苦于以下问题:C++ POA_var::deactivate_object方法的具体用法?C++ POA_var::deactivate_object怎么用?C++ POA_var::deactivate_object使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在portableserver::POA_var的用法示例。


在下文中一共展示了POA_var::deactivate_object方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: owner_transfer

Test::Process_ptr
Process_Factory::create_new_process (void)
{
  Startup_Callback *startup_callback_impl;
  ACE_NEW_THROW_EX (startup_callback_impl,
                    Startup_Callback,
                    CORBA::NO_MEMORY ());

  PortableServer::ServantBase_var owner_transfer(startup_callback_impl);

  CORBA::Object_var poa_object =
    this->orb_->resolve_initial_references("RootPOA");

  PortableServer::POA_var root_poa =
    PortableServer::POA::_narrow (poa_object.in ());

  PortableServer::ObjectId_var id =
    root_poa->activate_object (startup_callback_impl);

  CORBA::Object_var object = root_poa->id_to_reference (id.in ());

  Test::Startup_Callback_var startup_callback =
    Test::Startup_Callback::_narrow (object.in ());

  CORBA::String_var ior =
    this->orb_->object_to_string (startup_callback.in ());

  const ACE_TCHAR* argv[3] = {
    ACE_TEXT("child"),
    ACE_TEXT_CHAR_TO_TCHAR(ior.in ()),
    0};

  ACE_Process_Options options;
#if !defined(ACE_WIN32)
  options.avoid_zombies (1);
#endif /* ACE_WIN32 */
  options.command_line (argv);

  ACE_Process child_process;
  pid_t pid =
    child_process.spawn (options);

  if (pid == -1)
    {
      ACE_DEBUG ((LM_DEBUG,
                  "(%P|%t) Process_Factory::create_new_process, "
                  " spawn call failed (%d)\n",
                  ACE_ERRNO_GET));
      throw Test::Spawn_Failed ();
    }

  int process_has_started = 0;
  Test::Process_var the_process;
  for (int i = 0; i != 500 && !process_has_started; ++i)
    {
      ACE_Time_Value interval (0, 10000);
      this->orb_->perform_work (interval);

      process_has_started =
        startup_callback_impl->process_has_started (the_process.out ());
    }

  try
    {
      PortableServer::POA_var poa =
        startup_callback_impl->_default_POA ();
      PortableServer::ObjectId_var id =
        poa->servant_to_id (startup_callback_impl);
      poa->deactivate_object (id.in ());
    }
  catch (const CORBA::Exception&)
    {
    }

  if (process_has_started == 0)
    {
      ACE_DEBUG ((LM_DEBUG,
                  "(%P|%t) Process_Factory::create_new_process, "
                  " timeout while waiting for child\n"));
      (void) child_process.terminate ();
      throw Test::Spawn_Failed ();
    }

  return the_process._retn ();
}
开发者ID:OspreyHub,项目名称:ATCD,代码行数:85,代码来源:Process_Factory.cpp

示例2: catch

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  try
    {
      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv);

      CORBA::Object_var poa_object =
        orb->resolve_initial_references("RootPOA");

      PortableServer::POA_var poa =
        PortableServer::POA::_narrow (poa_object.in ());

      if (CORBA::is_nil (poa.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           " (%P|%t) Panic: nil RootPOA\n"),
                          1);

      Hello_impl * h = 0;
      ACE_NEW_RETURN (h,Hello_impl, 1);

      CORBA::ULong before_act = h->_refcount_value ();

      ACE_DEBUG ((LM_DEBUG, "Before activation: %d\n", before_act));

      PortableServer::ObjectId_var oid = poa->activate_object (h);

      CORBA::ULong after_act = h->_refcount_value ();

      ACE_DEBUG ((LM_DEBUG, "After activation: %d\n", after_act));
        {
          /*
           * C++ Language Mapping (formal/03-06-03), section 1.37.3 (Servant
           * Memory Management Considerations), first bullet on page 1-136:
           *
           *   POA::id_to_servant returns a Servant. The POA invokes _add_ref
           *   once on the Servant before returning it; the caller of
           *   id_to_servant is responsible for invoking _remove_ref on the
           *   returned servant when it is finished with it.
           */

          CORBA::ULong refCountBeforeIdToServant =
            h->_refcount_value ();

          ACE_DEBUG ((LM_DEBUG, "Before id_to_servant:  %d\n", refCountBeforeIdToServant));

          PortableServer::ServantBase_var srv = poa->id_to_servant (oid.in());

          CORBA::ULong refCountAfterIdToServant =
            srv->_refcount_value ();;

          ACE_DEBUG ((LM_DEBUG, "After id_to_servant:  %d\n", refCountAfterIdToServant));

           /*
           * According to the above quote, this assertion shall be true.
           */
          ACE_ASSERT (refCountAfterIdToServant == refCountBeforeIdToServant + 1);

          /*
           * At the end of this scope, "srv" is destructed, which decrements
           * the servant's reference count.
           */
        }

      CORBA::ULong before_deact = h->_refcount_value ();

      ACE_DEBUG ((LM_DEBUG, "Before deactivate_object: %d\n", before_deact));

      poa->deactivate_object (oid.in());

      /*
       * Because id_to_servant did not increment the reference count, but
       * the reference count was decremented by the "srv" destructor, the
       * reference count, using TAO 1.4.5, is now 0, and the servant has
       * been destructed. So the following will crash, despite being
       * correct.
       */

      CORBA::ULong after_deact = h->_refcount_value ();

      ACE_DEBUG ((LM_DEBUG, "After deactivate_object: %d\n", after_deact));

      h->_remove_ref ();

      orb->shutdown (1);

      orb->destroy ();
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception caught:");
      return 1;
    }

  return 0;
}
开发者ID:chenbk85,项目名称:ACE-Middleware,代码行数:97,代码来源:test.cpp

示例3: scheduler_impl


//.........这里部分代码省略.........
      schedule_name.length (1);
      schedule_name[0].id = CORBA::string_dup ("ScheduleService");

      CORBA::String_var str =
        this->orb_->object_to_string (scheduler.in ());
      ACE_DEBUG ((LM_DEBUG, "The (local) scheduler IOR is <%s>\n",
                  str.in ()));

      // Register the servant with the Naming Context....
      naming_context->rebind (schedule_name, scheduler.in ());

      ACE_Scheduler_Factory::use_config (naming_context.in ());
#endif /* 0 */

      auto_ptr<POA_RtecEventChannelAdmin::EventChannel> ec_impl;

      TAO_EC_Event_Channel_Attributes attr (root_poa.in (),
                                            root_poa.in ());

      TAO_EC_Event_Channel *ec =
        new TAO_EC_Event_Channel (attr);

      ec->activate ();

      auto_ptr<POA_RtecEventChannelAdmin::EventChannel> auto_ec_impl (ec);
      ec_impl = auto_ec_impl;

      RtecEventChannelAdmin::EventChannel_var channel =
        ec_impl->_this ();

      this->connect_consumers (scheduler.in (),
                               channel.in ());

      ACE_DEBUG ((LM_DEBUG, "connected consumer(s)\n"));

      this->connect_suppliers (scheduler.in (),
                               channel.in ());

      ACE_DEBUG ((LM_DEBUG, "connected supplier(s)\n"));

      this->activate_suppliers ();

      ACE_DEBUG ((LM_DEBUG, "suppliers are active\n"));

      // Wait for the supplier threads...
      if (ACE_Thread_Manager::instance ()->wait () == -1)
        {
          ACE_ERROR ((LM_ERROR, "Thread_Manager wait failed\n"));
          return 1;
        }

      ACE_DEBUG ((LM_DEBUG, "suppliers finished\n"));

      this->dump_results ();

      this->disconnect_consumers ();

      ACE_DEBUG ((LM_DEBUG, "consumers disconnected\n"));

      this->disconnect_suppliers ();

      ACE_DEBUG ((LM_DEBUG, "suppliers disconnected\n"));

      channel->destroy ();

      ACE_DEBUG ((LM_DEBUG, "channel destroyed\n"));

      {
        // Deactivate the EC
        PortableServer::POA_var poa =
          ec_impl->_default_POA ();
        PortableServer::ObjectId_var id =
          poa->servant_to_id (ec_impl.get ());
        poa->deactivate_object (id.in ());

        ACE_DEBUG ((LM_DEBUG, "EC deactivated\n"));
      }

      {
        // Deactivate the Scheduler
        PortableServer::POA_var poa =
          scheduler_impl._default_POA ();
        PortableServer::ObjectId_var id =
          poa->servant_to_id (&scheduler_impl);
        poa->deactivate_object (id.in ());

        ACE_DEBUG ((LM_DEBUG, "scheduler deactivated\n"));
      }
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("ECT_Throughput::run");
    }
  catch (...)
    {
      ACE_ERROR ((LM_ERROR, "non-corba exception raised\n"));
    }

  return 0;
}
开发者ID:CCJY,项目名称:ATCD,代码行数:101,代码来源:ECT_Throughput.cpp

示例4: supplierecname

int
Gateway::run (int argc, ACE_TCHAR* argv[])
{
    TAO_EC_Gateway_IIOP_Factory::init_svcs ();

    try
    {
        // First parse our command line options
        if (this->parse_args(argc, argv) != 0)
        {
            return -1;
        }

        // ORB initialization boiler plate...
        CORBA::ORB_var orb =
            CORBA::ORB_init (argc, argv);

        CORBA::Object_var object =
            orb->resolve_initial_references ("RootPOA");
        PortableServer::POA_var poa =
            PortableServer::POA::_narrow (object.in ());
        PortableServer::POAManager_var poa_manager =
            poa->the_POAManager ();
        poa_manager->activate ();

        // Obtain the event channel from the naming service
        CORBA::Object_var naming_obj =
            orb->resolve_initial_references ("NameService");

        if (CORBA::is_nil (naming_obj.in ()))
            ACE_ERROR_RETURN ((LM_ERROR,
                               " (%P|%t) Unable to get the Naming Service.\n"),
                              1);

        CosNaming::NamingContext_var naming_context =
            CosNaming::NamingContext::_narrow (naming_obj.in ());

        CosNaming::Name supplierecname (1);
        supplierecname.length (1);
        supplierecname[0].id = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR(supplierec));

        CORBA::Object_var supplierec_obj =
            naming_context->resolve (supplierecname);

        CosNaming::Name consumerecname (1);
        consumerecname.length (1);
        consumerecname[0].id = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR(consumerec));

        CORBA::Object_var consumerec_obj =
            naming_context->resolve (consumerecname);

        RtecEventChannelAdmin::EventChannel_var supplier_event_channel =
            RtecEventChannelAdmin::EventChannel::_narrow (supplierec_obj.in ());

        if (CORBA::is_nil (supplier_event_channel.in ()))
            ACE_ERROR_RETURN ((LM_ERROR,
                               " (%P|%t) Unable to get the supplier event channel.\n"),
                              1);

        RtecEventChannelAdmin::EventChannel_var consumer_event_channel =
            RtecEventChannelAdmin::EventChannel::_narrow (consumerec_obj.in ());

        if (CORBA::is_nil (consumer_event_channel.in ()))
            ACE_ERROR_RETURN ((LM_ERROR,
                               " (%P|%t) Unable to get the consumer event channel.\n"),
                              1);

        TAO_EC_Gateway_IIOP gateway;

        gateway.init(supplier_event_channel.in(), consumer_event_channel.in());

        PortableServer::ObjectId_var gateway_oid =
            poa->activate_object(&gateway);

        CORBA::Object_var gateway_obj =
            poa->id_to_reference(gateway_oid.in());

        RtecEventChannelAdmin::Observer_var obs =
            RtecEventChannelAdmin::Observer::_narrow(gateway_obj.in());

        RtecEventChannelAdmin::Observer_Handle local_ec_obs_handle =
            consumer_event_channel->append_observer (obs.in ());

        // Wait for events, using work_pending()/perform_work() may help
        // or using another thread, this example is too simple for that.
        orb->run ();

        consumer_event_channel->remove_observer (local_ec_obs_handle);

        poa->deactivate_object (gateway_oid.in ());

        // Destroy the POA
        poa->destroy (1, 0);
    }
    catch (const CORBA::Exception& ex)
    {
        ex._tao_print_exception ("Gateway::run");
        return 1;
    }

//.........这里部分代码省略.........
开发者ID:akostrikov,项目名称:ATCD,代码行数:101,代码来源:Gateway.cpp

示例5:

CollisionDetectorFactory_impl::~CollisionDetectorFactory_impl()
{
  PortableServer::POA_var poa = _default_POA();
  PortableServer::ObjectId_var id = poa->servant_to_id(this);
  poa->deactivate_object(id);
}
开发者ID:olivier-stasse,项目名称:openhrp3-simulator-wo-rtm,代码行数:6,代码来源:CollisionDetector_impl.cpp


注:本文中的portableserver::POA_var::deactivate_object方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。