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 }