=default for generated implementation copy ctor
[ACE_TAO.git] / TAO / examples / AMH / Sink_Server / MT_AMH_Server.cpp
blobb3a17de112494991addb36af41c6daa859a17834
2 #include "MT_AMH_Server.h"
3 #include "tao/Strategies/advanced_resource.h"
5 #include "ace/Task.h"
6 #include "ace/Get_Opt.h"
8 MT_AMH_Server::MT_AMH_Server (int &argc, ACE_TCHAR **argv)
9 : Base_Server (argc, argv)
13 MT_AMH_Server::~MT_AMH_Server ()
17 void
18 MT_AMH_Server::usage (const char *message)
20 static const char * usage =
21 "invoke as: mt_server -o <ior_output_file>\n"
22 " -n <num_threads>\n"
23 "-s <sleep_time (in microseconds)>\n";
25 // @@ Mayur, why don't you just place the usage message directly in
26 // the below ACE_ERROR macro? It's not a big deal. It's just
27 // something we normally do.
29 // Mayur: Seems cleaner to me this way.
30 ACE_ERROR ((LM_ERROR, "%C : %C", message, usage));
34 int
35 MT_AMH_Server::parse_args ()
37 // Let the base server parse it's argumrents first
38 if (Base_Server::parse_args () != 1)
40 this->usage ("");
41 ACE_OS::exit (1);
44 ACE_Get_Opt get_opts (this->argc_, this->argv_, ACE_TEXT("n:"));
45 int c;
46 int count_argv = 0;
48 while ((c = get_opts ()) != -1)
50 ++count_argv;
51 switch (c)
53 case 'n':
55 this->nthreads_ = ACE_OS::atoi (get_opts.opt_arg ());
58 // Added unneeded '{ & }' just to satisfy Win32
59 for (int i = count_argv; i <= this->argc_; ++i)
60 this->argv_ [i] = this->argv_ [i+2];
63 // Decrement the value of this->argc_ to reflect the removal
64 // of '-n' option.
65 this->argc_ = this->argc_ - 2;
66 return 1;
69 case '?':
70 default:
71 // Don't do anything.
72 break;
75 return 0;
78 void
79 MT_AMH_Server::start_threads ()
81 // Each of this thread runs the event loop
82 this->activate (THR_NEW_LWP | THR_JOINABLE, this->nthreads_, 1);
83 this->thr_mgr ()->wait ();
86 int
87 MT_AMH_Server::svc ()
89 run_event_loop ();
90 return 1;