summaryrefslogtreecommitdiff
path: root/TAO/examples
diff options
context:
space:
mode:
authormayur <mayur@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2002-07-10 18:42:26 +0000
committermayur <mayur@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2002-07-10 18:42:26 +0000
commitb427179101fc2d7f5ca26d8ce89da98b28733b05 (patch)
tree4dc31b812dd26e9fa23caa5c083ba67c098850bf /TAO/examples
parent867afe4284680facf42917e774406fb6fb854afb (diff)
downloadATCD-b427179101fc2d7f5ca26d8ce89da98b28733b05.tar.gz
Wed Jul 10 11:35:05 2002 Mayur Deshpande <mayur@ics.uci.edu>
Diffstat (limited to 'TAO/examples')
-rw-r--r--TAO/examples/AMH/Sink_Server/AMH_Servant.cpp1
-rw-r--r--TAO/examples/AMH/Sink_Server/Base_Server.cpp2
-rw-r--r--TAO/examples/AMH/Sink_Server/Base_Server.h58
-rw-r--r--TAO/examples/AMH/Sink_Server/client.cpp2
-rw-r--r--TAO/examples/AMH/Sink_Server/mt_server.cpp23
-rw-r--r--TAO/examples/AMH/Sink_Server/st_server.cpp29
6 files changed, 60 insertions, 55 deletions
diff --git a/TAO/examples/AMH/Sink_Server/AMH_Servant.cpp b/TAO/examples/AMH/Sink_Server/AMH_Servant.cpp
index 8a1c69f8141..b8bd2c4c171 100644
--- a/TAO/examples/AMH/Sink_Server/AMH_Servant.cpp
+++ b/TAO/examples/AMH/Sink_Server/AMH_Servant.cpp
@@ -69,6 +69,7 @@ AMH_Servant::test_method (Test::AMH_RoundtripResponseHandler_ptr _tao_rh,
Timer_Handler *handler = new Timer_Handler (send_time);
ACE_Reactor *reactor = this->orb_->orb_core ()->reactor ();
+ // We assume the schedule_timer method is thread-safe
reactor->schedule_timer (handler,
(void *) Test::AMH_RoundtripResponseHandler::_duplicate (_tao_rh),
ACE_Time_Value (0, this->sleep_time_));
diff --git a/TAO/examples/AMH/Sink_Server/Base_Server.cpp b/TAO/examples/AMH/Sink_Server/Base_Server.cpp
index 2bc005c771d..ffa86f9ade6 100644
--- a/TAO/examples/AMH/Sink_Server/Base_Server.cpp
+++ b/TAO/examples/AMH/Sink_Server/Base_Server.cpp
@@ -13,8 +13,8 @@
Base_Server::Base_Server (int* argc, char **argv)
: argc_ (argc)
, argv_ (argv)
- , ior_output_file_("test.ior")
{
+ this->ior_output_file_ = ACE_const_cast (char*, "test.ior");
}
Base_Server::~Base_Server ()
diff --git a/TAO/examples/AMH/Sink_Server/Base_Server.h b/TAO/examples/AMH/Sink_Server/Base_Server.h
index 6925784d2ea..16446f4646d 100644
--- a/TAO/examples/AMH/Sink_Server/Base_Server.h
+++ b/TAO/examples/AMH/Sink_Server/Base_Server.h
@@ -32,40 +32,40 @@ class AMH_Servant;
*/
class Base_Server
{
- public:
- Base_Server (int *argc, char **argv);
- virtual ~Base_Server ();
-
- // Just parse the command line for the output-file (-o) option.
- // return -1 if -o option is not present
- virtual int parse_args (void);
-
- /// try and schedule using FIFO
- void try_RT_scheduling (void);
-
- /// ORB inititalisation stuff
- int start_orb_and_poa (void);
-
- /// register the servant with the poa
- virtual void register_servant (AMH_Servant *servant);
-
- /// orb-perform_work () abstraction
- virtual void run_event_loop ();
-
- public:
- /// Accesor method (for servants) to the initialised ORB
- CORBA::ORB_ptr orb () { return this->orb_.in (); }
-
- protected:
+public:
+ Base_Server (int *argc, char **argv);
+ virtual ~Base_Server ();
+
+ // Just parse the command line for the output-file (-o) option.
+ // return -1 if -o option is not present
+ virtual int parse_args (void);
+
+ /// try and schedule using FIFO
+ void try_RT_scheduling (void);
+
+ /// ORB inititalisation stuff
+ int start_orb_and_poa (void);
+
+ /// register the servant with the poa
+ virtual void register_servant (AMH_Servant *servant);
+
+ /// orb-perform_work () abstraction
+ virtual void run_event_loop ();
+
+public:
+ /// Accesor method (for servants) to the initialised ORB
+ CORBA::ORB_ptr orb () { return this->orb_.in (); }
+
+protected:
int *argc_;
char **argv_;
char *ior_output_file_;
CORBA::ORB_var orb_;
PortableServer::POA_var root_poa_;
-
- private:
- /// Write servant IOR to file specified with the '-o' option
- int write_ior_to_file (CORBA::String_var ior);
+
+private:
+ /// Write servant IOR to file specified with the '-o' option
+ int write_ior_to_file (CORBA::String_var ior);
};
#include "ace/post.h"
diff --git a/TAO/examples/AMH/Sink_Server/client.cpp b/TAO/examples/AMH/Sink_Server/client.cpp
index 6d12ddb1163..49c698fd421 100644
--- a/TAO/examples/AMH/Sink_Server/client.cpp
+++ b/TAO/examples/AMH/Sink_Server/client.cpp
@@ -55,9 +55,9 @@ private:
Client_Task::Client_Task (int argc, char **argv)
: argc_ (argc)
, argv_ (argv)
- , ior_("file://test.ior")
, iterations_(1000)
{
+ this->ior_ = ACE_const_cast (char*, "file://test.ior");
}
diff --git a/TAO/examples/AMH/Sink_Server/mt_server.cpp b/TAO/examples/AMH/Sink_Server/mt_server.cpp
index 1e2787ac1b4..d70624c44ec 100644
--- a/TAO/examples/AMH/Sink_Server/mt_server.cpp
+++ b/TAO/examples/AMH/Sink_Server/mt_server.cpp
@@ -6,10 +6,13 @@
#include "Base_Server.h"
#include "AMH_Servant.h"
-char *
-usage ()
+void
+usage (char *message)
{
- return "invoke as: mt_server -o <ior_output_file> \n -n <num_threads>\n -s <sleep_time (in microseconds)> \n";
+ static const char * usage =
+ "invoke as: mt_server -o <ior_output_file> \n -n <num_threads>\n -s <sleep_time (in microseconds)> \n";
+
+ ACE_ERROR ((LM_ERROR, "%s : %s", message, usage));
}
class MT_AMH_Server
@@ -29,7 +32,7 @@ public:
// Let the base server parse it's argumrents first
if (Base_Server::parse_args () != 1)
{
- ACE_ERROR ((LM_ERROR, "%s", usage ()));
+ usage (ACE_const_cast (char *, ""));
ACE_OS::exit (1);
}
@@ -96,20 +99,18 @@ main (int argc, char *argv[])
if (amh_server.parse_args () != 1)
{
- ACE_ERROR ((LM_ERROR, "%s", usage ()));
+ usage (ACE_const_cast (char*, ""));
ACE_OS::exit (1);
}
- AMH_Servant *servant = new AMH_Servant (amh_server.orb ());
+ AMH_Servant servant (amh_server.orb ());
- if (servant->parse_args (&argc, argv) != 1)
+ if (servant.parse_args (&argc, argv) != 1)
{
- ACE_ERROR ((LM_ERROR, "%s : %s", "sleep time unspecified", usage ()));
+ usage (ACE_const_cast (char*, "sleep time unspecified"));
ACE_OS::exit (1);
}
- // Server takes over memory responsibility for servant,
- // no need to deallocate it at end
- amh_server.register_servant (servant);
+ amh_server.register_servant (&servant);
amh_server.start_threads ();
}
diff --git a/TAO/examples/AMH/Sink_Server/st_server.cpp b/TAO/examples/AMH/Sink_Server/st_server.cpp
index d807eb243cb..c9b9f0529c6 100644
--- a/TAO/examples/AMH/Sink_Server/st_server.cpp
+++ b/TAO/examples/AMH/Sink_Server/st_server.cpp
@@ -5,10 +5,13 @@
#include "Base_Server.h"
-char *
-usage ()
+void
+usage (char *message)
{
- return "invoke as: st_server -o <ior_output_file> \n -s <sleep_time (in microseconds)> \n";
+ static const char * usage =
+ "invoke as: st_server -o <ior_output_file> \n -s <sleep_time (in microseconds)> \n";
+
+ ACE_ERROR ((LM_ERROR, "%s : %s", message, usage));
}
int
@@ -20,20 +23,20 @@ main (int argc, char *argv[])
if (amh_server.parse_args () != 1)
{
- ACE_ERROR ((LM_ERROR, "%s : %s", "IOR file missing", usage ()));
- ACE_OS::exit (1);
+ usage (ACE_const_cast (char *, "IOR file missing \n"));
+ ACE_OS::exit (1);
}
- AMH_Servant *servant = new AMH_Servant (amh_server.orb ());
-
- if (servant->parse_args (&argc, argv) != 1)
+ AMH_Servant servant (amh_server.orb ());
+
+ if (servant.parse_args (&argc, argv) != 1)
{
- ACE_ERROR ((LM_ERROR, "%s : %s", "sleep time unspecified", usage ()));
- ACE_OS::exit (1);
+ usage (ACE_const_cast (char *, "Sleep time unspecified \n"));
+ ACE_OS::exit (1);
}
- // Server takes over memory responsibility for servant,
- // no need to deallocate it at the end
- amh_server.register_servant (servant);
+ amh_server.register_servant (&servant);
amh_server.run_event_loop ();
+
+ return 0;
}