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/TP_Reactor.h"
10 #include "ace/Thread_Manager.h"
12 #if defined (ACE_WIN32) && defined (ACE_USES_OLD_IOSTREAMS)
19 #include "Reactor_Logging_Server_T.h"
20 #include "Logging_Acceptor_Ex.h"
22 typedef Reactor_Logging_Server
<Logging_Acceptor_Ex
>
23 Server_Logging_Daemon
;
26 class Quit_Handler
: public ACE_Event_Handler
{
28 Quit_Handler (ACE_Reactor
*r
) : ACE_Event_Handler (r
) {}
30 virtual int handle_exception (ACE_HANDLE
) {
31 reactor ()->end_reactor_event_loop ();
32 return -1; // Trigger call to handle_close() method.
35 virtual int handle_close (ACE_HANDLE
, ACE_Reactor_Mask
)
36 { delete this; return 0; }
39 // Protected destructor ensures dynamic allocation.
40 virtual ~Quit_Handler () {}
44 static ACE_THR_FUNC_RETURN
event_loop (void *arg
) {
45 ACE_Reactor
*reactor
= static_cast<ACE_Reactor
*> (arg
);
47 reactor
->owner (ACE_OS::thr_self ());
48 reactor
->run_reactor_event_loop ();
53 static ACE_THR_FUNC_RETURN
controller (void *arg
) {
54 ACE_Reactor
*reactor
= static_cast<ACE_Reactor
*> (arg
);
56 Quit_Handler
*quit_handler
= 0;
57 ACE_NEW_RETURN (quit_handler
, Quit_Handler (reactor
), 0);
59 #if defined (ACE_WIN32) && defined (ACE_USES_OLD_IOSTREAMS)
62 ACE_OS::fgets (user_input
, sizeof (user_input
), stdin
);
63 if (ACE_OS::strcmp (user_input
, "quit") == 0) {
64 reactor
->notify (quit_handler
);
70 std::string user_input
;
71 std::getline (cin
, user_input
, '\n');
73 if (user_input
== "quit") {
74 reactor
->notify (quit_handler
);
84 int ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
86 const size_t N_THREADS
= 4;
87 ACE_TP_Reactor tp_reactor
;
88 ACE_Reactor
reactor (&tp_reactor
);
89 std::unique_ptr
<ACE_Reactor
> delete_instance
90 (ACE_Reactor::instance (&reactor
));
92 Server_Logging_Daemon
*server
;
95 ACE_NEW_RETURN (server
,
96 Server_Logging_Daemon (argc
, argv
,
97 ACE_Reactor::instance ()),
99 ACE_Thread_Manager::instance ()->spawn_n
100 (N_THREADS
, event_loop
, ACE_Reactor::instance ());
101 ACE_Thread_Manager::instance ()->spawn
102 (controller
, ACE_Reactor::instance ());
103 return ACE_Thread_Manager::instance ()->wait ();