⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cubit_client.cpp

📁 这是广泛使用的通信开源项目,对于大容量,高并发的通讯要求完全能够胜任,他广泛可用于网络游戏医学图像网关的高qos要求.更详细的内容可阅读相应的材料
💻 CPP
📖 第 1 页 / 共 4 页
字号:

      // UNION
      if (this->check_enabled (TAO_ENABLE_CUBIT_UNION))
        {
          this->call_count_ = 0;
          this->error_count_ = 0;
          timer.start ();

          for (i = 0; i < this->loop_count_; ++i)
            {
              this->cube_union (ACE_ENV_SINGLE_ARG_PARAMETER);
              ACE_TRY_CHECK;
            }

          timer.stop ();
          timer.elapsed_time (elapsed_time);

          this->print_stats ("cube_union_stub call",
                             elapsed_time);
        }

      // SMALL LONG SEQUENCES
      if (this->check_enabled (TAO_ENABLE_CUBIT_SMALL_LONG_SEQ))
        {
          this->call_count_ = 0;
          this->error_count_ = 0;
          timer.start ();

          for (i = 0; i < this->loop_count_; ++i)
            {
              this->cube_long_sequence (this->loop_count_,
                                        4
                                        ACE_ENV_ARG_PARAMETER);
              ACE_TRY_CHECK;
            }

          timer.stop ();
          timer.elapsed_time (elapsed_time);

          this->print_stats ("cube_small_sequence<long>",
                             elapsed_time);
        }

      // LARGE LONG SEQUENCES
      if (this->check_enabled (TAO_ENABLE_CUBIT_LARGE_LONG_SEQ))
        {
          this->call_count_ = 0;
          this->error_count_ = 0;
          timer.start ();

          for (i = 0; i < this->loop_count_; ++i)
            {
              this->cube_long_sequence (this->loop_count_,
                                        1024
                                        ACE_ENV_ARG_PARAMETER);
              ACE_TRY_CHECK;
            }

          timer.stop ();
          timer.elapsed_time (elapsed_time);

          this->print_stats ("cube_large_sequence<long>",
                             elapsed_time);
        }

      // SMALL OCTET SEQUENCES
      if (this->check_enabled (TAO_ENABLE_CUBIT_SMALL_OCTET_SEQ))
        {
          this->call_count_ = 0;
          this->error_count_ = 0;
          timer.start ();

          if (bytes_in_octet_sequence_ > 0)
            {
              ACE_DEBUG ((LM_DEBUG,
                          "Running sequence<octet> test with %u bytes "
                          "in the sequence.\n", bytes_in_octet_sequence_));
              for (i = 0; i < this->loop_count_; ++i)
                {
                  this->cube_octet_sequence (this->loop_count_,
                                             bytes_in_octet_sequence_
                                             ACE_ENV_ARG_PARAMETER);
                  ACE_TRY_CHECK;
                }
            }
          else
            {
              for (i = 0; i < this->loop_count_; ++i)
                {
                  this->cube_octet_sequence (this->loop_count_,
                                             16
                                             ACE_ENV_ARG_PARAMETER);
                  ACE_TRY_CHECK;
                }
            }

          timer.stop ();
          timer.elapsed_time (elapsed_time);

          this->print_stats ("cube_small_sequence<octet>",
                             elapsed_time);
        }

      // LARGE OCTET SEQUENCES
      if (this->check_enabled (TAO_ENABLE_CUBIT_LARGE_OCTET_SEQ))
        {
          this->call_count_ = 0;
          this->error_count_ = 0;
          timer.start ();

          for (i = 0; i < this->loop_count_; ++i)
            {
              this->cube_octet_sequence (this->loop_count_,
                                         4096
                                         ACE_ENV_ARG_PARAMETER);
              ACE_TRY_CHECK;
            }

          timer.stop ();
          timer.elapsed_time (elapsed_time);

          this->print_stats ("cube_large_sequence<octet>",
                             elapsed_time);
        }

      // SMALL MANY SEQUENCES
      if (this->check_enabled (TAO_ENABLE_CUBIT_SMALL_STRUCT_SEQ))
        {
          this->call_count_ = 0;
          this->error_count_ = 0;
          timer.start ();

          for (i = 0; i < this->loop_count_; ++i)
            {
              this->cube_many_sequence (this->loop_count_,
                                        4
                                        ACE_ENV_ARG_PARAMETER);
              ACE_TRY_CHECK;
            }

          timer.stop ();
          timer.elapsed_time (elapsed_time);

          this->print_stats ("cube_small_sequence<many>",
                             elapsed_time);
        }

      // LARGE MANY SEQUENCES
      if (this->check_enabled (TAO_ENABLE_CUBIT_LARGE_STRUCT_SEQ))
        {
          this->call_count_ = 0;
          this->error_count_ = 0;
          timer.start ();

          for (i = 0; i < this->loop_count_; ++i)
            {
              this->cube_many_sequence (this->loop_count_,
                                        1024
                                        ACE_ENV_ARG_PARAMETER);
              ACE_TRY_CHECK;
            }

          timer.stop ();
          timer.elapsed_time (elapsed_time);

          this->print_stats ("cube_large_sequence<many>",
                             elapsed_time);
        }

      // MIXIN
      if (this->check_enabled (TAO_ENABLE_CUBIT_MIXIN))
        {
          this->call_count_ = 0;
          this->error_count_ = 0;
          timer.start ();

          for (i = 0; i < this->loop_count_; ++i)
            {
              this->cube_short (i
                                ACE_ENV_ARG_PARAMETER);
              ACE_TRY_CHECK;

              this->cube_octet (i
                                ACE_ENV_ARG_PARAMETER);
              ACE_TRY_CHECK;

              this->cube_long (i
                               ACE_ENV_ARG_PARAMETER);
              ACE_TRY_CHECK;
            }

          timer.stop ();
          timer.elapsed_time (elapsed_time);
          this->print_stats ("cube mixin (short/octet/long)",
                             elapsed_time);
        }

      // RTI
      if (this->check_enabled (TAO_ENABLE_CUBIT_RTI_DATA))
        {
          this->call_count_ = 0;
          this->error_count_ = 0;
          timer.start ();

          for (i = 0; i < this->loop_count_; ++i)
            {
              this->cube_rti_data (this->loop_count_,
                                   2,
                                   5
                                   ACE_ENV_ARG_PARAMETER);
              ACE_TRY_CHECK;
            }

          timer.stop ();
          timer.elapsed_time (elapsed_time);

          this->print_stats ("cube_rti_data",
                             elapsed_time);
        }

      // ONEWAY
      if (this->check_enabled (TAO_ENABLE_CUBIT_ONE_WAY))
        {
          this->call_count_ = 0;
          this->error_count_ = 0;
          timer.start ();

          for (i = 0; i < this->loop_count_; ++i)
            {
              this->cube_oneway (i
                                 ACE_ENV_ARG_PARAMETER);
              ACE_TRY_CHECK;
            }

          timer.stop ();
          timer.elapsed_time (elapsed_time);

          this->print_stats ("cube_oneway",
                             elapsed_time);
        }

      // ANY - LONG
      if (this->check_enabled (TAO_ENABLE_CUBIT_ANY))
        {
          this->call_count_ = 0;
          this->error_count_ = 0;
          timer.start ();

          for (i = 0; i < this->loop_count_; ++i)
            {
              this->cube_any (i
                              ACE_ENV_ARG_PARAMETER);
              ACE_TRY_CHECK;
            }

          timer.stop ();
          timer.elapsed_time (elapsed_time);
          this->print_stats ("cube_any",
                             elapsed_time);
        }

      // ANY - STRUCT
      if (this->check_enabled (TAO_ENABLE_CUBIT_ANY_STRUCT))
        {
          this->call_count_ = 0;
          this->error_count_ = 0;
          timer.start ();

          for (i = 0; i < this->loop_count_; ++i)
            {
              this->cube_any_struct (i
                                     ACE_ENV_ARG_PARAMETER);

              ACE_TRY_CHECK;
            }

          timer.stop ();
          timer.elapsed_time (elapsed_time);

          this->print_stats ("cube_any_struct",
                             elapsed_time);
	}

      this->shutdown_server (this->shutdown_
                             ACE_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;
      
      ACE_TRY_EX (SHM)
	{
	  this->cubit_->ping (ACE_ENV_SINGLE_ARG_PARAMETER);
	  ACE_TRY_CHECK_EX (SHM);
	}
      ACE_CATCHANY
	{
	  // Dont do anything..
	}
      ACE_ENDTRY;
    }
  ACE_CATCHANY
    {
      ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
                           "Cubit_Client::run");
    }
  ACE_ENDTRY;

  return this->error_count_ == 0 ? 0 : 1;
}

int
Cubit_Client::shutdown_server (int do_shutdown
                               ACE_ENV_ARG_DECL)
{
  if (do_shutdown)
    {
      ACE_DEBUG ((LM_DEBUG,
                  "shutdown on cubit object\n"));

      ACE_TRY_EX(NOT_COLLOCATED)
        {
          this->cubit_->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
          ACE_TRY_CHECK_EX (NOT_COLLOCATED);
        }
      ACE_CATCHANY
        {
          ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
                               "Cubit::shutdown_server");
        }
      ACE_ENDTRY;
      ACE_CHECK_RETURN (-1);
    }

  return 0;
}

Cubit_Client::~Cubit_Client (void)
{
  // Free resources and close the IOR files.
  if (this->cubit_factory_ior_file_)
    {
      ACE_OS::fclose (this->cubit_factory_ior_file_);
    }

  if (this->f_handle_ != ACE_INVALID_HANDLE)
    {
      ACE_OS::close (this->f_handle_);
    }

  if (this->cubit_factory_key_ != 0)
    {
      ACE_OS::free (this->cubit_factory_key_);
    }

  // Release the objects, to have a clean shutdown.
  this->factory_ = Cubit_Factory::_nil ();
  this->cubit_ = Cubit::_nil ();

  // Now release the ORB
  this->orb_ = CORBA::ORB::_nil ();
}


int
Cubit_Client::init (int argc, char **argv)
{
  this->argc_ = argc;
  this->argv_ = argv;

  ACE_TRY_NEW_ENV
    {
      // Retrieve the ORB.
      this->orb_ = CORBA::ORB_init (this->argc_,
                                    this->argv_,
                                    "internet"
                                    ACE_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;

      // Parse command line and verify parameters.
      if (this->parse_args () == -1)
        {
          return -1;
        }
      else
        {
          // Enable all tests if none were specified.
          if (this->test_enable_bitset_ == 0)
            this->enable_test (TAO_ENABLE_CUBIT_ALL);

          // Disable tests that were explicitly disabled.
          if (this->test_disable_bitset_ != 0)
            this->test_enable_bitset_ &= ~this->test_disable_bitset_;
        }


      if (this->cubit_factory_key_ == 0)
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             "%s: no cubit factory key specified\n",
                             this->argv_[0]),
                            -1);
        }

      CORBA::Object_var factory_object =
        this->orb_->string_to_object (this->cubit_factory_key_
                                      ACE_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;

      this->factory_ =
        Cubit_Factory::_narrow (factory_object.in()
                                ACE_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;

      if (CORBA::is_nil (this->factory_.in ()))
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             "invalid factory key <%s>\n",
                             this->cubit_factory_key_),
                            -1);
        }

      ACE_DEBUG ((LM_DEBUG,
                  "Factory received OK\n"));

      // Now retrieve the Cubit obj ref corresponding to the key.
      this->cubit_ =
        this->factory_->make_cubit (ACE_ENV_SINGLE_ARG_PARAMETER);
      ACE_TRY_CHECK;

      if (CORBA::is_nil (this->cubit_.in ()))
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             "null cubit objref returned by factory\n"),
                            -1);
        }
    }
  ACE_CATCHANY
    {
      ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
                           "Cubit::init");
      return -1;
    }
  ACE_ENDTRY;

  return 0;
}

#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
template class ACE_Env_Value<unsigned long>;
template class ACE_Env_Value<unsigned short>;
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
#pragma instantiate ACE_Env_Value<unsigned long>
#pragma instantiate ACE_Env_Value<unsigned short>
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -