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


C++ ACE_Time_Value::msec方法代码示例

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


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

示例1:

  bool
  Eager_Transport_Queueing_Strategy::timer_check (
    const TAO::BufferingConstraint &buffering_constraint,
    const ACE_Time_Value &current_deadline,
    bool &set_timer,
    ACE_Time_Value &new_deadline) const
  {
    set_timer = false;

    if (!ACE_BIT_ENABLED (buffering_constraint.mode,
                          TAO::BUFFER_TIMEOUT))
      {
        return false;
      }

    // Compute the next deadline...
    ACE_Time_Value const now = ACE_OS::gettimeofday ();
    ACE_Time_Value timeout =
      this->time_conversion (buffering_constraint.timeout);
    new_deadline = now + timeout;

    // Check if the new deadline is more stringent, or if the deadline
    // has expired and thus must be reset anyway.
    if (current_deadline > new_deadline
        || current_deadline < now)
      {
        set_timer = true;
      }

    // ... if there is no deadline we don't want to schedule output (the
    // deadline will be set because set_timer is set to 1 in that case).
    // If there is a deadline but but it has not been reached, we
    // don't want to schedule any output either...
    if (current_deadline == ACE_Time_Value::zero
        || current_deadline >= now)
      {
        return false;
      }

    if (TAO_debug_level > 6)
      {
        TAOLIB_DEBUG ((LM_DEBUG,
                    "TAO (%P|%t) - TAO_Eager_Buffering_Sync_Strategy::timer_check, "
                    "Now = %u, Current = %u, New = %u\n",
                    now.msec (), current_deadline.msec (),
                    new_deadline.msec ()));
      }

    return true;
  }
开发者ID:asdlei00,项目名称:ACE,代码行数:50,代码来源:Messaging_Queueing_Strategies.cpp

示例2: main

int main()
{
    ACE::init();
    fprintf(stderr, "Starting timing test\n");

    ACE_Time_Value now1,now2;

    ACE_High_Res_Timer timer;
    ACE_Profile_Timer profiler;
    ACE_Time_Value sleep;
    ACE_Time_Value elapsed;
    double avErrors[wTimes];
    
    int i,k;

    for(i=0;i<wTimes;i++)
        avErrors[i]=0;

    for(i=0;i<iterations;i++)
        {
            double req;
            double time;
            for(k=0;k<wTimes;k++)
                {
                    req=sleepT[k];
                    sleep.msec(sleepT[k]);
                    
                    now1 = ACE_OS::gettimeofday ();
                    
                    //ACE_OS::sleep(sleep);
                    usleep(sleep.sec()*1000000+sleep.usec()-1000);

                    now2 = ACE_OS::gettimeofday ();

                    time=(now2.sec()-now1.sec())*1000;
                    time+=(now2.usec()-now1.usec())/1000;
                    avErrors[k]+=fabs(req-time)/iterations;
                    fprintf(stderr, "*");
                }
            fprintf(stderr, "Completed %d out of %d\n", i+1, iterations);
        }

    for(i=0;i<wTimes;i++)
        {
            sleep.msec(sleepT[i]);
            fprintf(stderr, "Req %us and %u[ms], average error %.3lf\n", (unsigned int)sleep.sec(), (unsigned int) sleep.usec()/1000, avErrors[i]);
        }

    ACE::fini();
}
开发者ID:AbuMussabRaja,项目名称:yarp,代码行数:50,代码来源:main.cpp

示例3:

int KSG_Reactor_Work_Thr::do_task2(KSG_Reactor_Scheduler::SERVER_HANDLER *handle)
{
	int ret;
	ACE_Time_Value estimated = ACE_OS::gettimeofday() - handle->request_time_;
	long t = estimated.msec();
	if(t > handle->request_->default_timeout())
	{
		// 更新业务处理完成时间
		ACE_DEBUG((LM_ERROR,"对方请求已经等待超时...[%d]ms",handle->request_->default_timeout()));
		// 通知句柄以处理完成
		ret = -1;
	}
	else
	{
		ret = handle->request_->process_request(handle);
	}
	handle->mblk_->release();
	handle->mblk_ = NULL;
	if(ret == -1)
	{
		// 请求有问题,需要关闭
		ACE_DEBUG((LM_TRACE,"发送应答失败,关闭请求[%08X]",handle->handle_));
		//ACE_OS::closesocket(handle->handle_);
		//this->schd_->reactor()->remove_handler(handle->handle_,ACE_Event_Handler::ALL_EVENTS_MASK);

		this->schd_->close_error_socket(handle->handle_);
	}
	// 释放 handle
	schd_->free_handle(handle);
	
	// 更新业务处理完成时间
	return ret;
}
开发者ID:nykma,项目名称:ykt4sungard,代码行数:33,代码来源:reactor_def.cpp

示例4: run_receiver

/*\brief Receive single datagram
  \note The function employes dgram_port and dgram_recv_timeout variables
  \retval -1 if not received,
  \retval 0  received a datagrams
*/
int run_receiver ()
{
  ACE_DEBUG
    ((LM_INFO,
      ACE_TEXT ("Receiving datagrams from port %d with timeout %d ms\n"),
      dgram_port, dgram_recv_timeout.msec ()));

  ACE_SOCK_Dgram socket;
  ACE_INET_Addr  remote ;
  static char    dgram_buffer[BUFSIZ];

  if (socket.open (ACE_INET_Addr (dgram_port)) != -1)
    if (socket.recv (dgram_buffer, sizeof (dgram_buffer),
                     remote, 0, &dgram_recv_timeout) > 0)
      {
        ACE_DEBUG ((LM_INFO, ACE_TEXT ("%C received\n"), dgram_buffer));
        return 0;
      }
    else
      {
        ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"),
                           ACE_TEXT ("Cannot receive datagrams")), -1);
      }
  else
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT ("%p: %d\n"),
                         ACE_TEXT ("Cannot open broadcast socket on port"), dgram_port), -1);
    }
}
开发者ID:esohns,项目名称:ATCD,代码行数:35,代码来源:SOCK_Dgram_Bcast_Test.cpp

示例5: countdown

int
ACE_WIN32_Proactor::handle_events (ACE_Time_Value &wait_time)
{
  // Decrement <wait_time> with the amount of time spent in the method
  ACE_Countdown_Time countdown (&wait_time);
  return this->handle_events (wait_time.msec ());
}
开发者ID:aresxii,项目名称:aresxii,代码行数:7,代码来源:WIN32_Proactor.cpp

示例6: ACE_TMAIN

int ACE_TMAIN (int, ACE_TCHAR *[])
{
  Manager tp;
  tp.activate ();

  // Wait for a moment every time you send a message.
  ACE_Time_Value tv;
  tv.msec (100);

  ACE_Message_Block *mb = 0;
  for (int i = 0; i < 30; i++)
    {
      ACE_NEW_RETURN
        (mb, ACE_Message_Block(sizeof(int)), -1);

      ACE_OS::memcpy (mb->wr_ptr (), &i, sizeof(int));

      ACE_OS::sleep (tv);

      // Add a new work item.
      tp.putq (mb);
    }

  ACE_Thread_Manager::instance ()->wait ();
  return 0;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:26,代码来源:ThreadPool.cpp

示例7: run_auto_test

/* \brief Just runs automatic tests

Function sends a number of datagrams, spawns child thread or process and
tries to receive at least one datagram.
\retval 0 datagram was received
\retval -1 datagram was not received
*/
int run_auto_test (const ACE_TCHAR *prog_name)
{
#if defined (ACE_HAS_PROCESS_SPAWN)
  ACE_DEBUG ((LM_INFO, ACE_TEXT ("Running auto_tests in process mode\n")));

  ACE_Process_Options opts;
  pid_t child_pid;
  opts.command_line (ACE_TEXT ("%s -p %d -t %d -a -r"),
                     prog_name, dgram_port, dgram_recv_timeout.msec ());
  if ((child_pid = ACE_Process_Manager::instance ()->spawn (opts)) == -1)
    ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("spawn_n()")), -1);

#elif defined (ACE_HAS_THREADS)
  ACE_UNUSED_ARG (prog_name);
  ACE_DEBUG ((LM_INFO, ACE_TEXT ("Running auto_tests in thread mode\n")));
  if (ACE_Thread_Manager::instance ()->spawn (run_thread_receiver) == -1)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("%p\n"),
                       ACE_TEXT ("spawn_n ()")), -1);
#else
  ACE_ERROR_RETURN ((LM_ERROR,
                     ACE_TEXT ("Cannot run in auto_test mode without fork or threads.\n")),
                      -1);
#endif /* defined (ACE_HAS_PROCESS_SPAWN) */

  ACE_DEBUG ((LM_INFO,
              ACE_TEXT ("Sending datagrams on port %d in auto_test mode\n"),
              dgram_port));

  ACE_SOCK_Dgram_Bcast socket;

  if (socket.open (ACE_Addr::sap_any) != -1)
    {
      // send datagrams until child finishes
      while (1)
        {
          send_datagram (socket, dgrams_no--);
          ACE_Time_Value child_timeout (1);
#if defined (ACE_HAS_PROCESS_SPAWN)

          if (ACE_Process_Manager::instance ()->wait (child_pid,
                                                      child_timeout,
                                                      &receiver_exit_code) == child_pid)
            break;
#else /* ACE_HAS_THREADS */
          // sleep 1 second or wait for child thread
          child_timeout += ACE_OS::gettimeofday () ;
          if (ACE_Thread_Manager::instance ()->wait (&child_timeout) == 0)
            break;
#endif
        }
      socket.close ();
      ACE_DEBUG ((LM_INFO, ACE_TEXT ("Child finished with %d exit code\n"),
                  receiver_exit_code));
    }
  else
    ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"),
                       ACE_TEXT ("Cannot open broadcast socket")), -1);
  return (receiver_exit_code);
}
开发者ID:esohns,项目名称:ATCD,代码行数:67,代码来源:SOCK_Dgram_Bcast_Test.cpp

示例8: timeout

int
ACE_TMAIN (int, ACE_TCHAR*[])
{
  // Manage memory automagically.
  ACE_Reactor_Impl *impl = new ACE_Msg_WFMO_Reactor;
  auto_ptr<ACE_Reactor> reactor (new ACE_Reactor (impl, 1));
  ACE_Reactor::instance (reactor.get ());

  Event_Handler event_handler;
  global_event_handler = &event_handler;

  event_handler.iterations_ = 5;
  int result =
    ACE_Reactor::instance ()->register_handler (&event_handler,
                                                event_handler.handle_.handle ());
  ACE_ASSERT (result == 0);

  ACE_Time_Value timeout (1);
  result =
    ACE_Utils::truncate_cast<int> (
      ::SetTimer (0,                         // handle of window for timer messages
                  0,                             // timer identifier
                  timeout.msec (),               // time-out value
                  (TIMERPROC) &timer_callback)); // address of timer procedure

  ACE_ASSERT (result != 0);

  ACE_Reactor::run_event_loop ();

  return 0;
}
开发者ID:helixum,项目名称:wow-cata,代码行数:31,代码来源:Window_Messages.cpp

示例9: joinSiblingPeer

bool LeafClientHandler::joinSiblingPeer(
        int type,
        UUIDPtr& uuid,
        CellIDPtr& cellID,
        CellIDPtr& parentCellID,
        EndpointPtr& endpoint,
        SAPInfoPtr& discoverySAP,
        SAPInfoPtr& meshSAP,
        SAPInfoPtr& ftSAP
        ) {
    ACE_GUARD_RETURN(ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, m_lock, false);
    JoinMeshPacket *packet = 0;
    UUIDPtr runtimeUUID;
    m_mesh->getUUID(runtimeUUID);
    if (m_debugLeafClientHandler) {
        ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)LeafClientHandler:joinSiblingPeer(): PEER(%s,%s)\n"),
                runtimeUUID->toString().c_str(),
                cellID->toString().c_str()));
    }

    UUIDPtr srcCellID(new CellID(*(m_cellID.get())));
    UUIDPtr dstCellID(new CellID(*(m_cellID.get())));
    packet = new JoinMeshPacket(m_uuid,
            srcCellID,
            runtimeUUID,
            dstCellID,
            0,
            type,
            uuid,
            cellID,
            parentCellID,
            endpoint,
            discoverySAP,
            meshSAP,
            ftSAP
            );
    RequestEngine<SthenoPacket*>::RequestPtr* request = sendRequest(packet, 0);
    if (request == 0) {
        ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)ERROR: LeafClientHandler:joinSiblingPeer() - Request failed\n")));
        return 0;
    }
    //ACE_DEBUG((LM_DEBUG,ACE_TEXT("(%t|%T)Before wait future\n");
    ACE_Time_Value timeout = ACE_OS::gettimeofday();
    ACE_Time_Value delta;
    delta.msec(JOIN_CELL_TIMEOUT_MS);
    timeout += delta;
    list<SthenoPacket*>* results = request->get()->waitFuture(0);
    ACE_DEBUG((LM_DEBUG,ACE_TEXT("(%t|%T) LeafClientHandler:joinSiblingPeer() After future\n")));
    if (results != 0 && results->size() > 0) {
        JoinMeshReplyPacket* replyPacket = static_cast<JoinMeshReplyPacket*> (results->front());
        bool status = replyPacket->getJoinResult();
        ListHelper<SthenoPacket*>::deleteList(results);
        return status;
    } else {
        ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)ERROR: LeafClientHandler::joinSiblingPeer() - No response\n")));
    }

    return false;
}
开发者ID:edenduthie,项目名称:rtft1,代码行数:59,代码来源:LeafClientHandler.cpp

示例10:

void yarp::os::impl::fromDouble(ACE_Time_Value &v, double x,int unit) {
#ifdef YARP_HAS_ACE
        v.msec(static_cast<int>(x*1000/unit+0.5));
#else
        v.tv_usec = static_cast<int>(x*1000000/unit+0.5) % 1000000;
        v.tv_sec = static_cast<int>(x/unit);
#endif
}
开发者ID:johnty,项目名称:libYARP_OS,代码行数:8,代码来源:RFModule.cpp

示例11: max

  Miro::PanPositionIDL
  PanTiltImpl::currentPosition()
  {
    Miro::PanPositionIDL position;
    position.angle = actPosition;
    position.accuracy = Miro::deg2Rad(3.);

    if (prvPanning()) {
      position.accuracy += max( Miro::deg2Rad(7.), accuracy );

#ifdef WEGOTIT
      ACE_Time_Value delta = ACE_OS::gettimeofday() - timeLastSet;

      position.angle = lastPosition;
      position.accuracy = Miro::deg2Rad(10.);

      double blur = Miro::deg2Rad(0.04 * delta.msec());

      int t_msec = (int)fabs((nextPosition - lastPosition) * 300);

      // sind wir noch in der Bewegung?
      if (delta < ACE_Time_Value(t_msec / 1000 , (t_msec % 1000) * 1000)) {
	position.angle += (nextPosition - lastPosition) * (double)delta.msec() / (double)t_msec;
      }
      else {
	position.angle = nextPosition;
	blur *= 1 - (delta.msec() - t_msec) / 400;
      }
      position.accuracy += blur;
#endif

    }

#ifdef LETSTILTAGAIN
    if (!prvTilting())
      position.ti(!prvTilting())
      position.tiltvalue = nextPosition.tiltvalue;
    else
      position.tiltvalue = (lastPosition.panvalue <= nextPosition.panvalue)?
	lastPosition.panvalue + (now - timeLastSet).msec() * params_.tiltRadPerMSec :
	lastPosition.panvalue - (now - timeLastSet).msec() * params_.tiltRadPerMSec;
#endif

    return position;
  }
开发者ID:BackupTheBerlios,项目名称:miro-middleware-svn,代码行数:45,代码来源:SparrowPanTiltImpl.cpp

示例12: 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

示例13: wait

static void *
worker (void *)
{
  for (int iterations = 1;
       iterations <= n_iterations;
       iterations++)
    {
#if !defined (ACE_HAS_STHREADS) && !defined (ACE_HAS_POSIX_SEM)
      ACE_Time_Value wait (0,
                           iterations * 1000 * 100);  // Wait 'iter' msec
      ACE_Time_Value tv = ACE_OS::gettimeofday () + wait;

      if (s.acquire (tv))
        ++timeouts;
      else
        {
          ACE_Time_Value diff = ACE_OS::gettimeofday ();
          diff = diff - tv;       // tv should have been reset to time acquired
          if (diff.msec () > ACE_ALLOWED_SLACK)
            {
              ACE_DEBUG ((LM_DEBUG,
                          ACE_TEXT ("Acquire fails time reset test\n")));
              ACE_DEBUG ((LM_DEBUG,
                          ACE_TEXT ("Diff btw now and returned time: %d ms\n"),
                          diff.msec ()));
              test_result = 1;
            }
          // Hold the lock for a while.
          ACE_OS::sleep (ACE_Time_Value (0,
                                         (ACE_OS::rand () % 1000) * 1000));
          s.release ();
        }
#else
      s.acquire ();
      // Hold the lock for a while.
      ACE_OS::sleep (ACE_Time_Value (0,
                                     (ACE_OS::rand () % 1000) * 1000));
      s.release ();
#endif /* ACE_HAS_STHREADS && ACE_HAS_POSIX_SEM */
      ACE_Thread::yield ();
    }

  return 0;
}
开发者ID:BackupTheBerlios,项目名称:pyasynchio-svn,代码行数:44,代码来源:Semaphore_Test.cpp

示例14: 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

示例15: wait

static void *
worker (void *)
{
  for (int iterations = 1;
       iterations <= n_iterations;
       iterations++)
    {
      //FUZZ: disable check_for_lack_ACE_OS
      ACE_Time_Value wait (0,
                           iterations * 1000 * 100);  // Wait 'iter' msec
      //FUZZ: enable check_for_lack_ACE_OS

      ACE_Time_Value tv = ACE_OS::gettimeofday () + wait;
      if (evt.wait (&tv) == -1)
      {
          // verify that we have ETIME
          if (ACE_OS::last_error() != ETIME)
            {
              ACE_ERROR ((LM_ERROR,
                          ACE_TEXT ("%p\n"),
                          ACE_TEXT ("Worker should be ETIME but is")));
            }
          else
            ++timeouts;
          ACE_Time_Value diff = ACE_OS::gettimeofday ();
          diff = diff - tv;       // tv should have been reset to time acquired
          long diff_msec = diff.msec ();

          if (diff_msec > ACE_ALLOWED_SLACK)
            {
              ACE_ERROR ((LM_ERROR,
                          ACE_TEXT ("Acquire fails time reset test\n")));
              ACE_ERROR ((LM_ERROR,
                          ACE_TEXT ("Diff btw now and returned time: %d ms; ")
                          ACE_TEXT ("%d allowed\n"),
                          (int)diff_msec,
                          (int)ACE_ALLOWED_SLACK));
              test_result = 1;
            }
          // Hold the lock for a while.
          ACE_OS::sleep (ACE_Time_Value (0,
                                         (ACE_OS::rand () % 1000) * 1000));
          evt.signal ();
      }

      ACE_Thread::yield ();
    }

  return 0;
}
开发者ID:chrrrisw,项目名称:ACE,代码行数:50,代码来源:Auto_Event_Test.cpp


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