Debugging the C++npv2_reactor_log_server program, the main function creates a Ace_reactor object, ace_reactor_impl its member variable *implementation_ in its constructor, and assigns a value of Ace_ Wfmo_reactor object, so the Ace_wfmo_reactor object needs to be constructed.
The Ace_wfmo_reactor constructor calls its member function open, which initializes the member variable notify_handler_ to the Ace_wfmo_reactor_notify object in the function, and then calls Ace_wfmo_reactor_ The Notify::open function will call the Ace_wfmo_reactor::register_handler function and call the Ace_wfmo_reactor_handler_repository::bind_i function, and the ACE _wfmo_reactor_notify object ace_reactor_notify *notify_handler_; saved in Ace_wfmo_reactor_handler_repository class To_be_added_ Info *to_be_added_info_; In the member variable.
The Ace_wfmo_reactor::wakeup_all_threads function is called at the end of the Ace_wfmo_reactor_handler_repository::bind_i function, which ace_manual_ its member variables Event Wakeup_all_threads_; set to signaled state.
Also call the Ace_wfmo_reactor::register_handler function to register the Ace_manual_event Wakeup_all_threads_ event. Then at the end of the Ace_wfmo_reactor::open function according to the comment "Since we have added and handles into the handler repository,update the
main function when you create a Server_logging_daemon object, the Examples\c++npv2\logging_ is called The Logging_acceptor::open function in the Acceptor.cpp file, Logging_acceptor class inherits from the Ace_event_handler class, which calls Ace_reactor::register_ The handler function, in turn, calls the Ace_wfmo_reactor::register_handler function and calls the Ace_wfmo_reactor::register_handler_i function and calls the Ace_wfmo_ Reactor_handler_repository::bind_i, add Ace_event_handler, which is its subclass logging_acceptor, to the Ace_wfmo_reactor_handler_ The HANDLES_TO_BE_ADDED_ member variable of the Repository class, and then calls the Ace_wfmo_reactor::wakeup_all_threads member variable that is about to be ace_wfmo_reactor Ace_ The manual_event wakeup_all_threads_; is placed in a signaled state.
The main function calls Ace_reactor::run_reactor_event_loop, which calls the Ace_wfmo_reactor::handle_events function to call Ace_wfmo_reactor:: The event_handling function, called the ace_wfmo_reactor::wait_for_multiple_events function in the function, waitformultipleobjects wait for ace_wfmo_reactor: : Two Ace_handle added in open, where the first member variable returned by Ace_wfmo_reactor_notify::get_handle is Ace_auto_event Wakeup_one_thread_; Initialized to a signal-free State, the second is a handle to ace_manual_event Wakeup_all_threads_, because in the Logging_acceptor::open function it is called to Ace_wfmo_reactor_handler _repository::bind_i and ace_wfmo_reactor the member variable ace_manual_event Wakeup_all_threads_, set to signaled state. So this will return 1.
Then call Ace_wfmo_reactor::safe_dispatch in the Ace_wfmo_reactor::event_handling function, which first calls Ace_wfmo_reactor::d Ispatch, and then because __try, __finally mechanism calls Ace_wfmo_reactor::update_state.
ace_wfmo_reactor::d ispatch function call Ace_wfmo_reactor::d the Ispatch_handles function, which loops through the ACE_WFMO _reactor::d Ispatch_handler, and then call Ace_wfmo_reactor::simple_dispatch_handler, which calls the virtual function in the function ace_event_handler::handle_ Signal, because polymorphism is called here is the ace_wakeup_all_threads_handler::handle_signal function does not do any processing.
Ace_wfmo_reactor::update_state function in the Ace_process_mutex lock_, variable use Ace_guard_return macro lock, LOCK_ member variable is defined at two points, one is not ace_ Thread_mutex is because its implementation is a critical section, the critical section is not used: the WaitForMultipleObjects function, and the other is not a process mutex, because there is no name and no other process can use this variable. The Ace_wfmo_reactor::update_state function is mainly for ace_wfmo_reactor_handler_repository Handler_rep_, which is updated because the previous logging_acceptor :: The Open function adds a logging_acceptor that inherits from the Ace_event_handler class from the Ace_wfmo_reactor_handler_repository to_be_added_info_ To Current_info_ in the update. Then reset the ace_manual_event Wakeup_all_threads_ of the Ace_wfmo_reactor, member variable. This will block the next call to Ace_wfmo_reactor::event_handling when it is Ace_wfmo_reactor::wait_for_multiple_ The waitformultipleobjectsex of the events function, which waits for the two ace_handle added in Ace_wfmo_reactor::open and the ace_handle associated with the listening socket.
Debug C++npv2_reactor_log_server Program