Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / DevGuideExamples / Multithreading / GracefulShutdown / MessengerServer.h
bloba28018a9ee8f1ba9bedf166e37dfed1b17b68235
1 /* -*- C++ -*- */
3 #ifndef MESSENGERSERVER_H_
4 #define MESSENGERSERVER_H_
6 #include "MessengerS.h"
7 #include "ace/Task.h"
8 #include <iostream>
10 //Class MessengerServer
11 class MessengerServer
13 public:
14 //Constructor
15 MessengerServer (CORBA::ORB_ptr orb);
17 //Destructor
18 virtual ~MessengerServer ();
20 // parse arguments
21 int parse_args (int argc, ACE_TCHAR* argv[]);
23 // run the ORB's event loop continuously
24 void run ();
26 // run the ORB's event loop for some number of seconds
27 void run (int seconds);
29 // handle ORB events in a polling loop for some number of iterations
30 void poll (int iterations);
32 // schedule a shutdown timer with the ORB's reactor to timeout
33 // after some seconds
34 void schedule_shutdown_timer (int seconds);
36 // spawn thread to monitor console and shutdown on console input
37 void shutdown_on_console_input ();
39 enum ShutdownMethod {
40 s_client_call, // shutdown on client invocation
41 s_polling_loop, // shutdown after some iterations through loop
42 s_timer, // schedule a timer to shutdown
43 s_console_input, // shutdown on console input
44 s_run_time_value // use CORBA::ORB::run() with time value
47 // Task to monitor console input.
48 class ConsoleMonitor : public ACE_Task_Base
50 public:
51 ConsoleMonitor (CORBA::ORB_ptr orb)
52 : orb_(CORBA::ORB::_duplicate(orb))
56 virtual int svc()
58 char c;
59 std::cin.get (c);
60 orb_->shutdown (true);
61 return 0;
63 private:
64 CORBA::ORB_var orb_;
67 private:
68 CORBA::ORB_var orb_;
69 ConsoleMonitor * monitor_;
72 #endif /* MESSENGERSERVER_H_ */