當前位置: 首頁>>代碼示例>>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: ACE_TEXT

int
Echo_Handler::dispatch_echo_checks (int first_call)
{
  // Set ones , if this is the first call (not from handle_timeout)
  if (first_call)
    {
      for (size_t j = 0; j < this->number_remotes_; ++j)
        {
          this->success_status_[j] = 1;
        }
      this->current_attempt_ = this->max_attempts_num_;
    }

  // Send echo-checks.
  for (size_t i = 0; i < this->number_remotes_; ++i)
    {
      if (this->success_status_[i] != 0)
        {
          if (this->ping_socket ().send_echo_check (
                this->remote_addrs_[i],
                this->connect_to_remote_) == -1)
            ACE_ERROR
              ((LM_ERROR,
                ACE_TEXT ("(%P|%t) Echo_Handler::dispatch_echo_checks - ")
                ACE_TEXT ("failed for this->remote_addrs_[%d].\n"),
                i));
        }
    }

  int rval_sched = -1;
  if ((rval_sched =
         this->reactor ()->schedule_timer (this,
                                           0,
                                           ACE_Time_Value (1),
                                           this->reply_wait_)) == -1)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("(%P|%t) Echo_Handler::dispatch_echo_checks:")
                       ACE_TEXT (" %p\n"),
                       ACE_TEXT ("schedule_timer")),
                      -1);
  return 0;
}
開發者ID:PGSeungminLee,項目名稱:CGSF,代碼行數:42,代碼來源:Network_Adapters_Test.cpp

示例2: ACE_TMAIN

int
ACE_TMAIN (int argc, ACE_TCHAR* argv[])
{
  try
  {
    if (argc < 2) throw args ();

    ACE_INET_Addr addr (argv[1]);

    //FUZZ: disable check_for_lack_ACE_OS
    // Turn on message loss and reordering simulation.
    //
    ACE_RMCast::Socket socket (addr, false, true);
    //FUZZ: enable check_for_lack_ACE_OS

    Message msg;
    msg.sn = 0;

    for (unsigned short i = 0; i < payload_size; i++)
    {
      msg.payload[i] = i;
    }

    for (; msg.sn < message_count; msg.sn++)
    {
      socket.send (&msg, sizeof (msg));
    }

    // Keep running in case retransmissions are needed.
    //
    ACE_OS::sleep (ACE_Time_Value (60, 0));

    return 0;
  }
  catch (args const&)
  {
    ACE_ERROR ((LM_ERROR,
                "usage: %s <IPv4 multicast address>:<port>\n", argv[0]));
  }

  return 1;
}
開發者ID:azraelly,項目名稱:knetwork,代碼行數:42,代碼來源:Sender.cpp

示例3: wait

int
DllOrb::fini (void)
{
  try
  {
    mv_poaManager_->deactivate (1, 1);
    mv_poaManager_ = PortableServer::POAManager::_nil ();

    // attempt to protect against sporadic BAD_INV_ORDER exceptions
    ACE_OS::sleep (ACE_Time_Value (0, 500));

      mv_rootPOA_->destroy (1, 1);

      mv_rootPOA_ = PortableServer::POA::_nil ();
    mv_orb_->shutdown (1);

    ACE_DEBUG ((LM_ERROR, ACE_TEXT ("wait() ...\n")));
    // wait for our threads to finish
    wait();
    ACE_DEBUG ((LM_ERROR, ACE_TEXT ("wait() done\n")));

    ACE_auto_ptr_reset (ma_barrier_, static_cast<ACE_Thread_Barrier *> (0));
  }
  catch (...)
  {
    ACE_DEBUG ((LM_ERROR, ACE_TEXT ("ERROR: exception\n")));
    return -1;
  }

  try
  {
    mv_orb_->destroy ();
    mv_orb_ = CORBA::ORB::_nil ();
  }
  catch (const CORBA::Exception& ex)
  {
    ex._tao_print_exception ("Exception caught:");
    return -1;
  }

  return 0;
}
開發者ID:CCJY,項目名稱:ATCD,代碼行數:42,代碼來源:DllOrb.cpp

示例4: av

  void
  Connection::write(Message& message)
  {
    ACE_Time_Value av(ACE_OS::gettimeofday() + ACE_Time_Value(1));

    if (writeMutex.acquire(av) == -1)
      throw Miro::CException(errno, "Error writing can device.");

    // Roland: Is this sleep necessary for Sparrow2003 can ???

    ACE_Time_Value time = ACE_OS::gettimeofday();
    ACE_Time_Value delta = time - lastWrite;
    if (delta < canTimeOut) {
      // is this sleep necessary ???
      // well, yes

      ACE_OS::sleep(canTimeOut - delta); // this is at least 10usec thanks to linux
      time = ACE_OS::gettimeofday();
    }

    // will definitely choke if base is off
    int rc;
    if (parameters_.module == "pcan") {
       pcanmsg * msgp;
       message.canMessage((int **) &msgp);
       msgp->msg.msgtype = MSGTYPE_EXTENDED;
       for(int i = 0; i < msgp->msg.len; i++)
          std::cout << msgp->msg.data[i];
       rc = ioctl(ioBuffer.get_handle(), PCAN_WRITE_MSG, msgp);
    }
    else {
       canmsg * msg;
       message.canMessage((int **) &msg);
       rc = ioBuffer.send_n(msg, sizeof(canmsg));
    }

    lastWrite = time;

    writeMutex.release();
    if (rc == -1)
      throw Miro::CException(errno, "Error writing can device.");
  }
開發者ID:BackupTheBerlios,項目名稱:miro-middleware-svn,代碼行數:42,代碼來源:CanConnection.cpp

示例5: handle_timeout

  virtual int handle_timeout (const ACE_Time_Value &,
                              const void *arg)
  {
    ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) Test_Handler::handle_timeout\n")));
    ++this->nr_expirations_;

    void *nc_arg = const_cast<void *> (arg);
    Thread_Timer_Queue *timer_queue =
      reinterpret_cast<Thread_Timer_Queue *> (nc_arg);

    ACE_Time_Value timeout = ACE_OS::gettimeofday () + ACE_Time_Value (1, 0);

    ACE_DEBUG ((LM_DEBUG,
                ACE_TEXT ("(%t) scheduling new timer 1 sec from now\n")));
    if (timer_queue->schedule (this, timer_queue, timeout) == -1)
      ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%t) %p\n"),
                  ACE_TEXT ("schedule failed")));

    return 0;
  }
開發者ID:INMarkus,項目名稱:ATCD,代碼行數:20,代碼來源:Recursive_Condition_Test.cpp

示例6: time_of_last_send

int AC_Output_Handler::svc () {
  ACE_Message_Block *chunk[ACE_IOV_MAX];
  size_t message_index = 0;
  ACE_Time_Value time_of_last_send (ACE_OS::gettimeofday ());
  ACE_Time_Value timeout;
  ACE_Sig_Action no_sigpipe ((ACE_SignalHandler) SIG_IGN);
  ACE_Sig_Action original_action;
  no_sigpipe.register_action (SIGPIPE, &original_action);

  for (;;) {
    if (message_index == 0) {
      timeout = ACE_OS::gettimeofday ();
      timeout += FLUSH_TIMEOUT;
    }
    ACE_Message_Block *mblk = 0;
    if (getq (mblk, &timeout) == -1) {
      if (errno == ESHUTDOWN) {
        if (connector_->reconnect () == -1) break;
        continue;
      } else if (errno != EWOULDBLOCK) break;
      else if (message_index == 0) continue;
    } else {
      if (mblk->size () == 0
          && mblk->msg_type () == ACE_Message_Block::MB_STOP)
        { mblk->release (); break; }
      chunk[message_index] = mblk;
      ++message_index;
    }
    if (message_index >= ACE_IOV_MAX ||
        (ACE_OS::gettimeofday () - time_of_last_send
         >= ACE_Time_Value(FLUSH_TIMEOUT))) {
      if (this->send (chunk, message_index) == -1) break;
      time_of_last_send = ACE_OS::gettimeofday ();
    }
  }

  if (message_index > 0)
    this->send (chunk, message_index);
  no_sigpipe.restore_action (SIGPIPE, original_action);
  return 0;
}
開發者ID:binghuo365,項目名稱:BaseLab,代碼行數:41,代碼來源:AC_Client_Logging_Daemon.cpp

示例7: ACE_DEBUG

 void
 Receiver_exec_i::ccm_activate (void)
 {
   ACE_DEBUG ((LM_DEBUG, "Receiver_exec_i::ccm_activate \n "));
   /// No need to implement anything
   /// Start the timer .
    if (this->reactor ()->schedule_timer(
                this->hello_generator_,  // The callback object
                0,                       // No arguments for this callback
                ACE_Time_Value (1, 0),   // Initial delay
                this->interval_) == -1)  // Time interval
      {
        ACE_ERROR ((LM_ERROR, "Receiver_exec_i::ccm_activate - "
                              "Error scheduling timer\n"));
      }
    else
      {
        ACE_DEBUG ((LM_DEBUG, "Receiver_exec_i::ccm_activate - "
                              "Hello generator is running\n"));
      }
  }
開發者ID:INMarkus,項目名稱:ATCD,代碼行數:21,代碼來源:Receiver_exec.cpp

示例8: server_

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

// Constructor.
TAO_Time_Service_Clerk::TAO_Time_Service_Clerk (int timer_value,
                                                int timer_value_usecs,
                                                const IORS& servers)
  : server_ (servers),
    helper_ (this)
{
  // Schedule the helper to be invoked by the reactor
  // periodically.

  if (TAO_ORB_Core_instance ()->reactor ()->schedule_timer
      (&helper_,
       0,
       ACE_Time_Value::zero,
       ACE_Time_Value(timer_value,timer_value_usecs)) == -1)
    ORBSVCS_ERROR ((LM_ERROR,
                "%p\n",
                "schedule_timer ()"));
}
開發者ID:binary42,項目名稱:OCI,代碼行數:21,代碼來源:TAO_Time_Service_Clerk.cpp

示例9: reuseAddr_test

int reuseAddr_test (void)
{
# if defined ACE_WIN32 || !defined ACE_LACKS_IOCTL
  ACE_SOCK_Dgram_Bcast sock1;
  if (sock1.open(ACE_INET_Addr(UDP_PORT),PF_INET,0,1) != 0)
  {
    ACE_ERROR ((LM_ERROR, ACE_TEXT ("Could not open socket for broadcast on port %d\n"), UDP_PORT ));
    ++result;
  }
  else
  {
    // Keep the socket open for some time
    ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Opened socket on port %d and keep it open for %d sec\n"), UDP_PORT,  SEC_TO_KEEP_SOCKET_OPEN));

    ACE_OS::sleep(ACE_Time_Value(SEC_TO_KEEP_SOCKET_OPEN,0));

    sock1.close();
  }
# endif
  return result;
}
開發者ID:DOCGroup,項目名稱:ACE_TAO,代碼行數:21,代碼來源:Bug_4189_Regression_Test.cpp

示例10: main

int main (int, char* [])
{
    ACE_Reactor reactor;
    Time_Handler* th = new Time_Handler;
    int timer_id[NUMBER_TIMERS];
    for (int i = 0; i < NUMBER_TIMERS; i++)
	{
        timer_id[i] = reactor.schedule_timer(th,
                                              (const void *)i, // argument sent to handle_timeout()
                                              ACE_Time_Value(2 * i + 1)); //set timer to go off with delay
	}
	
    //Cancel the fifth timer before it goes off
    reactor.cancel_timer(timer_id[5]);//Timer ID of timer to be removed
    while (!done)
	{
        reactor.handle_events();
	}

    return 0;
}
開發者ID:air2013,項目名稱:huapuyu,代碼行數:21,代碼來源:main.cpp

示例11: svc

 int svc( ) 
 {
   if ( m_sleep == ACE_Time_Value( 0 ) ) {
     printf( "###### TIMEBOMB Disabled. ######\n" );
     fflush( stdout );
     return 0;
   }
   ACE_Time_Value start = ACE_OS::gettimeofday();
   ACE_Time_Value now = ACE_OS::gettimeofday();
   do {
     ACE_OS::sleep( 1 );
     now = ACE_OS::gettimeofday();
   } while( now - start < m_sleep );
   printf( "####### ERROR: TIMEBOMB WENT OFF, TEST TIMED OUT ########\n" );
   fflush( stdout );
   
   callClientCleanup();
   
   exit( -1 );
   return 0;
 }
開發者ID:leloulight,項目名稱:gemfirexd-oss,代碼行數:21,代碼來源:fw_TimeBomb.hpp

示例12: OUR_DEBUG

int CLogManager::PutLog(_LogBlockInfo* pLogBlockInfo)
{
    ACE_Message_Block* mb = pLogBlockInfo->GetQueueMessage();

    //如果正在重新加載
    if(m_blIsNeedReset == true)
    {
        //回收日誌塊
        m_objLogBlockPool.ReturnBlockInfo(pLogBlockInfo);
        return 0;
    }

    if(mb)
    {
        int msgcount = (int)msg_queue()->message_count();

        if (msgcount >= m_nQueueMax)
        {
            OUR_DEBUG((LM_INFO,"[CLogManager::PutLog] CLogManager queue is full!\n"));
            //回收日誌塊
            m_objLogBlockPool.ReturnBlockInfo(pLogBlockInfo);
            return -1;
        }

        ACE_Time_Value xtime = ACE_OS::gettimeofday()+ACE_Time_Value(0, MAX_MSG_PUTTIMEOUT);

        if(this->putq(mb, &xtime) == -1)
        {
            OUR_DEBUG((LM_ERROR,"[CLogManager::PutLog] CLogManager putq error(%s)!\n", pLogBlockInfo->m_pBlock));
            //回收日誌塊
            m_objLogBlockPool.ReturnBlockInfo(pLogBlockInfo);
            return -1;
        }

        return 0;
    }

    OUR_DEBUG((LM_ERROR,"[CLogManager::PutLog] CLogManager new ACE_Message_Block error!\n"));
    return -1;
}
開發者ID:freeeyes,項目名稱:PSS,代碼行數:40,代碼來源:LogManager.cpp

示例13: ACE_TEST_ASSERT

int
Time_Handler::handle_timeout (const ACE_Time_Value &tv,
                              const void *arg)
{
  long current_count = static_cast<long> (reinterpret_cast<size_t> (arg));
  if (current_count >= 0)
    ACE_TEST_ASSERT (current_count == the_count);

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("[%x] Timer id %d with count #%d|%d timed out at %d!\n"),
              this,
              this->timer_id (),
              the_count,
              current_count,
              tv.sec ()));

  if (current_count == long (ACE_MAX_TIMERS - 1))
    done = 1;
  else if (the_count == long (ACE_MAX_TIMERS - 1))
    {
      done = 1;
      return -1;
    }
  else if (current_count == -1)
    {
#if defined (ACE_HAS_CPP11)
      int result = ACE_Reactor::instance ()->reset_timer_interval (this->timer_id (),
                                                                   std::chrono::seconds {the_count + 1});
#else
      int result = ACE_Reactor::instance ()->reset_timer_interval (this->timer_id (),
                                                                   ACE_Time_Value (the_count + 1));
#endif
      if (result == -1)
        ACE_ERROR ((LM_ERROR,
                    ACE_TEXT ("Error resetting timer interval\n")));
    }
  the_count += (1 + odd);
  return 0;
}
開發者ID:INMarkus,項目名稱:ATCD,代碼行數:39,代碼來源:Reactor_Timer_Test.cpp

示例14: test_registering_all_handlers

static void
test_registering_all_handlers (void)
{
  ACE_Trace t (ACE_TEXT ("test_registering_all_handler"),
               __LINE__,
               ACE_TEXT_CHAR_TO_TCHAR (__FILE__));
  Time_Handler rt[ACE_MAX_TIMERS];
  long t_id[ACE_MAX_TIMERS];

  for (size_t i = 0; i < ACE_MAX_TIMERS; i++)
    {
      t_id[i] =
        ACE_Reactor::instance ()->schedule_timer (&rt[i],
                                                  (const void *) i,
                                                  ACE_Time_Value (2 * i + 1));
      ACE_TEST_ASSERT (t_id[i] != -1);
      rt[i].timer_id (t_id[i]);
    }

  while (!done)
    ACE_Reactor::instance ()->handle_events ();
}
開發者ID:huangyt,項目名稱:foundations.github.com,代碼行數:22,代碼來源:Reactor_Timer_Test.cpp

示例15: ACE_DEBUG

CORBA::Long
Simple_Server_i::test_method (CORBA::Boolean do_callback)
{
  if (do_callback)
    {
      // Scheduling ourselves for doing the callbacks
      if (TAO_debug_level > 0)
      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("Scheduling for callback\n")));

      if (this->orb_->orb_core ()->reactor ()->schedule_timer (this,
                                                               0,
                                                               ACE_Time_Value (1)) == -1)
        {
          ACE_ERROR ((LM_ERROR,
                      "(%P|%t) Can't schedule timers, aborting ..\n"));

          ACE_OS::abort ();
        }
    }

  return 0;
}
開發者ID:OspreyHub,項目名稱:ATCD,代碼行數:23,代碼來源:test_i.cpp


注:本文中的ACE_Time_Value函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。