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


C++ ACE_Time_Value类代码示例

本文整理汇总了C++中ACE_Time_Value的典型用法代码示例。如果您正苦于以下问题:C++ ACE_Time_Value类的具体用法?C++ ACE_Time_Value怎么用?C++ ACE_Time_Value使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1:

ScopedTimer::~ScopedTimer() 
{
	destroy_time_ = ACE_OS::gettimeofday();
	ACE_Time_Value diff = destroy_time_ - init_time_;
	printf("[ScopedTimer: %s Time: %ld.%03ldms]\n",
				name_.c_str(),
				diff.sec() * 1000 + diff.usec() / 1000,
				diff.usec() % 1000);
}
开发者ID:jl2005,项目名称:usefull_codes,代码行数:9,代码来源:TimeUtils.cpp

示例2: start

void
test_i::shutdown (CORBA::Long start_time)
{
  ACE_Time_Value start (0);
  start.msec (static_cast<long> (start_time)); // HPUX seems to require this cast
  ACE_DEBUG ((LM_DEBUG, "server: Shutting down... (%dms)\n",
              (ACE_OS::gettimeofday() - start).msec ()));
  this->orb_->shutdown (0);
}
开发者ID:asdlei00,项目名称:ACE,代码行数:9,代码来源:test_i.cpp

示例3: conf

bool CoAPRDService::initialize()
{
    try
    {
        std::string conf("service.conf");
        std::string reactor("service.reactor");

        _confPtr = ServiceGetter::findByName<ConfService>(context(), conf);
        _reactorPtr = ServiceGetter::findByName<ReactorService>(context(), reactor);

    }
    catch(toolkit::NullPointerException &e)
    {
        ACE_DEBUG((LM_DEBUG, "get service failed at SerialPortService\n"));

        return false;
    }


    _coapWrapperPtr = new CoAPWrapper();

    if (_coapWrapperPtr->Create(_confPtr->_rdAddr,
                                _confPtr->_rdAddrPort,
                                _confPtr->_coapDebugLevel
                               ) < 0)
    {

        ACE_DEBUG((LM_DEBUG,"Failed to create coap\n"));
        return false;
    }

    _rdRes = new CoAP_RD_Resource(_coapWrapperPtr.get());

    if ((_rdRes->Create()) == 0)
    {
        ACE_DEBUG((LM_DEBUG,"Failed to craete rd resource\n"));
        return false;
    }

    _rdLookup = new CoAPRDLookUpResource(_coapWrapperPtr.get());

    if ((_rdLookup->Create()) == 0)
    {
        ACE_DEBUG((LM_DEBUG,"Failed to craete lookup resource\n"));
        return false;
    }

    ACE_Time_Value timeout;
    timeout.sec(5);

    _reactorPtr->register_handler(this, ACE_Event_Handler::READ_MASK);
    _reactorPtr->schedule_timer(this, 0, timeout);


    return true;
}
开发者ID:hisilicon,项目名称:IoTGateway,代码行数:56,代码来源:CoAPRdService.cpp

示例4: delaySystem

/// WARNING: actual precision under WIN32 depends on setting scheduler
/// by means of MM functions.
///
void SystemClock::delaySystem(double seconds) {
#ifdef YARP_HAS_ACE
    ACE_Time_Value tv;
    tv.sec (long(seconds));
    tv.usec (long((seconds-long(seconds)) * 1.0e6));
    ACE_OS::sleep(tv);
#else
    usleep(seconds*1000000);
#endif
}
开发者ID:BRKMYR,项目名称:yarp,代码行数:13,代码来源:SystemClock.cpp

示例5:

int
STDIN_Handler::handle_timeout (const ACE_Time_Value &tv,
                               const void *)
{
  ACE_DEBUG ((LM_DEBUG,
              "(%t) timeout occurred at %d sec, %d usec\n",
              tv.sec (),
              tv.usec ()));
  return 0;
}
开发者ID:BackupTheBerlios,项目名称:pyasynchio-svn,代码行数:10,代码来源:test_demuxing.cpp

示例6: ACE_NEW_THROW_EX

    CORBA::Object_ptr
    ServantRetentionStrategyNonRetain::create_reference (
      const char *intf,
      CORBA::Short priority)
    {
      // This operation creates an object reference that encapsulates a
      // POA-generated Object Id value and the specified interface
      // repository id. This operation does not cause an activation to
      // take place. The resulting reference may be passed to clients, so
      // that subsequent requests on those references will cause the
      // appropriate servant manager to be invoked, if one is
      // available. The generated Object Id value may be obtained by
      // invoking POA::reference_to_id with the created reference.

      PortableServer::ObjectId_var system_id;
      PortableServer::ObjectId user_id;

      // Otherwise, it is the NON_RETAIN policy.  Therefore, any ol'
      // object id will do (even an empty one). However, to make an
      // object id useful for discriminating objects in applications
      // use a simple id of a counter and a time stamp. The use of a
      // counter by itself is not sufficient for uniqueness over time
      // and a timestamp isn't sufficient since multiple IDs may be
      // requested within the same time unit.

      PortableServer::ObjectId *sys_id = 0;
      ACE_NEW_THROW_EX (sys_id,
                        PortableServer::ObjectId (8),
                        CORBA::NO_MEMORY ());

      sys_id->length(8);

      long count = this->sys_id_count_++;
      ACE_Time_Value now = ACE_OS::gettimeofday();

      ACE_UINT32 *id_ptr = reinterpret_cast<ACE_UINT32 *>(sys_id->get_buffer());

      *(id_ptr++) = count;
      *id_ptr = static_cast<ACE_UINT32>(now.sec());

      system_id = sys_id;

      // User id is the same as system id.
      user_id = system_id.in ();

      // Remember params for potentially invoking <key_to_object> later.
      this->poa_->key_to_object_params_.set (system_id,
                                             intf,
                                             0,
                                             1,
                                             priority,
                                             true);

      return this->poa_->invoke_key_to_object_helper_i (intf, user_id);
    }
开发者ID:CCJY,项目名称:ATCD,代码行数:55,代码来源:ServantRetentionStrategyNonRetain.cpp

示例7: handleSynchSetup

static int handleSynchSetup(CRtspSession* pSession, const unsigned int unTimeout,
                            const bool bTcpFlag, MEDIA_ADDR *pstPeerMediaAddr)
{
    // 等待信号触发,否则阻塞在此
    ACE_Time_Value wait = ACE_OS::gettimeofday();
    wait.sec (wait.sec () + unTimeout);

    int nRet = pSession->m_pRtspSemaphore->acquire(&wait);
    // 接收超时,直接返回
    if(0 != nRet)
    {
        ACE_Guard <ACE_Thread_Mutex> locker (pSession->m_Mutex);
        IVS_RUN_LOG_ERR("receive rtsp setup response out of time, handle[%p].", pSession);
        pSession->destroyRtspMsg();
        return RTSP_ERR_TIMEOUT;
    }

	//IVS_RUN_LOG_ERR("----- handleSynchSetup 1, handle[%p].", pSession);

    // 解析错误,直接返回
    if (!pSession->m_bRecvRetFlag)
    {
		ACE_Guard <ACE_Thread_Mutex> locker (pSession->m_Mutex);
		int iRet = pSession->m_iRetCode;
        pSession->destroyRtspMsg();
		IVS_RUN_LOG_ERR("receive rtsp setup response decode error, handle[%p], RetCode[%d].", pSession, iRet);
        return iRet;
    }

	//IVS_RUN_LOG_ERR("----- handleSynchSetup 2, handle[%p].", pSession);

    // UDP传输方式下,获取媒体流发送地址
    //if (false == bTcpFlag)
    CRtspSetupMessage* pRtspMsg = dynamic_cast<CRtspSetupMessage*>(pSession->m_pRtspMsg);
    if (NULL == pRtspMsg)
    {
		IVS_RUN_LOG_ERR("receive rtsp setup response msg is null, handle[%p].", pSession);
        return RET_FAIL;
    }
    if (0 != pRtspMsg->getServerIp())
    {
        pstPeerMediaAddr->unMediaIp        = pRtspMsg->getServerIp();           //lint !e613
        pstPeerMediaAddr->unMediaVideoPort = pRtspMsg->getServerVideoPort();    //lint !e613
        pstPeerMediaAddr->unMediaAudioPort = pRtspMsg->getServerAudioPort();    //lint !e613
    }
 
	//IVS_RUN_LOG_ERR("----- handleSynchSetup 3, handle[%p].", pSession);

    // 释放消息
    pSession->destroyRtspMsg();
    // 解析成功,更改状态为ready
    pSession->setStatus(RTSP_SESSION_STATUS_READY);
    IVS_RUN_LOG_INF("send setup message success, handle[%p].", pSession);
    return RET_OK;
}
开发者ID:rgmabs19357,项目名称:esdk_ivs_sdk_windows,代码行数:55,代码来源:rtsp_client_api.cpp

示例8: handle_timeout

int RDService::handle_timeout (const ACE_Time_Value &tv,
                            const void *arg)
{
    ACE_Time_Value timeout;
    timeout.sec(5);
    
    coap_wrapper_->time_out(timeout);
    net_->schedule_timer(this, 0, timeout);
    
    return 0;
}
开发者ID:herryfan,项目名称:IoTGateway,代码行数:11,代码来源:RD_Service.cpp

示例9:

ACE_Log_Record::ACE_Log_Record (ACE_Log_Priority lp,
                                const ACE_Time_Value &ts,
                                long p)
  : length_ (0),
    type_ (ACE_UINT32 (lp)),
    secs_ ((ACE_UINT32) ts.sec ()),
    usecs_ ((ACE_UINT32) ts.usec ()),
    pid_ (ACE_UINT32 (p))
{
  // ACE_TRACE ("ACE_Log_Record::ACE_Log_Record");
}
开发者ID:dariuskylin,项目名称:utilityLib,代码行数:11,代码来源:Log_Record.cpp

示例10: policy_list

bool
Client::flood_connection (ACE_Time_Value& tv)
{
  // Block flushing currently blocks even on SYNC_DELAYED_BUFFERING
  //  so we can't use it to flood connections.

  // Set the policy value.
  // SYNC_DELAYED_BUFFERING is used to ensure that the tcp buffer gets filled before
  //  buffering starts.
  Messaging::SyncScope sync_scope = TAO::SYNC_DELAYED_BUFFERING;
  //Messaging::SyncScope sync_scope = Messaging::SYNC_NONE;
  CORBA::Any sync_scope_any;
  sync_scope_any <<= sync_scope;

  CORBA::PolicyList policy_list (1);
  policy_list.length (1);
  policy_list[0] = orb_->create_policy
    (Messaging::SYNC_SCOPE_POLICY_TYPE, sync_scope_any);
  // Apply the policy at the object level
  CORBA::Object_var obj = test_obj_->_set_policy_overrides
    (policy_list, CORBA::SET_OVERRIDE);
  Test_var mod_test_obj = Test::_narrow (obj.in ());

  policy_list[0]->destroy ();
  policy_list.length(0);

  ACE_Auto_Array_Ptr<char> tmp (new char [2000000]);
  char* msg = tmp.get();

  ACE_OS::memset (msg,'A',1999999);
  msg[1999999] = 0;

  test_obj_->sleep (static_cast<CORBA::Long>(tv.sec())
                    , static_cast<CORBA::Long>(tv.msec()));

  /* BLOCK flush startegy always has SYNC_WITH_TRANSPORT semantics.
      Trying to flood a BLOCKed flushing connection can lead to a TIMEOUT
      exception being thrown. This will close out the connection and
      the whole flooding attempt fails. Therefore in BLOCK flushing case
      don't attempt to flood (unless BLOCK flush accepts SYNC_WITH_TRANSPORT
      semantics).
   */
  if (flush_strategy_ != BLOCKING)
    {
      mod_test_obj->dummy_one_way (msg);

      // attempt again to flood connection.
      ACE_Time_Value tv_tmp (2);
      orb_->perform_work (tv_tmp);
    }

  return true;
}
开发者ID:OspreyHub,项目名称:ATCD,代码行数:53,代码来源:Client.cpp

示例11: run_main

int
run_main (int, ACE_TCHAR *[])
{
  ACE_START_TEST (ACE_TEXT ("Reactor_Notify_Test"));

  int test_result = 0;       // Innocent until proven guilty

  if (0 == run_notify_purge_test ())
    {
      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("purge_pending_notifications test OK\n")));
    }
  else
    {
      ACE_ERROR ((LM_ERROR,
                  ACE_TEXT ("purge_pending_notifications test FAIL\n")));
      test_result = 1;
    }

#if defined (ACE_HAS_THREADS)
  if (0 != run_quiet_notify_test ())
    test_result = 1;

  ACE_Time_Value timeout (SHORT_TIMEOUT);

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("(%t) running tests with notify pipe enabled")
              ACE_TEXT (" and time-out = %d seconds\n"),
              timeout.sec ()));
  run_test (0, timeout);

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("(%t) running tests with notify pipe disabled")
              ACE_TEXT (" and time-out = %d seconds\n"),
              timeout.sec ()));
  run_test (1, timeout);

  timeout.set (LONG_TIMEOUT, 0);
  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("(%t) running tests with reactor notification ")
              ACE_TEXT ("pipe enabled\n")
              ACE_TEXT (" and time-out = %d seconds\n"),
              timeout.sec ()));
  run_test (0, timeout);

#else
  ACE_ERROR ((LM_INFO,
              ACE_TEXT ("threads not supported on this platform\n")));
#endif /* ACE_HAS_THREADS */
  ACE_END_TEST;
  return test_result;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:52,代码来源:Reactor_Notify_Test.cpp

示例12: handle_timeout

int CoAPRDService::handle_timeout (const ACE_Time_Value &tv,
                                   const void *arg)
{
    ACE_Time_Value timeout;
    timeout.sec(5);

    _coapWrapperPtr->time_out(timeout);
    _reactorPtr->schedule_timer(this, 0, timeout);
    _rdRes->timeout();

    return 0;

}
开发者ID:hisilicon,项目名称:IoTGateway,代码行数:13,代码来源:CoAPRdService.cpp

示例13: Init

int RDService::Init()
{
    ACE_Time_Value timeout;
    timeout.sec(5);
    
    if ((coap_wrapper_ = new CoAPWrapper()) == 0)
    {
        ACE_DEBUG((LM_DEBUG, "Failed to allocate CoAPWrapper in RD\n"));
        return -1;
    }

    if (coap_wrapper_->Create(conf_->rd_addr_, 
                              conf_->rd_addr_port_,
                              conf_->coap_debug_level_
                              ) < 0)
    {

        ACE_DEBUG((LM_DEBUG,"Failed to create coap\n"));
        return -1;
    }

    if ((rd_resource_ = new CoAP_RD_Resource(coap_wrapper_)) == 0)
    {
        ACE_DEBUG((LM_DEBUG, "Failed to allocate rd resource in RD\n"));
        return -1;
    }

    if ((rd_resource_->Create()) == 0)
    {
        ACE_DEBUG((LM_DEBUG,"Failed to craete rd resource\n"));
        return -1;
    }
    
    if ((lookup_resource_ = new CoAPRDLookUpResource(coap_wrapper_)) == 0)
    {
        ACE_DEBUG((LM_DEBUG, "Failed to allocate lookup resource in RD\n"));
        return -1;
    }

    if ((lookup_resource_->Create()) == 0)
    {
        ACE_DEBUG((LM_DEBUG,"Failed to craete lookup resource\n"));
        return -1;
    }

    net_->join(coap_wrapper_->get_handle());
    net_->RegHandler(this, ACE_Event_Handler::READ_MASK);
    net_->schedule_timer(this, 0, timeout);
    
    return 0;
}
开发者ID:herryfan,项目名称:IoTGateway,代码行数:51,代码来源:RD_Service.cpp

示例14: test_timeout

// Tests the amount of time spent in a timed wait.
static int
test_timeout (void)
{
  int status = 0;

  // milliseconds...
  long msecs_expected;
  long msecs_waited;
  long msecs_diff;

  // Wait a little longer each time
  static long wait_secs = 3;

  ACE_Time_Value wait = ACE_OS::gettimeofday ();

  ACE_Time_Value begin = wait;

  wait.sec (wait.sec () + wait_secs);

  if (s.acquire (wait) == -1)
    {
      if (errno != ETIME)
        {
          ACE_ERROR ((LM_ERROR,
                      ACE_TEXT ("%p\n"),
                      ACE_TEXT ("test_timeout should be ETIME but is")));
          status = -1;
        }
    }

  ACE_Time_Value wait_diff = ACE_OS::gettimeofday () - begin;

  msecs_waited = wait_diff.msec ();
  msecs_expected = wait_secs * 1000;
  msecs_diff = labs (msecs_expected - msecs_waited);

  if (msecs_diff > ACE_ALLOWED_SLACK)
    {
      ACE_ERROR ((LM_ERROR,
                  ACE_TEXT ("Timed wait fails length test\n")));
      ACE_ERROR ((LM_ERROR,
                  ACE_TEXT ("Expected %d ms, actual %d ms; %d allowed\n"),
                  (int)msecs_expected,
                  (int)msecs_waited,
                  (int)ACE_ALLOWED_SLACK));
      status = -1;
    }

  ++wait_secs;
  return status;
}
开发者ID:esohns,项目名称:ATCD,代码行数:52,代码来源:Semaphore_Test.cpp

示例15: ACE_DEBUG

int
Thr_Consumer_Handler::svc (void)
{
  for (in_thread_ = 1;;)
    {
      ACE_DEBUG ((LM_DEBUG,
                  "(%t) Thr_Consumer_Handler's handle = %d\n",
                  this->peer ().get_handle ()));

      // Since this method runs in its own thread it is OK to block on
      // output.

      for (ACE_Message_Block *mb = 0;
           this->msg_queue ()->dequeue_head (mb) != -1;
           )
        if (this->send (mb) == -1)
          ACE_ERROR ((LM_ERROR,
                      "(%t) %p\n",
                      "send failed"));

      ACE_ASSERT (errno == ESHUTDOWN);

      ACE_DEBUG ((LM_DEBUG,
                  "(%t) shutting down threaded Consumer_Handler %d on handle %d\n",
                  this->connection_id (),
                  this->get_handle ()));

      this->peer ().close ();

      // Re-establish the connection, using exponential backoff.
      for (this->timeout (1);
           // Default is to reconnect synchronously.
           this->event_channel_->initiate_connection_connection (this, 1) == -1;
           // Second parameter '1' means using sync mode directly,
           // don't care Options::blocking_semantics().  If don't do
           // so, async mode will be used to connect which won't
           // satisfy original design.
           )
        {
          ACE_Time_Value tv (this->timeout ());

          ACE_ERROR ((LM_ERROR,
                      "(%t) reattempting connection, sec = %d\n",
                      tv.sec ()));

          ACE_OS::sleep (tv);
        }
    }

  ACE_NOTREACHED (return 0;)
}
开发者ID:BackupTheBerlios,项目名称:pyasynchio-svn,代码行数:51,代码来源:Concrete_Connection_Handlers.cpp


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