本文整理汇总了C++中ACE_Reactor::schedule_timer方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_Reactor::schedule_timer方法的具体用法?C++ ACE_Reactor::schedule_timer怎么用?C++ ACE_Reactor::schedule_timer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_Reactor
的用法示例。
在下文中一共展示了ACE_Reactor::schedule_timer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
int
Time_Handler::svc (void)
{
ACE_Reactor *r = ACE_Reactor::instance ();
ACE_ASSERT (r->cancel_timer (this->timer_id_[2]) == 1);
this->timer_id_[2] = Time_Handler::TIMER_CANCELLED;
this->timer_id_[1] = r->schedule_timer(this,
(const void *) 1,
ACE_Time_Value (2));
// This one may get the callback before we return, so serialize.
this->lock_.acquire ();
this->timer_id_[0] = r->schedule_timer(this,
(const void *) 0,
ACE_Time_Value (0, -5));
this->lock_.release ();
ACE_OS::sleep(3);
this->timer_id_[5] = r->schedule_timer(this,
(const void *)5,
ACE_Time_Value (10));
this->timer_id_[6] = r->schedule_timer(this,
(const void *)6,
ACE_Time_Value (12));
ACE_ASSERT (r->cancel_timer (this->timer_id_[4]) == 1);
this->timer_id_[4] = Time_Handler::TIMER_CANCELLED;
return 0;
}
示例2:
void
Sender_exec_i::start (void)
{
ACE_Reactor* reactor = 0;
::CORBA::Object_var ccm_object = this->ciao_context_->get_CCM_object();
if (!::CORBA::is_nil (ccm_object.in ()))
{
::CORBA::ORB_var orb = ccm_object->_get_orb ();
if (!::CORBA::is_nil (orb.in ()))
{
reactor = orb->orb_core ()->reactor ();
}
}
if (reactor)
{
// calculate the interval time
long const usec = 1000000 / this->rate_;
if (reactor->schedule_timer (
this->ticker_,
0,
ACE_Time_Value (3, usec),
ACE_Time_Value (0, usec)) == -1)
{
ACE_ERROR ((LM_ERROR, ACE_TEXT ("Sender_exec_i::start : ")
ACE_TEXT ("Error scheduling timer")));
}
}
else
{
throw ::CORBA::INTERNAL ();
}
}
示例3: dtv
int
ImR_Activator_i::handle_exit (ACE_Process * process)
{
if (debug_ > 0)
{
ORBSVCS_DEBUG
((LM_DEBUG,
ACE_TEXT ("Process %d exited with exit code %d, delay = %d\n"),
process->getpid (), process->return_value (), this->induce_delay_));
}
if (this->induce_delay_ > 0 && this->active_check_pid_ == ACE_INVALID_PID)
{
ACE_Reactor *r = this->orb_->orb_core()->reactor();
ACE_Time_Value dtv (0, this->induce_delay_ * 1000);
pid_t pid = process->getpid();
Act_token_type token = static_cast<Act_token_type>(pid);
r->schedule_timer (this, reinterpret_cast<void *>(token), dtv );
}
else
{
this->handle_exit_i (process->getpid());
}
return 0;
}
示例4: doit
void
device_averager::activate()
{
doit( device_state::command_initialize );
ACE_Reactor * reactor = acewrapper::singleton::ReactorThread::instance()->get_reactor();
reactor->schedule_timer( this, 0, ACE_Time_Value(1), ACE_Time_Value(1) );
}
示例5: dtv
int
ImR_Activator_i::handle_exit (ACE_Process * process)
{
if (debug_ > 0)
{
ORBSVCS_DEBUG
((LM_DEBUG,
ACE_TEXT ("Process %d exited with exit code %d\n"),
process->getpid (), process->return_value ()));
}
if (this->induce_delay_ > 0)
{
ACE_Reactor *r = this->orb_->orb_core()->reactor();
ACE_Time_Value dtv (0, this->induce_delay_ * 1000);
pid_t pid = process->getpid();
#if (ACE_SIZEOF_VOID_P == 8)
ACE_INT64 token = static_cast<ACE_INT64>(pid);
#else
ACE_INT32 token = static_cast<ACE_INT32>(pid);
#endif
r->schedule_timer (this, reinterpret_cast<void *>(token), dtv );
}
else
{
this->handle_exit_i (process->getpid());
}
return 0;
}
示例6:
void
Time_Handler::setup (void)
{
ACE_Reactor *r = ACE_Reactor::instance ();
this->timer_id_[2] = r->schedule_timer (this,
(const void *) 2,
ACE_Time_Value (3));
this->timer_id_[3] = r->schedule_timer (this,
(const void *) 3,
ACE_Time_Value (4));
this->timer_id_[4] = r->schedule_timer (this,
(const void *) 4,
ACE_Time_Value (5));
return;
}
示例7: reactor
int
run_main (int, ACE_TCHAR *[])
{
ACE_START_TEST (ACE_TEXT ("Timer_Cancellation_Test"));
ACE_Reactor reactor (new ACE_TP_Reactor,
1);
Deadlock deadlock;
deadlock.reactor (&reactor);
Event_Handler handler (deadlock);
// Scheduler a timer to kick things off.
reactor.schedule_timer (&handler,
0,
ACE_Time_Value (1));
// Run the event loop for a while.
ACE_Time_Value timeout (4);
reactor.run_reactor_event_loop (timeout);
ACE_END_TEST;
return 0;
}
示例8: clk_tck
void
Client_Peer::crash(void)
{
Crasher * crasher = new Crasher;
ACE_Time_Value clk_tck (0, Clock_Ticks::get_usecs_per_tick ());
ACE_Reactor * reactor = this->orb_->orb_core()->reactor();
reactor->schedule_timer(crasher, 0, clk_tck);
}
示例9: defined
CORBA::Boolean
ImR_Activator_i::kill_server (const char* name, CORBA::Long lastpid, CORBA::Short signum)
{
if (debug_ > 1)
ORBSVCS_DEBUG((LM_DEBUG,
"ImR Activator: Killing server <%C>, lastpid = %d\n",
name, lastpid));
pid_t lpid = static_cast<pid_t>(lastpid);
pid_t pid = 0;
bool found = false;
int result = -1;
for (ProcessMap::iterator iter = process_map_.begin();
!found && iter != process_map_.end (); iter++)
{
if (iter->item () == name)
{
pid = iter->key ();
found = pid == lpid;
}
}
if (!found && pid == 0)
{
pid = lpid;
}
#if defined (ACE_WIN32)
found = false; // sigchild apparently doesn't work on windows
#endif
if (pid != 0)
{
result =
#if !defined (ACE_WIN32)
(signum != 9) ? ACE_OS::kill (pid, signum) :
#endif
ACE::terminate_process (pid);
if (this->running_server_list_.remove (name) == 0)
{
this->dying_server_list_.insert (name);
}
if (debug_ > 1)
ORBSVCS_DEBUG((LM_DEBUG,
"ImR Activator: Killing server <%C> "
"signal %d to pid %d, found %d, this->notify_imr_ %d, result = %d\n",
name, signum, static_cast<int> (pid), found, this->notify_imr_, result));
if (!found && result == 0 && this->notify_imr_)
{
this->process_map_.bind (pid, name);
ACE_Reactor *r = this->orb_->orb_core()->reactor();
Act_token_type token = static_cast<Act_token_type>(pid);
r->schedule_timer (this, reinterpret_cast<void *>(token), ACE_Time_Value ());
}
}
return result == 0;
}
示例10: xreactor
int
main (int argc, char**argv)
{
// The worlds most useless user interface
Widget top_level = XtVaAppInitialize (NULL,
"buttontest",
NULL,
0,
&argc,
argv,
NULL,
NULL);
Widget button = XmCreatePushButton (top_level,
"change",
0,
0);
XtManageChild (button);
XtAddCallback (button,
XmNactivateCallback,
ActivateCB,
NULL);
// A reactor beastie.
ACE_XtReactor xreactor (XtWidgetToApplicationContext (top_level));
ACE_Reactor reactor (&xreactor);
// Print a message when data is recv'd on stdin...
ACE_Event_Handler *stdin_;
ACE_NEW_RETURN (stdin_,
Stdin (new Stdout (&reactor)),
-1);
reactor.register_handler (stdin_,
ACE_Event_Handler::READ_MASK);
// Print a message every 10 seconds.
if (reactor.schedule_timer (stdin_, 0,
ACE_Time_Value (10),
ACE_Time_Value (10)) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
"%p\n",
"schedule_timer"),
-1);
// Show the top_level widget.
XtRealizeWidget (top_level);
// Demonstrate Reactor/Xt event loop unification.
XtAppMainLoop (XtWidgetToApplicationContext (top_level));
return 0;
}
示例11: pause
void pause()
{
// get the reactor and set the timer.
CORBA::ORB_var orb = TheServiceParticipant->get_ORB ();
ACE_Reactor* reactor ;
reactor = orb->orb_core()->reactor();
if (reactor->schedule_timer(this,
0,
ACE_Time_Value(0,1)) == -1)
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT("(%P|%t) ERROR: PauseReactor, ")
ACE_TEXT(" %p. \n"), "schedule_timer"));
}
}
示例12: lock
bool
iTaskManager::manager_initialize()
{
if ( timerHandler_ == 0 ) {
acewrapper::scoped_mutex_t<> lock( mutex_ );
if ( timerHandler_ == 0 ) {
// initialize timer
timerHandler_ = new acewrapper::EventHandler< acewrapper::TimerReceiver<internal::TimeReceiver> >();
ACE_Reactor * reactor = iTaskManager::instance()->reactor();
reactor->schedule_timer( timerHandler_, 0, ACE_Time_Value(3), ACE_Time_Value(3) );
}
// activate task
pTask_->open();
return true;
}
return false;
}
示例13: defined
CORBA::Boolean
ImR_Activator_i::kill_server (const char* name, CORBA::Long lastpid, CORBA::Short signum)
{
if (debug_ > 1)
ORBSVCS_DEBUG((LM_DEBUG,
"ImR Activator: Killing server <%s>...\n",
name));
pid_t pid = static_cast<pid_t>(lastpid);
bool found = false;
int result = -1;
for (ProcessMap::iterator iter = process_map_.begin();
!found && iter != process_map_.end (); iter++)
{
if (iter->item () == name)
{
pid = iter->key ();
found = true;
}
}
#if defined (ACE_WIN32)
found = false; // sigchild apparently doesn't work on windows
#endif
if (pid != 0)
{
result = (signum != 9) ? ACE_OS::kill (pid, signum)
: ACE::terminate_process (pid);
if (debug_ > 1)
ORBSVCS_DEBUG((LM_DEBUG,
"ImR Activator: Killing server <%s> "
"signal %d to pid %d, result = %d\n",
name, signum, pid, result));
if (!found && result == 0 && this->notify_imr_)
{
this->process_map_.bind (pid, name);
#if (ACE_SIZEOF_VOID_P == 8)
ACE_INT64 token = static_cast<ACE_INT64>(pid);
#else
ACE_INT32 token = static_cast<ACE_INT32>(pid);
#endif
ACE_Reactor *r = this->orb_->orb_core()->reactor();
r->schedule_timer (this, reinterpret_cast<void *>(token), ACE_Time_Value ());
}
}
return result == 0;
}
示例14: timeout_interval
int
Heartbeat_Application::register_for_timeouts (void)
{
// Schedule timeout every 0.5 seconds, for sending heartbeat events.
ACE_Time_Value timeout_interval (0, 500000);
ACE_Reactor *reactor = this->orb_->orb_core ()->reactor ();
if (!reactor
|| reactor->schedule_timer (&this->timeout_handler_, 0,
timeout_interval,
timeout_interval) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"Heartbeat_Application::register_for_timeouts - "
"cannot schedule timer\n"),
-1);
}
return 0;
}
示例15: timeout
int
TAO_Acceptor::handle_accept_error (ACE_Event_Handler* base_acceptor)
{
if (errno == EMFILE || errno == ENFILE)
{
if (TAO_debug_level > 0)
TAOLIB_DEBUG ((LM_DEBUG, "TAO (%P|%t) - "
"TAO_Acceptor::handle_accept_error - "
"Too many files open\n"));
// If the user has decided to stop accepting when the file handles
// run out, just return -1;
if (this->error_retry_delay_ == 0)
return -1;
// Get the reactor. If there isn't one, which isn't very likely,
// then just return -1.
ACE_Reactor* reactor = base_acceptor->reactor ();
if (reactor == 0)
return -1;
// So that the reactor doesn't completely remove this handler from
// the reactor, register it with the except mask. It should be
// removed in the timer handler.
reactor->register_handler (base_acceptor,
ACE_Event_Handler::EXCEPT_MASK);
// Remove the handler so that the reactor doesn't attempt to
// process this handle again (and tightly spin).
reactor->remove_handler (base_acceptor,
ACE_Event_Handler::ACCEPT_MASK |
ACE_Event_Handler::DONT_CALL);
// Schedule a timer so that we can resume the handler in hopes
// that some file handles have freed up.
ACE_Time_Value timeout (this->error_retry_delay_);
reactor->schedule_timer (base_acceptor, 0, timeout);
}
// We want to keep accepting in all other situations.
return 0;
}