static bool
test_reactor_dispatch_order (ACE_Reactor &reactor)
{
    Handler handler (reactor);
    if (!handler.ok_)
    {
        ACE_ERROR ((LM_ERROR, ACE_TEXT ("Error initializing test; abort.\n")));
        return false;
    }

    bool ok_to_go = true;

    // This should trigger a call to <handle_input>.
    ssize_t result =
        ACE::send_n (handler.pipe_.write_handle (),
                     message,
                     ACE_OS::strlen (message));
    if (result != ssize_t (ACE_OS::strlen (message)))
    {
        ACE_ERROR ((LM_ERROR, ACE_TEXT ("Handler sent %b bytes; should be %B\n"),
                    result, ACE_OS::strlen (message)));
        ok_to_go = false;
    }

    // This should trigger a call to <handle_timeout>.
    if (-1 == reactor.schedule_timer (&handler,
                                      0,
                                      ACE_Time_Value (0)))
    {
        ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("schedule_timer")));
        ok_to_go = false;
    }

    // Suspend the handlers - only the timer should be dispatched
    ACE_Time_Value tv (1);
    reactor.suspend_handlers ();
    reactor.run_reactor_event_loop (tv);

    // only the timer should have fired
    if (handler.dispatch_order_ != 2)
    {
        ACE_ERROR ((LM_ERROR, ACE_TEXT ("Incorrect number fired %d\n"),
                    handler.dispatch_order_));
        ok_to_go = false;
    }

    // Reset the dispatch_order_ count and schedule another timer
    handler.dispatch_order_ = 1;
    if (-1 == reactor.schedule_timer (&handler,
                                      0,
                                      ACE_Time_Value (0)))
    {
        ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("schedule_timer")));
        ok_to_go = false;
    }

    // Resume the handlers - things should work now
    reactor.resume_handlers ();

    if (ok_to_go)
    {
        reactor.run_reactor_event_loop (tv);
    }

    if (0 != reactor.remove_handler (handler.pipe_.read_handle (),
                                     ACE_Event_Handler::ALL_EVENTS_MASK |
                                     ACE_Event_Handler::DONT_CALL))
        ACE_ERROR ((LM_ERROR,
                    ACE_TEXT ("%p\n"),
                    ACE_TEXT ("remover_handler pipe")));

    if (handler.dispatch_order_ != 4)
    {
        ACE_ERROR ((LM_ERROR, ACE_TEXT ("Incorrect number fired %d\n"),
                    handler.dispatch_order_));
        ok_to_go = false;
    }

    return ok_to_go;
}