2 ** Copyright 2002 Addison Wesley. All Rights Reserved.
5 // FUZZ: disable check_for_streams_include
6 #include "ace/streams.h"
8 #include "ace/Reactor.h"
9 #include "ace/Select_Reactor.h"
10 #include "ace/Thread_Manager.h"
12 #if defined (ACE_WIN32) && defined (ACE_USES_OLD_IOSTREAMS)
18 #include "Reactor_Logging_Server_T.h"
19 #include "Logging_Acceptor_Ex.h"
21 typedef Reactor_Logging_Server
<Logging_Acceptor_Ex
>
22 Server_Logging_Daemon
;
25 class Quit_Handler
: public ACE_Event_Handler
{
27 Quit_Handler (ACE_Reactor
*r
) : ACE_Event_Handler (r
) {}
29 virtual int handle_exception (ACE_HANDLE
) {
30 reactor ()->end_reactor_event_loop ();
31 return -1; // Trigger call to handle_close() method.
34 virtual int handle_close (ACE_HANDLE
, ACE_Reactor_Mask
)
35 { delete this; return 0; }
38 // Protected destructor ensures dynamic allocation.
39 virtual ~Quit_Handler () {}
43 static ACE_THR_FUNC_RETURN
event_loop (void *arg
) {
44 ACE_Reactor
*reactor
= static_cast<ACE_Reactor
*> (arg
);
46 reactor
->owner (ACE_OS::thr_self ());
47 reactor
->run_reactor_event_loop ();
52 static ACE_THR_FUNC_RETURN
controller (void *arg
) {
53 ACE_Reactor
*reactor
= static_cast<ACE_Reactor
*> (arg
);
55 Quit_Handler
*quit_handler
= 0;
56 ACE_NEW_RETURN (quit_handler
, Quit_Handler (reactor
), 0);
58 #if defined (ACE_WIN32) && defined (ACE_USES_OLD_IOSTREAMS)
61 ACE_OS::fgets (user_input
, sizeof (user_input
), stdin
);
62 if (ACE_OS::strcmp (user_input
, "quit") == 0) {
63 reactor
->notify (quit_handler
);
69 std::string user_input
;
70 std::getline (cin
, user_input
, '\n');
71 if (user_input
== "quit") {
72 reactor
->notify (quit_handler
);
82 int ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
84 ACE_Select_Reactor select_reactor
;
85 ACE_Reactor
reactor (&select_reactor
);
87 Server_Logging_Daemon
*server
;
90 ACE_NEW_RETURN (server
,
91 Server_Logging_Daemon (argc
, argv
, &reactor
),
93 ACE_Thread_Manager::instance ()->spawn (event_loop
, &reactor
);
94 ACE_Thread_Manager::instance ()->spawn (controller
, &reactor
);
95 return ACE_Thread_Manager::instance ()->wait ();