本文整理汇总了C++中ACE_Reactor::purge_pending_notifications方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_Reactor::purge_pending_notifications方法的具体用法?C++ ACE_Reactor::purge_pending_notifications怎么用?C++ ACE_Reactor::purge_pending_notifications使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_Reactor
的用法示例。
在下文中一共展示了ACE_Reactor::purge_pending_notifications方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: t
static int
run_notify_purge_test (void)
{
int status;
ACE_Reactor *r = ACE_Reactor::instance ();
{
Purged_Notify n1;
Purged_Notify *n2;
ACE_NEW_RETURN (n2, Purged_Notify, -1);
auto_ptr<Purged_Notify> ap (n2);
// First test:
// Notify EXCEPT, and purge ALL
r->notify (&n1); // the mask is EXCEPT_MASK
status = r->purge_pending_notifications (&n1);
if (status == -1 && errno == ENOTSUP)
return 0; // Select Reactor w/o ACE_HAS_REACTOR_NOTIFICATION_QUEUE
if (status != 1)
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("Purged %d notifies; expected 1\n"),
status));
// Second test:
// Notify READ twice, and WRITE once, and purge READ and WRITE - should purge 3 times.
r->notify (&n1, ACE_Event_Handler::READ_MASK);
r->notify (&n1, ACE_Event_Handler::READ_MASK);
r->notify (&n1, ACE_Event_Handler::WRITE_MASK);
status = r->purge_pending_notifications
(&n1, ACE_Event_Handler::READ_MASK | ACE_Event_Handler::WRITE_MASK);
if (status != 3)
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("Purged %d notifies; expected 3\n"),
status));
// Third test:
// Notify READ on 2 handlers, and purge READ|WRITE on all handlers. Should purge 2
r->notify (&n1, ACE_Event_Handler::READ_MASK);
r->notify (n2, ACE_Event_Handler::READ_MASK);
status = r->purge_pending_notifications
(0, ACE_Event_Handler::READ_MASK | ACE_Event_Handler::WRITE_MASK);
if (status != 2)
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("Purged %d notifies; expected 2\n"),
status));
// Forth test:
// Notify EXCEPT and WRITE, purge READ. Should not purge
r->notify (&n1); // the mask is EXCEPT_MASK
r->notify (&n1, ACE_Event_Handler::WRITE_MASK);
status = r->purge_pending_notifications
(&n1, ACE_Event_Handler::READ_MASK);
if (status != 0)
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("Purged %d notifies; expected 0\n"),
status));
// Fifth test:
r->notify (n2);
// The destructor of the event handler no longer removes the
// notifications. It is the application's responsability to do
// so.
r->purge_pending_notifications(n2,
ACE_Event_Handler::ALL_EVENTS_MASK);
r->purge_pending_notifications(&n1,
ACE_Event_Handler::ALL_EVENTS_MASK);
}
ACE_Time_Value t (1);
status = r->handle_events (t); // Should be nothing to do, and time out
return status < 0 ? 1 : 0; // Return 0 for all ok, else error
}