summaryrefslogtreecommitdiff
path: root/TAO
diff options
context:
space:
mode:
authorschmidt <douglascraigschmidt@users.noreply.github.com>1998-05-07 00:21:39 +0000
committerschmidt <douglascraigschmidt@users.noreply.github.com>1998-05-07 00:21:39 +0000
commita19868f856558a2703866a545a4b521bb0ba1c26 (patch)
tree4a0ff8bc6f99ee288ef39f3d9bdfdd99d95fa391 /TAO
parent1fd7cdbea7518146c344ffd2e55dd5289c39ca4c (diff)
downloadATCD-a19868f856558a2703866a545a4b521bb0ba1c26.tar.gz
*** empty log message ***
Diffstat (limited to 'TAO')
-rw-r--r--TAO/orbsvcs/Concurrency_Service/Concurrency_Service.cpp115
-rw-r--r--TAO/orbsvcs/Concurrency_Service/Concurrency_Service.h44
-rw-r--r--TAO/orbsvcs/orbsvcs/Concurrency/CC_Lock.cpp121
-rw-r--r--TAO/orbsvcs/orbsvcs/Concurrency/CC_Lock.h64
-rw-r--r--TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSet.cpp147
-rw-r--r--TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSet.h34
-rw-r--r--TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSetFactory.cpp55
-rw-r--r--TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSetFactory.h30
-rw-r--r--TAO/orbsvcs/orbsvcs/Concurrency/Concurrency_Utils.cpp11
-rw-r--r--TAO/orbsvcs/orbsvcs/Concurrency/Concurrency_Utils.h23
-rw-r--r--TAO/orbsvcs/orbsvcs/CosConcurrencyControl.idl91
-rw-r--r--TAO/orbsvcs/tests/Concurrency/CC_client.cpp132
-rw-r--r--TAO/orbsvcs/tests/Concurrency/CC_client.h66
-rw-r--r--TAO/orbsvcs/tests/Concurrency/CC_naming_service.cpp44
-rw-r--r--TAO/orbsvcs/tests/Concurrency/CC_naming_service.h34
-rw-r--r--TAO/orbsvcs/tests/Concurrency/CC_tests.cpp166
-rw-r--r--TAO/orbsvcs/tests/Concurrency/CC_tests.h87
-rw-r--r--TAO/orbsvcs/tests/Concurrency/NS_client.cpp43
-rw-r--r--TAO/orbsvcs/tests/Concurrency/NS_client.h38
-rw-r--r--TAO/tests/NestedUpcall/README96
20 files changed, 806 insertions, 635 deletions
diff --git a/TAO/orbsvcs/Concurrency_Service/Concurrency_Service.cpp b/TAO/orbsvcs/Concurrency_Service/Concurrency_Service.cpp
index 5bb81a459d4..7228c1178a3 100644
--- a/TAO/orbsvcs/Concurrency_Service/Concurrency_Service.cpp
+++ b/TAO/orbsvcs/Concurrency_Service/Concurrency_Service.cpp
@@ -24,34 +24,38 @@ Concurrency_Service::Concurrency_Service (void)
: use_naming_service_ (1),
ior_output_file_ (0)
{
- ACE_DEBUG((LM_DEBUG, "Concurrency_Service::Concurrency_Service(void)\n"));
+ ACE_DEBUG ((LM_DEBUG,
+ "Concurrency_Service::Concurrency_Service (void)\n"));
}
-// Constructor taking command-line arguments
+// Constructor taking command-line arguments.
Concurrency_Service::Concurrency_Service (int argc,
char** argv,
- CORBA::Environment& _env)
+ CORBA::Environment& env)
{
- ACE_DEBUG((LM_DEBUG, "Concurrency_Service::Concurrency_Service(...)\n"));
- this->init (argc, argv, _env);
+ ACE_DEBUG ((LM_DEBUG,
+ "Concurrency_Service::Concurrency_Service (...)\n"));
+ this->init (argc, argv, env);
}
-Concurrency_Service::parse_args(void)
+Concurrency_Service::parse_args (void)
{
- ACE_DEBUG((LM_DEBUG, "Concurrency_Service::parse_args\n"));
+ ACE_DEBUG ((LM_DEBUG,
+ "Concurrency_Service::parse_args\n"));
+
ACE_Get_Opt get_opts (argc_, argv_, "do:s");
int c;
while ((c = get_opts ()) != -1)
- switch(c)
+ switch (c)
{
case 'd': // debug flag
TAO_debug_level++;
break;
case 'o': // output the IOR to a file
this->ior_output_file_ = ACE_OS::fopen (get_opts.optarg, "w");
- if(this->ior_output_file_ == 0)
+ if (this->ior_output_file_ == 0)
ACE_ERROR_RETURN ((LM_ERROR,
"Unable to open %s for writing: %p\n",
get_opts.optarg), -1);
@@ -72,91 +76,98 @@ Concurrency_Service::parse_args(void)
return 0;
}
-// Initialize the state of the Concurrency_Service object
+// Initialize the state of the Concurrency_Service object.
+
int
Concurrency_Service::init (int argc,
- char** argv,
- CORBA::Environment& _env)
+ char **argv,
+ CORBA::Environment &env)
{
- ACE_DEBUG((LM_DEBUG, "Concurrency_Service::init\n"));
- if(this->orb_manager_.init_child_poa (argc,
+ ACE_DEBUG ((LM_DEBUG,
+ "Concurrency_Service::init\n"));
+ if (this->orb_manager_.init_child_poa (argc,
argv,
"child_poa",
- _env) == -1)
- ACE_ERROR_RETURN((LM_ERROR,
+ env) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
"%p\n",
"init_child_poa"),
-1);
- TAO_CHECK_ENV_RETURN(_env,-1);
+ TAO_CHECK_ENV_RETURN (env,-1);
this->argc_ = argc;
this->argv_ = argv;
- if(this->parse_args()!=0)
- ACE_ERROR_RETURN((LM_ERROR,
+ if (this->parse_args ()!=0)
+ ACE_ERROR_RETURN ((LM_ERROR,
"Could not parse command line\n"),
-1);
CORBA::String_var str =
- this->orb_manager_.activate(this->my_concurrency_server_.GetLockSetFactory(),
- _env);
+ this->orb_manager_.activate (this->my_concurrency_server_.GetLockSetFactory (),
+ env);
ACE_DEBUG ((LM_DEBUG,
"The IOR is: <%s>\n",
- str.in()));
+ str.in ()));
- if(this->ior_output_file_)
+ if (this->ior_output_file_)
{
- ACE_OS::fprintf (this->ior_output_file_, "%s", str.in());
+ ACE_OS::fprintf (this->ior_output_file_, "%s", str.in ());
ACE_OS::fclose (this->ior_output_file_);
}
- if(this->use_naming_service_)
- return this->init_naming_service (_env);
+ if (this->use_naming_service_)
+ return this->init_naming_service (env);
return 0;
}
int
-Concurrency_Service::init_naming_service(CORBA::Environment& _env)
+Concurrency_Service::init_naming_service (CORBA::Environment &env)
{
- ACE_DEBUG((LM_DEBUG, "Concurrency_Service::init_naming_service(...)\n"));
+ ACE_DEBUG ((LM_DEBUG, "Concurrency_Service::init_naming_service (...)\n"));
CORBA::ORB_var orb;
PortableServer::POA_var child_poa;
- orb = this->orb_manager_.orb();
- child_poa = this->orb_manager_.child_poa();
+ orb = this->orb_manager_.orb ();
+ child_poa = this->orb_manager_.child_poa ();
- int result = this->my_name_server_.init (orb.in(),
- child_poa.in());
- if(result<0)
+ int result = this->my_name_server_.init (orb.in (),
+ child_poa.in ());
+ if (result == -1)
return result;
- lockset_factory_ = this->my_concurrency_server_.GetLockSetFactory()->_this(_env);
- TAO_CHECK_ENV_RETURN(_env, -1);
+ lockset_factory_ =
+ this->my_concurrency_server_.GetLockSetFactory ()->_this (env);
+ TAO_CHECK_ENV_RETURN (env, -1);
CosNaming::Name concurrency_context_name (1);
- concurrency_context_name.length(1);
+ concurrency_context_name.length (1);
concurrency_context_name[0].id = CORBA::string_dup ("CosConcurrency");
+
this->concurrency_context_ =
this->my_name_server_->bind_new_context (concurrency_context_name,
- _env);
- TAO_CHECK_ENV_RETURN(_env, -1);
+ env);
+ TAO_CHECK_ENV_RETURN (env, -1);
CosNaming::Name lockset_name (1);
- lockset_name.length(1);
+ lockset_name.length (1);
lockset_name[0].id = CORBA::string_dup ("LockSetFactory");
- this->concurrency_context_->bind(lockset_name,
- lockset_factory_.in(),
- _env);
- TAO_CHECK_ENV_RETURN(_env, -1);
+ this->concurrency_context_->bind (lockset_name,
+ lockset_factory_.in (),
+ env);
+ TAO_CHECK_ENV_RETURN (env, -1);
return 0;
}
-// Run the ORB event loop
+// Run the ORB event loop.
+
int
-Concurrency_Service::run (CORBA_Environment& _env)
+Concurrency_Service::run (CORBA_Environment& env)
{
- ACE_DEBUG((LM_DEBUG, "Concurrency_Service::run(...)\n"));
- if(this->orb_manager_.run(_env) == -1)
- ACE_ERROR_RETURN((LM_ERROR,
+ ACE_DEBUG ((LM_DEBUG,
+ "Concurrency_Service::run (...)\n"));
+
+ if (this->orb_manager_.run (env) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
"Concurrency_Service::run"),
-1);
return 0;
@@ -166,10 +177,10 @@ Concurrency_Service::run (CORBA_Environment& _env)
Concurrency_Service::~Concurrency_Service (void)
{
- ACE_DEBUG((LM_DEBUG, "Concurrency_Service::~Concurrency_Service(void)\n"));
+ ACE_DEBUG ((LM_DEBUG,
+ "Concurrency_Service::~Concurrency_Service (void)\n"));
}
-
int
main (int argc, char ** argv)
{
@@ -180,11 +191,11 @@ main (int argc, char ** argv)
TAO_TRY
{
- if( concurrency_service.init (argc,argv,TAO_TRY_ENV) == -1)
+ if (concurrency_service.init (argc, argv, TAO_TRY_ENV) == -1)
return 1;
else
{
- concurrency_service.run(TAO_TRY_ENV);
+ concurrency_service.run (TAO_TRY_ENV);
TAO_CHECK_ENV;
}
}
diff --git a/TAO/orbsvcs/Concurrency_Service/Concurrency_Service.h b/TAO/orbsvcs/Concurrency_Service/Concurrency_Service.h
index 4686a83cc6f..7530624c2a4 100644
--- a/TAO/orbsvcs/Concurrency_Service/Concurrency_Service.h
+++ b/TAO/orbsvcs/Concurrency_Service/Concurrency_Service.h
@@ -1,4 +1,5 @@
// $Id$
+
// ============================================================================
//
// = LIBRARY
@@ -8,7 +9,8 @@
// Concurrency_Service.h
//
// = DESCRIPTION
-// This class implements the functionality of the Concurrency_Service.
+// This class implements a subset of the functionality of the
+// CORBA Concurrency Service.
//
// = AUTHORS
// Torben Worm <tworm@cs.wustl.edu>
@@ -18,49 +20,45 @@
#if !defined (_CONCURRENCY_SERVICE_H)
#define _CONCURRENCY_SERVICE_H
-//#include "ace/streams.h"
-//#include "tao/tao_util.h"
#include "ace/Get_Opt.h"
#include "ace/Log_Msg.h"
#include "tao/TAO.h"
#include "orbsvcs/Concurrency/Concurrency_Utils.h"
-//#include "orbsvcs/Concurrency/CC_LockSetFactory.h"
#include "orbsvcs/Naming/Naming_Utils.h"
-class Concurrency_Service:public TAO_ORB_Manager
+class Concurrency_Service : public TAO_ORB_Manager
{
- // =TITLE
+ // = TITLE
// Defines a class that encapsulates the implementation of the
// concurrency service.
- // =DESCRIPTION
- //
- //
-
+ // = DESCRIPTION
+ // @@ Please add a brief description here.
public:
+ // = Initialization and termination methods.
Concurrency_Service (void);
// Default Constructor.
Concurrency_Service (int argc,
- char** argv,
- CORBA::Environment& _env);
+ char **argv,
+ CORBA::Environment &env);
// Constructor taking the command-line arguments.
~Concurrency_Service (void);
// Destructor.
int init (int argc,
- char** argv,
- CORBA::Environment& _env);
+ char **argv,
+ CORBA::Environment &env);
// Initialize the Concurrency Service with the arguments.
- int run (CORBA_Environment& _env);
+ int run (CORBA_Environment &env);
// Run the Concurrency_Service.
private:
- int parse_args(void);
+ int parse_args (void);
// Parses the commandline arguments.
- int init_naming_service (CORBA::Environment& _env);
+ int init_naming_service (CORBA::Environment &env);
// Initialize the name server and register the concurency server
// factory with it. Maybe later it will be convinient to register
// the individual lock sets with the naming service. At present the
@@ -80,22 +78,22 @@ private:
// objects.
TAO_Concurrency_Server my_concurrency_server_;
- // An instance of the concurrency server
+ // An instance of the concurrency server.
CosConcurrencyControl::LockSetFactory_var lockset_factory_;
- // Factory var to register with the naming service
+ // Factory var to register with the naming service.
CosNaming::NamingContext_var concurrency_context_;
- // Naming context for the concurrency service
+ // Naming context for the concurrency service.
CosNaming::NamingContext_var naming_context_;
- // Naming context for the naming service
+ // Naming context for the naming service.
int argc_;
- // Number of commandline arguments
+ // Number of commandline arguments.
char **argv_;
- // Commandline arguments
+ // Commandline arguments.
};
#endif /* _CONCURRENCY_SERVICE_H */
diff --git a/TAO/orbsvcs/orbsvcs/Concurrency/CC_Lock.cpp b/TAO/orbsvcs/orbsvcs/Concurrency/CC_Lock.cpp
index 4438cc8e668..29f505adc00 100644
--- a/TAO/orbsvcs/orbsvcs/Concurrency/CC_Lock.cpp
+++ b/TAO/orbsvcs/orbsvcs/Concurrency/CC_Lock.cpp
@@ -11,7 +11,7 @@
//
// = DESCRIPTION
// This class implements a lock used by the lock set from the
-// concurrency control service
+// concurrency control service.
//
// = AUTHORS
// Torben Worm <tworm@cs.wustl.edu>
@@ -21,86 +21,110 @@
#include "CC_Lock.h"
#include "tao/corba.h"
-CC_Lock::CC_Lock(CosConcurrencyControl::lock_mode mode)
- : mode_ (mode), lock_held_ (0)
+CC_Lock::CC_Lock (CosConcurrencyControl::lock_mode mode)
+ : mode_ (mode),
+ lock_held_ (0)
{
}
-CC_Lock::~CC_Lock()
+CC_Lock::~CC_Lock (void)
{
}
-void CC_Lock::lock(CORBA::Environment &_env)
+void
+CC_Lock::lock (CORBA::Environment &env)
{
- ACE_DEBUG((LM_DEBUG, "CC_Lock::lock\n"));
+ ACE_DEBUG ((LM_DEBUG,
+ "CC_Lock::lock\n"));
lock_held_++;
- int success = semaphore_.acquire();
- if(success==-1) {
- TAO_THROW(CORBA::INTERNAL(CORBA::COMPLETED_NO));
- }
+
+ if (semaphore_.acquire () == -1)
+ TAO_THROW (CORBA::INTERNAL (CORBA::COMPLETED_NO));
}
-CORBA::Boolean CC_Lock::try_lock(CORBA::Environment &_env)
+CORBA::Boolean
+CC_Lock::try_lock (CORBA::Environment &env)
{
- ACE_DEBUG((LM_DEBUG, "CC_Lock::try_lock. "));
+ ACE_DEBUG ((LM_DEBUG,
+ "CC_Lock::try_lock. "));
+
lock_held_++;
- ACE_DEBUG((LM_DEBUG, "lock_held_: %i, ", lock_held_));
- int success = semaphore_.tryacquire();
- ACE_DEBUG((LM_DEBUG, "success: %i\n", success));
- if(success==-1) {
- if(errno==EBUSY) {
- lock_held_--;
- return CORBA::B_FALSE;
+
+ ACE_DEBUG ((LM_DEBUG,
+ "lock_held_: %i, ",
+ lock_held_));
+
+ int success = semaphore_.tryacquire ();
+
+ ACE_DEBUG ((LM_DEBUG,
+ "success: %i\n", success));
+
+ if (success == -1)
+ {
+ if (errno == EBUSY)
+ {
+ lock_held_--;
+ return CORBA::B_FALSE;
+ }
+ else
+ TAO_THROW_RETURN (CORBA::INTERNAL (CORBA::COMPLETED_NO),
+ CORBA::B_FALSE);
}
- else
- TAO_THROW_RETURN(CORBA::INTERNAL(CORBA::COMPLETED_NO), CORBA::B_FALSE);
- }
- // else {
- // this->lock(_env);
- // }
}
-void CC_Lock::unlock(CORBA::Environment &_env)
+void
+CC_Lock::unlock (CORBA::Environment &env)
{
- ACE_DEBUG((LM_DEBUG, "CC_Lock::unlock\n"));
- if(lock_held_==0)
- TAO_THROW(CosConcurrencyControl::LockNotHeld);
- int success = semaphore_.release();
- if(success==-1) {
- TAO_THROW(CORBA::INTERNAL(CORBA::COMPLETED_NO));
- }
+ ACE_DEBUG ((LM_DEBUG,
+ "CC_Lock::unlock\n"));
+ if (lock_held_ == 0)
+ TAO_THROW (CosConcurrencyControl::LockNotHeld);
+
+ int success = semaphore_.release ();
+
+ if (success == -1)
+ TAO_THROW (CORBA::INTERNAL (CORBA::COMPLETED_NO));
+
lock_held_--;
}
-void CC_Lock::change_mode(CosConcurrencyControl::lock_mode new_mode,
- CORBA::Environment &_env)
+void
+CC_Lock::change_mode (CosConcurrencyControl::lock_mode new_mode,
+ CORBA::Environment &env)
{
- ACE_DEBUG((LM_DEBUG, "CC_Lock::change_mode\n"));
- // @@TAO Hmmm, we cannot really do anything at present since there is
- // only one lock per lock set and that lock is essentially a write lock
- if(lock_held_==0)
- TAO_THROW(CosConcurrencyControl::LockNotHeld);
+ ACE_DEBUG ((LM_DEBUG,
+ "CC_Lock::change_mode\n"));
+
+ // @@TAO Hmmm, we cannot really do anything at present since there
+ // is only one lock per lock set and that lock is essentially a
+ // write lock
+
+ if (lock_held_ == 0)
+ TAO_THROW (CosConcurrencyControl::LockNotHeld);
+
this->mode_ = new_mode;
}
-CORBA::Boolean CC_Lock::Compatible(const CC_Lock &other)
+CORBA::Boolean CC_Lock::Compatible (const CC_Lock &other)
{
- return this->Compatible(other.mode_);
+ return this->Compatible (other.mode_);
}
-CORBA::Boolean CC_Lock::Compatible(CosConcurrencyControl::lock_mode mode)
+CORBA::Boolean CC_Lock::Compatible (CosConcurrencyControl::lock_mode mode)
{
return compatible_[this->mode_][mode];
}
-CosConcurrencyControl::lock_mode CC_Lock::GetMode(void)
+CosConcurrencyControl::lock_mode CC_Lock::GetMode (void)
{
return mode_;
}
-// The check of compatibility is a hard coded table statically allocated
-// This table must be changed if the number of lock modes or their
-// compatibility are changed. 5 = number of lock modes
+// The check of compatibility is a hard coded table statically
+// allocated. This table must be changed if the number of lock modes
+// or their compatibility are changed. 5 = number of lock modes
+// @@ Torben, also please make sure to use an enum here, as well!
+
CORBA::Boolean CC_Lock::compatible_[5][5] ={
{CORBA::B_TRUE, CORBA::B_TRUE, CORBA::B_TRUE, CORBA::B_TRUE, CORBA::B_FALSE},
{CORBA::B_TRUE, CORBA::B_TRUE, CORBA::B_TRUE, CORBA::B_FALSE, CORBA::B_FALSE},
@@ -108,6 +132,3 @@ CORBA::Boolean CC_Lock::compatible_[5][5] ={
{CORBA::B_TRUE, CORBA::B_FALSE, CORBA::B_FALSE, CORBA::B_FALSE, CORBA::B_TRUE},
{CORBA::B_FALSE, CORBA::B_FALSE, CORBA::B_FALSE, CORBA::B_FALSE, CORBA::B_FALSE}};
-//#if defined (__ACE_INLINE__)
-//#include "CC_Lock.i"
-//#endif // defined INLINE
diff --git a/TAO/orbsvcs/orbsvcs/Concurrency/CC_Lock.h b/TAO/orbsvcs/orbsvcs/Concurrency/CC_Lock.h
index ce5db2f8c96..cc40ccff0f8 100644
--- a/TAO/orbsvcs/orbsvcs/Concurrency/CC_Lock.h
+++ b/TAO/orbsvcs/orbsvcs/Concurrency/CC_Lock.h
@@ -24,60 +24,66 @@
#include "ace/Synch.h"
#include "orbsvcs/CosConcurrencyControlC.h"
-class TAO_ORBSVCS_Export CC_Lock {
+class TAO_ORBSVCS_Export CC_Lock
+{
// = TITLE
// CC_Lock
//
// = DESCRIPTION
// This class implements the lock concept from the concurrency
- // control service. The lock holds its mode - this might later be
- // changed to subclasses depending on the differences of the locks.
- // At present the is only a lock-pr-thread/client-type which is
- // essentially a write lock since it is not allowed to have more
- // than one lock pr. servant in this implementation.
+ // control service. The lock holds its mode - this might later
+ // be changed to subclasses depending on the differences of the
+ // locks. At present the is only a lock-pr-thread/client-type
+ // which is essentially a write lock since it is not allowed to
+ // have more than one lock pr. servant in this implementation.
public:
- CC_Lock(CosConcurrencyControl::lock_mode mode);
+ CC_Lock (CosConcurrencyControl::lock_mode mode);
// Creates the lock with the desired mode
- ~CC_Lock();
+ ~CC_Lock (void);
// Deletes the lock
- void lock(CORBA::Environment &_env);
+ void lock (CORBA::Environment &env);
// Acquires this lock. Blocks until lock is obtained
- CORBA::Boolean try_lock(CORBA::Environment &_env);
+ CORBA::Boolean try_lock (CORBA::Environment &env);
// Tries to acquire this lock. If it is not possible to acquire the
// lock, false is returned
- void unlock(CORBA::Environment &_env);
- // Releases this lock
+ void unlock (CORBA::Environment &env);
+ // Releases this lock.
- void change_mode(CosConcurrencyControl::lock_mode new_mode,
- CORBA::Environment &_env);
- // Changes the mode of this lock
+ void change_mode (CosConcurrencyControl::lock_mode new_mode,
+ CORBA::Environment &env);
+ // Changes the mode of this lock.
- CORBA::Boolean Compatible(const CC_Lock &other);
- // returns true if this lock is compatible with the other lock
+ CORBA::Boolean Compatible (const CC_Lock &other);
+ // returns true if this lock is compatible with the other lock.
- CORBA::Boolean Compatible(CosConcurrencyControl::lock_mode mode);
- // returns true is this lock is compatible with the referenced mode
+ CORBA::Boolean Compatible (CosConcurrencyControl::lock_mode mode);
+ // Returns true is this lock is compatible with the referenced mode.
+
+ CosConcurrencyControl::lock_mode GetMode (void);
+ // Returns the mode of the lock.
- CosConcurrencyControl::lock_mode GetMode(void);
- // Returns the mode of the lock
protected:
CosConcurrencyControl::lock_mode mode_;
- // Holds the lock's mode
+ // Holds the lock's mode.
+
private:
ACE_Thread_Semaphore semaphore_;
- // holds the semaphore for this lock
+ // Holds the semaphore for this lock.
+ // @@ Torben, can you please explain this implementation in a bit more detail?
+
int lock_held_;
- // if greater than zero the lock is held (that number of times)
+ // If greater than zero the lock is held (that number of times).
+
static CORBA::Boolean compatible_[5][5];
- // defines the compatibility of the locks. 5 = number of lock modes
+ // Defines the compatibility of the locks. 5 = number of lock modes.
+ // @@ Torben, can you please make sure that you use an enum value
+ // rather than a magic number for this? Ideally, this enum value
+ // would be defined in the same place as the "number of lock modes."
+ //
};
-//#if defined (__ACE_INLINE__)
-//#include "CC_Lock.i"
-//#endif // defined INLINE
-
#endif /* !defined (_CC_LOCK_H) */
diff --git a/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSet.cpp b/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSet.cpp
index d8d8385b5dc..974392e6299 100644
--- a/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSet.cpp
+++ b/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSet.cpp
@@ -1,5 +1,4 @@
/* -*- C++ -*- */
-
// $Id$
// ============================================================================
@@ -17,11 +16,12 @@
#include "CC_LockSet.h"
-// Default constructor. We cannot create the lock at this point because we
-// are not locking anything, and we do not know the mode of the lock. In a
-// full fledged version the lock set (implementation) will be instantiated
-// here
-CC_LockSet::CC_LockSet(void)
+// Default constructor. We cannot create the lock at this point
+// because we are not locking anything, and we do not know the mode of
+// the lock. In a full fledged version the lock set (implementation)
+// will be instantiated here
+
+CC_LockSet::CC_LockSet (void)
: related_lockset_ (0),
lock_ (0)
{
@@ -29,90 +29,115 @@ CC_LockSet::CC_LockSet(void)
}
// Constructor used to create related lock sets.
-CC_LockSet::CC_LockSet(CosConcurrencyControl::LockSet_ptr related)
+
+CC_LockSet::CC_LockSet (CosConcurrencyControl::LockSet_ptr related)
: related_lockset_ (related),
lock_ (0)
{
// Do nothing
}
-// Destructor. Remove the lock if it exists. In a later version the lock set
-// must be removed here. Actually if all locks have been unlocked no lock
-// instances should exist at this point.
-CC_LockSet::~CC_LockSet(void)
+// Destructor. Remove the lock if it exists. In a later version the
+// lock set must be removed here. Actually if all locks have been
+// unlocked no lock instances should exist at this point.
+
+CC_LockSet::~CC_LockSet (void)
{
- if(lock_!=0)
+ if (lock_!=0)
delete lock_;
+
lock_ = 0;
}
-// Locks the lock in the desired mode. Blocks until success. In a later
-// version the lock set should be searched for incompatible locks
-void CC_LockSet::lock(CosConcurrencyControl::lock_mode mode,
- CORBA::Environment &_env)
+// Locks the lock in the desired mode. Blocks until success. In a
+// later version the lock set should be searched for incompatible
+// locks.
+
+void
+CC_LockSet::lock (CosConcurrencyControl::lock_mode mode,
+ CORBA::Environment &env)
{
- ACE_DEBUG((LM_DEBUG, "CC_LockSet::lock\n"));
- if(lock_==0) {
- ACE_NEW(lock_, CC_Lock(mode));
- if(errno==ENOMEM) {
- _env.clear();
- _env.exception(new CORBA::NO_MEMORY (CORBA::COMPLETED_NO));
- _env.print_exception("CC_Lock::lock()");
+ ACE_DEBUG ((LM_DEBUG, "CC_LockSet::lock\n"));
+ if (lock_ == 0)
+ {
+ ACE_NEW (lock_, CC_Lock (mode));
+ if (errno == ENOMEM)
+ {
+ env.clear ();
+ env.exception (new CORBA::NO_MEMORY (CORBA::COMPLETED_NO));
+ env.print_exception ("CC_Lock::lock ()");
+ }
+ }
+ TAO_TRY
+ {
+ lock_->lock (env);
+ }
+ TAO_CATCHANY
+ {
+ TAO_RETHROW;
}
- }
- TAO_TRY {
- lock_->lock(_env);
- }
- TAO_CATCHANY {
- TAO_RETHROW;
- }
TAO_ENDTRY;
}
-// Tries to lock. If it is not possible false is returned. Comments for lock
-// holds for later version
-CORBA::Boolean CC_LockSet::try_lock(CosConcurrencyControl::lock_mode mode,
- CORBA::Environment &_env)
+// Tries to lock. If it is not possible false is returned. Comments
+// for lock holds for later version.
+
+CORBA::Boolean
+CC_LockSet::try_lock (CosConcurrencyControl::lock_mode mode,
+ CORBA::Environment &env)
{
- ACE_DEBUG((LM_DEBUG, "CC_LockSet::try_lock\n"));
- TAO_TRY {
- return lock_->try_lock(_env);
- }
- TAO_CATCHANY {
- TAO_RETHROW_RETURN(CORBA::B_FALSE);
- }
+ ACE_DEBUG ((LM_DEBUG,
+ "CC_LockSet::try_lock\n"));
+ TAO_TRY
+ {
+ return lock_->try_lock (env);
+ }
+ TAO_CATCHANY
+ {
+ TAO_RETHROW_RETURN (CORBA::B_FALSE);
+ }
TAO_ENDTRY;
}
-// Drops the specified lock. In this simple case we have only one lock at
-// any time so we just drop that lock.
-void CC_LockSet::unlock(CosConcurrencyControl::lock_mode mode,
- CORBA::Environment &_env)
+// Drops the specified lock. In this simple case we have only one lock
+// at any time so we just drop that lock.
+
+void
+CC_LockSet::unlock (CosConcurrencyControl::lock_mode mode,
+ CORBA::Environment &env)
{
- ACE_DEBUG((LM_DEBUG, "CC_LockSet::unlock\n"));
- TAO_TRY {
- lock_->unlock(_env);
- }
- TAO_CATCHANY {
- TAO_RETHROW;
- }
+ ACE_DEBUG ((LM_DEBUG,
+ "CC_LockSet::unlock\n"));
+ TAO_TRY
+ {
+ lock_->unlock (env);
+ }
+ TAO_CATCHANY
+ {
+ TAO_RETHROW;
+ }
TAO_ENDTRY;
}
// Changes the mode of a held lock. In this version we deal with only
-// one type of lock (in reality) and therefore the type is of no meaning
-void CC_LockSet::change_mode (CosConcurrencyControl::lock_mode held_mode,
- CosConcurrencyControl::lock_mode new_mode,
- CORBA::Environment &_env)
+// one type of lock (in reality) and therefore the type is of no
+// meaning.
+
+void
+CC_LockSet::change_mode (CosConcurrencyControl::lock_mode held_mode,
+ CosConcurrencyControl::lock_mode new_mode,
+ CORBA::Environment &env)
{
- ACE_DEBUG((LM_DEBUG, "CC_LockSet::change_mode\n"));
+ ACE_DEBUG ((LM_DEBUG,
+ "CC_LockSet::change_mode\n"));
TAO_TRY
{
- lock_->change_mode(new_mode, _env);
+ lock_->change_mode (new_mode, env);
+ }
+ TAO_CATCHANY
+ {
+ TAO_RETHROW;
}
- TAO_CATCHANY {
- TAO_RETHROW;
- }
TAO_ENDTRY;
}
diff --git a/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSet.h b/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSet.h
index 909b06b95b7..0dc03fcba8b 100644
--- a/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSet.h
+++ b/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSet.h
@@ -30,21 +30,24 @@ class TAO_ORBSVCS_Export CC_LockSet : public POA_CosConcurrencyControl::LockSet
// CC_LockSet
//
// = DESCRIPTION
- // This class implements the LockSet interface that is part
- // of the CosConcurrency service. Please consult the idl file for
- // detailed descriptions apart from the comments in this file
- // At present the lock set is not really a set, but only one lock.
+ // This class implements the LockSet interface that is part of
+ // the CosConcurrency service. Please consult the idl file for
+ // detailed descriptions apart from the comments in this file At
+ // present the lock set is not really a set, but only one lock.
{
public:
+ // = Initialization and termination methods.
CC_LockSet(void);
// Default constructor
CC_LockSet(CosConcurrencyControl::LockSet_ptr related);
- // Constructor used if create_related is used to create the lock set
+ // Constructor used if create_related is used to create the lock
+ // set.
~CC_LockSet(void);
- // Destructor
+ // Destructor.
+ // @@ Torben, please add comments to the following methods.
virtual void lock (CosConcurrencyControl::lock_mode mode,
CORBA::Environment &env);
@@ -59,18 +62,15 @@ public:
CORBA::Environment &env);
private:
CC_Lock *lock_;
- // At present the lock set contains only one lock
+ // At present the lock set contains only one lock.
CosConcurrencyControl::LockSet_ptr related_lockset_;
- // If this lock set is related to another lock set, this is the pointer
- // to the related lock set. This is a really simple solution, but since
- // transactions are not supported in the first version there should be
- // no reason to drop lock sets together. The LockSetCoordinator is not
- // implemented (it has the responsibilities of dropping the locks).
-}; // CC_LockSet
-
-//#if defined (__ACE_INLINE__)
-//#include "CC_LockSet.i"
-//#endif // defined INLINE
+ // If this lock set is related to another lock set, this is the
+ // pointer to the related lock set. This is a really simple
+ // solution, but since transactions are not supported in the first
+ // version there should be no reason to drop lock sets together. The
+ // LockSetCoordinator is not implemented (it has the
+ // responsibilities of dropping the locks).
+};
#endif /* _CC_LOCKSET_H */
diff --git a/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSetFactory.cpp b/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSetFactory.cpp
index f3d2a0c03a1..720321666e1 100644
--- a/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSetFactory.cpp
+++ b/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSetFactory.cpp
@@ -1,5 +1,4 @@
/* -*- C++ -*- */
-
// $Id$
// ============================================================================
@@ -19,53 +18,55 @@
#include "CC_LockSet.h"
// Default constructor
-CC_LockSetFactory::CC_LockSetFactory(void)
+CC_LockSetFactory::CC_LockSetFactory (void)
{
- ACE_NEW(this->lock_, ACE_Lock_Adapter<ACE_Thread_Mutex> ());
+ // @@ Torben, can you please comment this code?
+ ACE_NEW (this->lock_, ACE_Lock_Adapter<ACE_Thread_Mutex>);
}
-// Destructor
-CC_LockSetFactory::~CC_LockSetFactory(void)
+// Destructor.
+CC_LockSetFactory::~CC_LockSetFactory (void)
{
delete this->lock_;
}
CosConcurrencyControl::LockSet_ptr
- CC_LockSetFactory::create ( CORBA::Environment &env)
+CC_LockSetFactory::create ( CORBA::Environment &env)
{
CC_LockSet *ls = 0;
- env.clear();
- env.exception(new CORBA::UNKNOWN (CORBA::COMPLETED_NO));
- ACE_GUARD_RETURN(ACE_Lock, ace_mon, *this->lock_,
- CosConcurrencyControl::LockSet::_nil());
+ env.clear ();
+ env.exception (new CORBA::UNKNOWN (CORBA::COMPLETED_NO));
+ ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->lock_, CosConcurrencyControl::LockSet::_nil ());
- env.clear();
+ env.clear ();
- env.exception(new CORBA::NO_MEMORY (CORBA::COMPLETED_NO));
- ACE_NEW_RETURN(ls, CC_LockSet, CosConcurrencyControl::LockSet::_nil());
- env.clear();
+ env.exception (new CORBA::NO_MEMORY (CORBA::COMPLETED_NO));
+ ACE_NEW_RETURN (ls,
+ CC_LockSet,
+ CosConcurrencyControl::LockSet::_nil ());
+ env.clear ();
- return ls->_this(env);
+ return ls->_this (env);
}
CosConcurrencyControl::LockSet_ptr
- CC_LockSetFactory::create_related (CosConcurrencyControl::LockSet_ptr which,
- CORBA::Environment &env)
+CC_LockSetFactory::create_related (CosConcurrencyControl::LockSet_ptr which,
+ CORBA::Environment &env)
{
CC_LockSet *ls = 0;
- env.clear();
- env.exception(new CORBA::UNKNOWN (CORBA::COMPLETED_NO));
- ACE_GUARD_RETURN(ACE_Lock, ace_mon, *this->lock_,
- CosConcurrencyControl::LockSet::_nil());
+ env.clear ();
+ env.exception (new CORBA::UNKNOWN (CORBA::COMPLETED_NO));
+ ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->lock_, CosConcurrencyControl::LockSet::_nil ());
- env.clear();
+ env.clear ();
- env.exception(new CORBA::NO_MEMORY (CORBA::COMPLETED_NO));
- ACE_NEW_RETURN(ls, CC_LockSet(which),
- CosConcurrencyControl::LockSet::_nil());
- env.clear();
+ env.exception (new CORBA::NO_MEMORY (CORBA::COMPLETED_NO));
+ ACE_NEW_RETURN (ls,
+ CC_LockSet (which),
+ CosConcurrencyControl::LockSet::_nil ());
+ env.clear ();
- return ls->_this(env);
+ return ls->_this (env);
}
diff --git a/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSetFactory.h b/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSetFactory.h
index c224bdafaed..4ea7853c282 100644
--- a/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSetFactory.h
+++ b/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSetFactory.h
@@ -11,7 +11,7 @@
//
// = DESCRIPTION
// This class implements the lock set factory interface from the
-// concuurency service
+// concurrency service.
//
// = AUTHORS
// Torben Worm <tworm@cs.wustl.edu>
@@ -29,31 +29,31 @@ class TAO_ORBSVCS_Export CC_LockSetFactory : public POA_CosConcurrencyControl::L
// CC_LockSetFactory
//
// = DESCRIPTION
- // This class implements the LockSetFactory interface that is part
- // of the CosConcurrency service. Please consult the idl file for
- // detailed descriptions apart from the comments in this file
+ // This class implements the LockSetFactory interface that is
+ // part of the CosConcurrency service. Please consult the idl
+ // file for detailed descriptions apart from the comments in
+ // this file.
{
public:
+ // = Initialization and termination methods.
CC_LockSetFactory(void);
- // Default constructor
+ // Default constructor.
~CC_LockSetFactory(void);
- // Destructor
+ // Destructor.
- virtual CosConcurrencyControl::LockSet_ptr create ( CORBA::Environment &env);
+ virtual CosConcurrencyControl::LockSet_ptr create (CORBA::Environment &env);
- virtual CosConcurrencyControl::LockSet_ptr
- create_related (CosConcurrencyControl::LockSet_ptr which,
- CORBA::Environment &env);
+ virtual CosConcurrencyControl::LockSet_ptr create_related (CosConcurrencyControl::LockSet_ptr which,
+ CORBA::Environment &env);
private:
ACE_Lock *lock_;
// Lock to serialize the access to the factory.
-}; // CC_LockSetFactory
-//#if defined (__ACE_INLINE__)
-//#include "CC_LockSetFactory.i"
-//#endif // defined INLINE
+};
-typedef CC_LockSetFactory *CC_LockSetFactory_var ;
+// @@ Torben, can you please add a comment as to why you need this
+// typedef?!
+typedef CC_LockSetFactory *CC_LockSetFactory_var;
#endif /* _CC_LOCKSETFACTORY_H */
diff --git a/TAO/orbsvcs/orbsvcs/Concurrency/Concurrency_Utils.cpp b/TAO/orbsvcs/orbsvcs/Concurrency/Concurrency_Utils.cpp
index 4e091c60467..1556f245210 100644
--- a/TAO/orbsvcs/orbsvcs/Concurrency/Concurrency_Utils.cpp
+++ b/TAO/orbsvcs/orbsvcs/Concurrency/Concurrency_Utils.cpp
@@ -8,10 +8,6 @@
// = FILENAME
// Concurrency_Utils.cpp
//
-// = DESCRIPTION
-//
-//
-//
// = AUTHOR
// Torben Worm <tworm@cs.wustl.edu>
//
@@ -36,8 +32,8 @@ TAO_Concurrency_Server::TAO_Concurrency_Server (CORBA::ORB_var &orb,
this->init (orb, poa);
}
-// Function to initialize the concurrency server object under the passed orb
-// and poa
+// Function to initialize the concurrency server object under the
+// passed orb and poa.
int
TAO_Concurrency_Server::init (CORBA::ORB_var &orb,
@@ -81,7 +77,8 @@ TAO_Concurrency_Server::init (CORBA::ORB_var &orb,
return 0;
}
-// Get the lock set factory
+// Get the lock set factory.
+
CC_LockSetFactory *
TAO_Concurrency_Server::GetLockSetFactory(void)
{
diff --git a/TAO/orbsvcs/orbsvcs/Concurrency/Concurrency_Utils.h b/TAO/orbsvcs/orbsvcs/Concurrency/Concurrency_Utils.h
index 5f2599a078e..06d5947e4cc 100644
--- a/TAO/orbsvcs/orbsvcs/Concurrency/Concurrency_Utils.h
+++ b/TAO/orbsvcs/orbsvcs/Concurrency/Concurrency_Utils.h
@@ -10,10 +10,10 @@
// Concurrency_Utils.h
//
// = DESCRIPTION
-// This class implements a Concurrency Server wrapper class which holds
-// a number of lock sets
-// The server must run in the thread per request concurrency model in
-// order to let the clients block on the semaphores.
+// This class implements a Concurrency Server wrapper class which
+// holds a number of lock sets. The server must run in the
+// thread per request concurrency model in order to let the
+// clients block on the semaphores.
//
// = AUTHORS
// Torben Worm <tworm@cs.wustl.edu>
@@ -34,11 +34,9 @@ class TAO_ORBSVCS_Export TAO_Concurrency_Server
// concurrency server.
//
// = DESCRIPTION
- //
- //
- //
- //
+ // @@ Torben, please fill in here...
public:
+ // = Initialization and termination methods.
TAO_Concurrency_Server (void);
//Default constructor.
@@ -47,18 +45,19 @@ public:
// Takes the POA under which to register the Concurrency Service
// implementation object.
+ ~TAO_Concurrency_Server (void);
+ // Destructor.
+
int init (CORBA::ORB_var &orb,
PortableServer::POA_var &poa);
// Initialize the concurrency server under the given ORB and POA.
CC_LockSetFactory *GetLockSetFactory(void);
- // Get the lock set factory
-
- ~TAO_Concurrency_Server (void);
- // Destructor.
+ // Get the lock set factory.
private:
CC_LockSetFactory lock_set_factory_;
+ // @@ Torben, please comment this.
};
#endif /* _CONCURRENCY_SERVER_H */
diff --git a/TAO/orbsvcs/orbsvcs/CosConcurrencyControl.idl b/TAO/orbsvcs/orbsvcs/CosConcurrencyControl.idl
index 7c6b7fe83d0..9c9415c6aee 100644
--- a/TAO/orbsvcs/orbsvcs/CosConcurrencyControl.idl
+++ b/TAO/orbsvcs/orbsvcs/CosConcurrencyControl.idl
@@ -32,16 +32,21 @@
#endif /* TAO_HAS_TRANSACTION_CONTROL_SERVICE */
module CosConcurrencyControl
-// = TITLE
-// CosConcurrencyControl
-//
-// = DESCRIPTION
-// This idl file describes the concurrency control service.
-// The purpose of the concurrency control service is to mediate
-// concurrent access to an pbject such that the consistency of
-// the object is not compromised when accessed by concurrently
-// executing computations.
{
+ // = TITLE
+ // CosConcurrencyControl
+ //
+ // = DESCRIPTION
+ // This idl file describes the concurrency control service. The
+ // purpose of the concurrency control service is to mediate
+ // concurrent access to an pbject such that the consistency of
+ // the object is not compromised when accessed by concurrently
+ // executing computations.
+
+ // = These are the different lock types supported by this module.
+
+ // For a description of the compatability between the different lock
+ // types please consult the service description (OMG).
enum lock_mode
{
read,
@@ -50,18 +55,15 @@ module CosConcurrencyControl
intention_read,
intention_write
};
- // This is the different lock types supported by this module. For a
- // description of the compatability between the different lock types
- // please consult the service description (OMG).
exception LockNotHeld {};
- // The LockNotHeld exception is is raised when an operation to unlock
- // or change the mode of a lock is called and the specified lock is not
- // held
+ // The LockNotHeld exception is is raised when an operation to
+ // unlock or change the mode of a lock is called and the specified
+ // lock is not held
#if defined (TAO_HAS_TRANSACTION_CONTROL_SERVICE)
- // @@TAO I'm in doubt here. The lock coordinator is designed for
- // transactional lock sets?? - tworm
+ // @@ The lock coordinator is designed for transactional lock sets,
+ // so we don't support it (yet).
interface LockCoordinator
{
// = TITLE
@@ -79,34 +81,37 @@ module CosConcurrencyControl
interface LockSet
{
// = TITLE
- // LockSet inteface to the concurrency service in implicit mode
+ // LockSet inteface to the concurrency service in implicit
+ // mode.
+ //
// = DESCRIPTION
- // Clients operating in the implicit mode (i.e. non-transactional
- // mode) acquire and release locks in lock sets throug this
- // interface. The interface only provides operations to acquire
- // and release locks on behalf of the calling thread or transaction.
+ // Clients operating in the implicit mode
+ // (i.e. non-transactional mode) acquire and release locks
+ // in lock sets throug this interface. The interface only
+ // provides operations to acquire and release locks on
+ // behalf of the calling thread or transaction.
void lock (in lock_mode mode);
- // Acquires a lock on the specified lock set in the specified mode.
- // Blocks until lock is obtained
+ // Acquires a lock on the specified lock set in the specified
+ // mode. Blocks until lock is obtained.
boolean try_lock (in lock_mode mode);
- // Tries to acquire a lock on the specified lock set. If it is not
- // possible to acquire the lock false is returned
+ // Tries to acquire a lock on the specified lock set. If it is
+ // not possible to acquire the lock false is returned.
void unlock (in lock_mode mode)
raises (LockNotHeld);
- // Releases a single lock on the specified lock set. A lock can be
- // held multiple times in the same mode. If the lock is not held the
- // exception LockNotHeld is raised
+ // Releases a single lock on the specified lock set. A lock can
+ // be held multiple times in the same mode. If the lock is not
+ // held the exception LockNotHeld is raised.
void change_mode (in lock_mode held_mode,
in lock_mode new_mode)
raises (LockNotHeld);
// Changes the mode of the lock on the specified lock set. If a
- // conflicting lock is held by another client the call blocks until
- // the new mode can be granted. If the lock is not held in the
- // specified mode the exception LockNotHeld is raised.
+ // conflicting lock is held by another client the call blocks
+ // until the new mode can be granted. If the lock is not held in
+ // the specified mode the exception LockNotHeld is raised.
#if defined (TAO_HAS_TRANSACTION_CONTROL_SERVICE)
LockCoordinator get_coordinator (in CosTransactions::Coordinator which);
@@ -120,15 +125,17 @@ module CosConcurrencyControl
{
// = TITLE
// TransactionalLockSet interface to the concurrency service
- // in transactional mode
+ // in transactional mode.
+ //
// = DESCRIPTION
// Clients operating in the transactional mode acquire and
// release locks in lock sets through this interface. The
// interface provides operations identical to the operations
- // described in the LockSet interface section. The difference
- // beeing that the coordinator for the transaction is explicitly
- // passed as a reference to the operations. Please see the
- // description of the LockSet interface for a detailed description.
+ // described in the LockSet interface section. The
+ // difference beeing that the coordinator for the
+ // transaction is explicitly passed as a reference to the
+ // operations. Please see the description of the LockSet
+ // interface for a detailed description.
void lock (in CosTransactions::Coordinator current,
in lock_mode mode);
@@ -157,10 +164,11 @@ module CosConcurrencyControl
interface LockSetFactory
{
// = TITLE
- // Factory interface for the LockSet and TransactionalLockSet
- // interfaces
+ // Factory interface for the LockSet and
+ // TransactionalLockSet interfaces.
+ //
// = DESCRIPTION
- // Factory for creating the lock sets
+ // Factory for creating the lock sets.
LockSet create ();
// Creates a new LockSet and lock coordinator
@@ -176,8 +184,7 @@ module CosConcurrencyControl
// Creates a new TransactionalLockSet and lock coordinator for
// transactional mode clients.
- TransactionalLockSet
- create_transactional_related (in TransactionalLockSet which);
+ TransactionalLockSet create_transactional_related (in TransactionalLockSet which);
// Creates a new transactional lock set related to the specified lock
// set. Related lock sets drop locks together.
#endif /* TAO_HAS_TRANSACTION_CONTROL_SERVICE */
diff --git a/TAO/orbsvcs/tests/Concurrency/CC_client.cpp b/TAO/orbsvcs/tests/Concurrency/CC_client.cpp
index f9f2ddfe0a2..5b79ca61cff 100644
--- a/TAO/orbsvcs/tests/Concurrency/CC_client.cpp
+++ b/TAO/orbsvcs/tests/Concurrency/CC_client.cpp
@@ -18,16 +18,17 @@ CC_Client::CC_Client (void)
CC_Client::~CC_Client (void)
{
- // Free resources
- // Close the ior files
+ // Free resources and close the ior files.
if (this->cc_factory_ior_file_)
ACE_OS::fclose (this->cc_factory_ior_file_);
+
if (this->f_handle_ != ACE_INVALID_HANDLE)
ACE_OS::close (this->f_handle_);
if (this->cc_factory_key_ != 0)
ACE_OS::free (this->cc_factory_key_);
- if(naming_service_!=0)
+
+ if (naming_service_!=0)
delete naming_service_;
}
@@ -71,7 +72,7 @@ CC_Client::parse_args (void)
break;
case 'e': // debug flag
run_extended_tests_ = 1;
- this->extended_tests_params_ = ACE_OS::strdup(get_opts.optarg);
+ this->extended_tests_params_ = ACE_OS::strdup (get_opts.optarg);
break;
case 'd': // debug flag
TAO_debug_level++;
@@ -96,8 +97,8 @@ CC_Client::parse_args (void)
break;
case 'h':
default:
- print_usage();
- ACE_ERROR_RETURN((LM_ERROR, ""), -1);
+ print_usage ();
+ ACE_ERROR_RETURN ((LM_ERROR, ""), -1);
}
// Indicates successful parsing of command line.
@@ -111,108 +112,111 @@ CC_Client::run (void)
{
int tests_run = 0;
// Tells whether any tests have been run
+
int success = CC_SUCCESS;
// Did test succeed?
- if(this->run_basic_tests_ && success==CC_SUCCESS)
+ if (this->run_basic_tests_ && success == CC_SUCCESS)
{
- success = run_basic_tests();
+ success = run_basic_tests ();
tests_run = 1;
}
- if(this->run_extended_tests_ && success==CC_SUCCESS)
+ if (this->run_extended_tests_ && success == CC_SUCCESS)
{
- success = run_extended_tests(this->extended_tests_params_);
+ success = run_extended_tests (this->extended_tests_params_);
tests_run = 1;
}
// Other tests go here
- // if(other_test_flag && success==CC_SUCCESS) ...
+ // if (other_test_flag && success == CC_SUCCESS) ...
if (this->shutdown_)
- {
- // @@TAO is this needed??
- }
+ // @@TAO is this needed??
- if (tests_run==0)
+ if (tests_run == 0)
{
- print_usage();
- ACE_ERROR_RETURN((LM_ERROR, "No tests given\n"), -1);
+ print_usage ();
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "No tests given\n"),
+ -1);
}
return success;
}
-
// This function runs basic tests concerned with only one lock set
+
int
-CC_Client::run_basic_tests(void)
+CC_Client::run_basic_tests (void)
{
int success = CC_FAIL;
- Test_Single_Lock_With_Mode t1(naming_service_,
- CosConcurrencyControl::read);
- Test_Single_Lock_With_Mode t2(naming_service_,
- CosConcurrencyControl::write);
- Test_Single_Lock_With_Mode t3(naming_service_,
- CosConcurrencyControl::upgrade);
- Test_Single_Lock_With_Mode t4(naming_service_,
- CosConcurrencyControl::intention_read);
- Test_Single_Lock_With_Mode t5(naming_service_,
- CosConcurrencyControl::intention_write);
- if( t1.run() == CC_SUCCESS &&
- t2.run() == CC_SUCCESS &&
- t3.run() == CC_SUCCESS &&
- t4.run() == CC_SUCCESS &&
- t5.run() == CC_SUCCESS )
+ Test_Single_Lock_With_Mode t1 (naming_service_,
+ CosConcurrencyControl::read);
+ Test_Single_Lock_With_Mode t2 (naming_service_,
+ CosConcurrencyControl::write);
+ Test_Single_Lock_With_Mode t3 (naming_service_,
+ CosConcurrencyControl::upgrade);
+ Test_Single_Lock_With_Mode t4 (naming_service_,
+ CosConcurrencyControl::intention_read);
+ Test_Single_Lock_With_Mode t5 (naming_service_,
+ CosConcurrencyControl::intention_write);
+ if (t1.run () == CC_SUCCESS &&
+ t2.run () == CC_SUCCESS &&
+ t3.run () == CC_SUCCESS &&
+ t4.run () == CC_SUCCESS &&
+ t5.run () == CC_SUCCESS)
return CC_SUCCESS;
else
return CC_FAIL;
}
int
-CC_Client::run_extended_tests(char *params)
+CC_Client::run_extended_tests (char *params)
{
char *test;
int success = CC_FAIL;
- ACE_DEBUG((LM_DEBUG, "Params: %s\n", params));
+ ACE_DEBUG ((LM_DEBUG,
+ "Params: %s\n",
+ params));
- char *cmd = strtok(params, ";");
- char *arg1 = strtok(NULL, ";");
- char *arg2 = strtok(NULL, ";");
+ char *cmd = ACE_OS::strtok (params, ";");
+ char *arg1 = ACE_OS::strtok (NULL, ";");
+ char *arg2 = ACE_OS::strtok (NULL, ";");
- // A possible scenario using test 1,2, and 3
- // Create and lock the lock set with the name 'Name'
+ // A possible scenario using test 1,2, and 3 Create and lock the
+ // lock set with the name 'Name'
// ./CC_client -e '1;Name'
// Try to lock the same lock set. The process will hang
// ./CC_client -e '2:Name'
// Unlocks the lock set. Now test 2 will continue.
// ./CC_client -e '3:Name'
- if(strcmp(cmd, "1")==0)
+ if (ACE_OS::strcmp (cmd, "1") == 0)
{
- Test_Setup_LockSet t1(naming_service_, arg1);
- success = t1.run();
+ Test_Setup_LockSet t1 (naming_service_, arg1);
+ success = t1.run ();
}
- if(strcmp(cmd, "2")==0)
+ if (ACE_OS::strcmp (cmd, "2") == 0)
{
- Test_Use_Already_Created_LockSet t2(naming_service_, arg1);
- success = t2.run();
+ Test_Use_Already_Created_LockSet t2 (naming_service_, arg1);
+ success = t2.run ();
}
- if(strcmp(cmd, "3")==0)
+ if (ACE_OS::strcmp (cmd, "3") == 0)
{
- Test_Unlock_Already_Created_LockSet t3(naming_service_, arg1);
- success = t3.run();
+ Test_Unlock_Already_Created_LockSet t3 (naming_service_, arg1);
+ success = t3.run ();
}
return success;
}
void
-CC_Client::print_usage(void)
+CC_Client::print_usage (void)
{
ACE_ERROR ((LM_ERROR,
"usage: %s"
@@ -229,8 +233,9 @@ CC_Client::print_usage(void)
int
CC_Client::init_naming_service (void)
{
- naming_service_ = new CC_naming_service(this->orb_);
-
+ ACE_NEW_RETURN (naming_service_,
+ CC_naming_service (this->orb_),
+ -1);
return 0;
}
@@ -274,20 +279,23 @@ CC_Client::init (int argc, char **argv)
TAO_TRY_ENV);
TAO_CHECK_ENV;
- /* The test cannot currently run without the naming service
- this->factory_ =
+#if 0
+ // The test cannot currently run without the naming service.
+ this->factory_ =
CosConcurrencyControl::LockSetFactory::_narrow
- (factory_object.in(), TAO_TRY_ENV);
+ (factory_object.in (), TAO_TRY_ENV);
TAO_CHECK_ENV;
if (CORBA::is_nil (this->factory_.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
"invalid factory key <%s>\n",
this->cc_factory_key_),
- -1);*/
+ -1);
+#endif /* 0 */
}
- ACE_DEBUG ((LM_DEBUG, "Factory received OK\n"));
+ ACE_DEBUG ((LM_DEBUG,
+ "Factory received OK\n"));
}
TAO_CATCHANY
@@ -312,12 +320,14 @@ main (int argc, char **argv)
if (cc_client.init (argc, argv) == -1)
{
- ACE_DEBUG((LM_DEBUG, "Did not initialize correctly\n"));
- return 1;
+ ACE_DEBUG ((LM_DEBUG,
+ "Did not initialize correctly\n"));
+ return 1;
}
else
{
- ACE_DEBUG((LM_DEBUG, "Running the test\n"));
+ ACE_DEBUG ((LM_DEBUG,
+ "Running the test\n"));
return cc_client.run ();
}
}
diff --git a/TAO/orbsvcs/tests/Concurrency/CC_client.h b/TAO/orbsvcs/tests/Concurrency/CC_client.h
index 6046c132d22..842b117d3ad 100644
--- a/TAO/orbsvcs/tests/Concurrency/CC_client.h
+++ b/TAO/orbsvcs/tests/Concurrency/CC_client.h
@@ -1,5 +1,6 @@
// -*- c++ -*-
// $Id$
+
// ============================================================================
//
// = LIBRARY
@@ -30,51 +31,52 @@
class CC_Client
{
// = TITLE
- // Defines a class that encapsulates the behaviour of a clien of the
- // concurrency service.
+ // Defines a class that encapsulates the behaviour of a clien of
+ // the concurrency service.
//
// = DESCRIPTION
- // This class declares an interface to run the test client for the
- // concurrency service.
- //
+ // This class declares an interface to run the test client for
+ // the concurrency service.
public:
- CC_Client(void);
- // Default constructor
+ // = Initialization and termination methods.
+ CC_Client (void);
+ // Default constructor.
- ~CC_Client(void);
+ ~CC_Client (void);
+ // Destructor.
- int run(void);
- // Run the test
+ int run (void);
+ // Run the test.
- int init(int argc, char **argv);
- // Initialize the test with the parameters from the command line
+ int init (int argc, char **argv);
+ // Initialize the test with the parameters from the command line.
private:
- int init_naming_service(void);
+ int init_naming_service (void);
// Function to initialize the naming service.
CC_naming_service *naming_service_;
- // A pointer to the naming service used for this test
+ // A pointer to the naming service used for this test.
- int parse_args(void);
- // Function to parse the command line arguments
+ int parse_args (void);
+ // Function to parse the command line arguments.
- int read_ior(char *filename);
- // Function to read the ior from the given file
+ int read_ior (char *filename);
+ // Function to read the ior from the given file.
- int run_basic_tests(void);
+ int run_basic_tests (void);
// Runs the basic tests (on a single lock set). Returns CC_SUCCESS
- // upon success CC_FAIL otherwise
+ // upon success CC_FAIL otherwise.
- int run_extended_tests(char *params);
+ int run_extended_tests (char *params);
// Runs the extended tests (on more lock sets). Returns CC_SUCCESS
- // upon success CC_FAIL otherwise
+ // upon success CC_FAIL otherwise.
FILE *cc_factory_ior_file_;
// File from which to obtain the IOR.
char *cc_factory_key_;
- // The factory key for the lock set factory
+ // The factory key for the lock set factory.
ACE_HANDLE f_handle_;
// File handle to read the IOR.
@@ -90,26 +92,26 @@ private:
// service is not used (for simple testing)
int argc_;
- // The number of arguments passed on the command line
+ // The number of arguments passed on the command line.
char **argv_;
- // The arguments from the command line
+ // The arguments from the command line.
int use_naming_service_;
// Flag to tell the client whether to use the naming service or not
// to find the concurrency control factory.
int run_basic_tests_;
- // flag to tell which test should be run
+ // flag to tell which test should be run.
int run_extended_tests_;
- // flag to tell which test should be run
+ // flag to tell which test should be run.
char *extended_tests_params_;
- // Parameters to the extended tests. The parameters are of the following
- // format: <test>:<parm1>:<parm2>...
+ // Parameters to the extended tests. The parameters are of the
+ // following format: <test>:<parm1>:<parm2>...
- void print_usage(void);
- // Prints out the options to the program
+ void print_usage (void);
+ // Prints out the options to the program.
};
-#endif /* !defined(_CC_CLIENT_H_) */
+#endif /* !defined (_CC_CLIENT_H_) */
diff --git a/TAO/orbsvcs/tests/Concurrency/CC_naming_service.cpp b/TAO/orbsvcs/tests/Concurrency/CC_naming_service.cpp
index 5794e75a701..3e1bba8dfbd 100644
--- a/TAO/orbsvcs/tests/Concurrency/CC_naming_service.cpp
+++ b/TAO/orbsvcs/tests/Concurrency/CC_naming_service.cpp
@@ -1,5 +1,6 @@
// -*- c++ -*-
// $Id$
+
// ============================================================================
//
// = LIBRARY
@@ -19,7 +20,7 @@
#include "CC_naming_service.h"
-CC_naming_service::CC_naming_service(CORBA::ORB_var orb)
+CC_naming_service::CC_naming_service (CORBA::ORB_var orb)
: naming_context_ (0),
cc_factory_key_ (0),
orb_ (0),
@@ -27,23 +28,23 @@ CC_naming_service::CC_naming_service(CORBA::ORB_var orb)
{
this->orb_ = orb;
- init_naming_service();
+ init_naming_service ();
}
-CC_naming_service::~CC_naming_service(void)
+CC_naming_service::~CC_naming_service (void)
{
}
CORBA::Object_var
-CC_naming_service::get_obj_from_name(char *c_name, char *name,
- CORBA::Environment &_env)
+CC_naming_service::get_obj_from_name (char *c_name, char *name,
+ CORBA::Environment &env)
{
- ACE_DEBUG((LM_DEBUG, "C: %s, N: %s\n", c_name, name));
+ ACE_DEBUG ((LM_DEBUG, "C: %s, N: %s\n", c_name, name));
CORBA::Object_var obj;
TAO_TRY
{
- if(strlen(c_name)==0)
+ if (ACE_OS::strlen (c_name) == 0)
{
CosNaming::Name ns_name (1);
ns_name.length (1);
@@ -61,7 +62,7 @@ CC_naming_service::get_obj_from_name(char *c_name, char *name,
}
TAO_CATCHANY
{
- TAO_TRY_ENV.print_exception ("CC_Client::get_obj_from_name(...)");
+ TAO_TRY_ENV.print_exception ("CC_Client::get_obj_from_name (...)");
return 0;
}
TAO_ENDTRY;
@@ -70,53 +71,54 @@ CC_naming_service::get_obj_from_name(char *c_name, char *name,
}
void
-CC_naming_service::bind_name(char *n,
+CC_naming_service::bind_name (char *n,
CORBA::Object_ptr obj,
- CORBA::Environment &_env)
+ CORBA::Environment &env)
{
- ACE_DEBUG((LM_DEBUG, "CC_Client::bind_name\n"));
+ ACE_DEBUG ((LM_DEBUG, "CC_Client::bind_name\n"));
TAO_TRY
{
CosNaming::Name ns_name (1);
- ns_name.length(1);
+ ns_name.length (1);
ns_name[0].id = CORBA::string_dup (n);
- naming_context_->bind(ns_name,
+ naming_context_->bind (ns_name,
obj,
- _env);
+ env);
}
TAO_CATCHANY
{
- TAO_TRY_ENV.print_exception ("CC_Client::bind_name(...)");
+ TAO_TRY_ENV.print_exception ("CC_Client::bind_name (...)");
}
TAO_ENDTRY;
}
CosConcurrencyControl::LockSetFactory_var
-CC_naming_service::get_lock_set_factory(void)
+CC_naming_service::get_lock_set_factory (void)
{
return this->factory_;
}
int
-CC_naming_service::init_naming_service(void)
+CC_naming_service::init_naming_service (void)
{
TAO_TRY
{
CORBA::Object_var naming_obj =
this->orb_->resolve_initial_references ("NameService");
+
if (CORBA::is_nil (naming_obj.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
" (%P|%t) Unable to resolve the Name Service.\n"),
-1);
- naming_context_ =
+ this->naming_context_ =
CosNaming::NamingContext::_narrow (naming_obj.in (),
TAO_TRY_ENV);
TAO_CHECK_ENV;
- CORBA::Object_var factory_obj = get_obj_from_name("CosConcurrency",
- "LockSetFactory",
- TAO_TRY_ENV);
+ CORBA::Object_var factory_obj = get_obj_from_name ("CosConcurrency",
+ "LockSetFactory",
+ TAO_TRY_ENV);
TAO_CHECK_ENV;
this->factory_ =
diff --git a/TAO/orbsvcs/tests/Concurrency/CC_naming_service.h b/TAO/orbsvcs/tests/Concurrency/CC_naming_service.h
index d52e666c4d7..998d2e17895 100644
--- a/TAO/orbsvcs/tests/Concurrency/CC_naming_service.h
+++ b/TAO/orbsvcs/tests/Concurrency/CC_naming_service.h
@@ -1,5 +1,6 @@
// -*- c++ -*-
// $Id$
+
// ============================================================================
//
// = LIBRARY
@@ -10,7 +11,7 @@
//
// = DESCRIPTION
// This class implements the naming services necessary to test the
-// concurrency service
+// concurrency service.
//
// = AUTHORS
// Torben Worm <tworm@cs.wustl.edu>
@@ -21,7 +22,7 @@
#include "orbsvcs/CosConcurrencyControlC.h"
#include "orbsvcs/CosNamingC.h"
-#if !defined(_CC_NAMING_SERVICE_H_)
+#if !defined (_CC_NAMING_SERVICE_H_)
#define _CC_NAMING_SERVICE_H_
class CC_naming_service
@@ -33,33 +34,32 @@ class CC_naming_service
// = DESCRIPTION
// This class declares an interface to the naming service for the
// concurrency service tests.
- //
public:
- CC_naming_service(CORBA::ORB_var orb_);
+ CC_naming_service (CORBA::ORB_var orb_);
// Default constructor
- ~CC_naming_service(void);
- // Default destructor
+ ~CC_naming_service (void);
+ // Default destructor.
- CORBA::Object_var get_obj_from_name(char *c_name, char *name,
- CORBA::Environment &_env);
+ CORBA::Object_var get_obj_from_name (char *c_name, char *name,
+ CORBA::Environment &_env);
// Lookup a name in the naming service (context, name)
void
- bind_name(char *n,
- CORBA::Object_ptr obj,
- CORBA::Environment &_env);
- // Bind a name in the concurrency context
+ bind_name (char *n,
+ CORBA::Object_ptr obj,
+ CORBA::Environment &_env);
+ // Bind a name in the concurrency context.
- CosConcurrencyControl::LockSetFactory_var get_lock_set_factory(void);
- // Gets the cc lock set factory which is common for all tests
+ CosConcurrencyControl::LockSetFactory_var get_lock_set_factory (void);
+ // Gets the cc lock set factory which is common for all tests.
private:
- int init_naming_service(void);
+ int init_naming_service (void);
// Function to initialize the naming service.
CosNaming::NamingContext_var naming_context_;
- // Naming service object for this object
+ // Naming service object for this object.
char *cc_factory_key_;
// Key of factory obj ref.
@@ -70,4 +70,4 @@ private:
CosConcurrencyControl::LockSetFactory_var factory_;
// factory pointer for the lock set.
};
-#endif /* !defined(_CC_NAMING_SERVICE_H_) */
+#endif /* !defined (_CC_NAMING_SERVICE_H_) */
diff --git a/TAO/orbsvcs/tests/Concurrency/CC_tests.cpp b/TAO/orbsvcs/tests/Concurrency/CC_tests.cpp
index 8320e483934..24fc5d77fbc 100644
--- a/TAO/orbsvcs/tests/Concurrency/CC_tests.cpp
+++ b/TAO/orbsvcs/tests/Concurrency/CC_tests.cpp
@@ -1,5 +1,6 @@
// -*- c++ -*-
// $Id$
+
// ============================================================================
//
// = LIBRARY
@@ -19,26 +20,27 @@
#include "CC_tests.h"
-CC_Test::CC_Test(CC_naming_service *ns)
- : result (CC_FAIL), naming_service_ (ns)
+CC_Test::CC_Test (CC_naming_service *ns)
+ : result (CC_FAIL),
+ naming_service_ (ns)
{
}
-CC_Test::~CC_Test(void)
+CC_Test::~CC_Test (void)
{
}
-CosConcurrencyControl::LockSet_ptr
-CC_Test:: create_lock_set(void)
+CosConcurrencyControl::LockSet_ptr
+CC_Test::create_lock_set (void)
{
- // Create the lock set and return an obj ref corresponding
- // to the key.
+ // Create the lock set and return an obj ref corresponding to the
+ // key.
CosConcurrencyControl::LockSet_ptr lock_set;
TAO_TRY
{
- lock_set =
- this->naming_service_->get_lock_set_factory()->create (TAO_TRY_ENV);
+ lock_set =
+ this->naming_service_->get_lock_set_factory ()->create (TAO_TRY_ENV);
TAO_CHECK_ENV;
if (CORBA::is_nil (lock_set))
@@ -55,72 +57,87 @@ CC_Test:: create_lock_set(void)
return lock_set;
}
-char *CC_Test::get_lock_mode_name(CosConcurrencyControl::lock_mode mode)
+char *
+CC_Test::get_lock_mode_name (CosConcurrencyControl::lock_mode mode)
{
- if(mode==CosConcurrencyControl::read)
+ if (mode==CosConcurrencyControl::read)
return "read";
- if(mode==CosConcurrencyControl::write)
+ if (mode==CosConcurrencyControl::write)
return "write";
- if(mode==CosConcurrencyControl::upgrade)
+ if (mode==CosConcurrencyControl::upgrade)
return "upgrade";
- if(mode==CosConcurrencyControl::intention_read)
+ if (mode==CosConcurrencyControl::intention_read)
return "intension_read";
- if(mode==CosConcurrencyControl::intention_write)
+ if (mode==CosConcurrencyControl::intention_write)
return "intension_write";
return "unknown lock mode";
}
-// Here the test start
+// Here is the test start.
-Test_Single_Lock_With_Mode::
-Test_Single_Lock_With_Mode(CC_naming_service *naming_service,
- CosConcurrencyControl::lock_mode mode)
- : CC_Test (naming_service), mode_ (mode)
+Test_Single_Lock_With_Mode::Test_Single_Lock_With_Mode (CC_naming_service *naming_service,
+ CosConcurrencyControl::lock_mode mode)
+ : CC_Test (naming_service),
+ mode_ (mode)
{
}
-Test_Single_Lock_With_Mode::~Test_Single_Lock_With_Mode()
+Test_Single_Lock_With_Mode::~Test_Single_Lock_With_Mode (void)
{
}
-Test_Single_Lock_With_Mode::run(int times_to_run)
+int
+Test_Single_Lock_With_Mode::run (int times_to_run)
{
CORBA::Boolean lock_not_held;
- CosConcurrencyControl::LockSet_ptr cc_lock_set_ = create_lock_set();
+ CosConcurrencyControl::LockSet_ptr cc_lock_set_ = create_lock_set ();
TAO_TRY
{
- cc_lock_set_->lock(mode_, TAO_TRY_ENV);
- ACE_DEBUG((LM_DEBUG, "%s lock set\n", get_lock_mode_name(mode_)));
+ cc_lock_set_->lock (mode_, TAO_TRY_ENV);
+ ACE_DEBUG ((LM_DEBUG,
+ "%s lock set\n",
+ get_lock_mode_name (mode_)));
+
+ lock_not_held = cc_lock_set_->try_lock (mode_,
+ TAO_TRY_ENV);
- lock_not_held = cc_lock_set_->try_lock(mode_, TAO_TRY_ENV);
- if(lock_not_held)
+ if (lock_not_held)
{
- ACE_DEBUG((LM_DEBUG, "%s lock not held\n",
- get_lock_mode_name(mode_)));
+ ACE_DEBUG ((LM_DEBUG,
+ "%s lock not held\n",
+ get_lock_mode_name (mode_)));
return CC_FAIL;
}
else
- ACE_DEBUG((LM_DEBUG, "%s lock held\n", get_lock_mode_name(mode_)));
+ ACE_DEBUG ((LM_DEBUG,
+ "%s lock held\n",
+ get_lock_mode_name (mode_)));
- cc_lock_set_->unlock(mode_, TAO_TRY_ENV);
- ACE_DEBUG((LM_DEBUG, "%s lock released\n", get_lock_mode_name(mode_)));
+ cc_lock_set_->unlock (mode_,
+ TAO_TRY_ENV);
+ ACE_DEBUG ((LM_DEBUG,
+ "%s lock released\n",
+ get_lock_mode_name (mode_)));
- lock_not_held = cc_lock_set_->try_lock(mode_, TAO_TRY_ENV);
- if(lock_not_held)
- {
- ACE_DEBUG((LM_DEBUG, "%s lock not held\n",
- get_lock_mode_name(mode_)));
- }
+ lock_not_held = cc_lock_set_->try_lock (mode_,
+ TAO_TRY_ENV);
+
+ if (lock_not_held)
+ ACE_DEBUG ((LM_DEBUG,
+ "%s lock not held\n",
+ get_lock_mode_name (mode_)));
else
{
- ACE_DEBUG((LM_DEBUG, "%s lock held\n", get_lock_mode_name(mode_)));
+ ACE_DEBUG ((LM_DEBUG,
+ "%s lock held\n",
+ get_lock_mode_name (mode_)));
return CC_FAIL;
}
@@ -137,29 +154,35 @@ Test_Single_Lock_With_Mode::run(int times_to_run)
return CC_SUCCESS;
}
-Test_Setup_LockSet::Test_Setup_LockSet(CC_naming_service *naming_service,
- char *name)
- : CC_Test (naming_service), my_name_ (name)
+Test_Setup_LockSet::Test_Setup_LockSet (CC_naming_service *naming_service,
+ char *name)
+ : CC_Test (naming_service),
+ my_name_ (name)
{
}
-Test_Setup_LockSet::~Test_Setup_LockSet()
+Test_Setup_LockSet::~Test_Setup_LockSet (void)
{
}
-int Test_Setup_LockSet::run(int times_to_run)
+int
+Test_Setup_LockSet::run (int times_to_run)
{
CORBA::Boolean lock_held = CORBA::B_FALSE;
TAO_TRY
{
- CosConcurrencyControl::LockSet_ptr cc_lock_set_ = create_lock_set();
- this->naming_service_->bind_name(my_name_, cc_lock_set_,
- TAO_TRY_ENV);
- ACE_DEBUG((LM_DEBUG, "Name bound\n"));
+ CosConcurrencyControl::LockSet_ptr cc_lock_set_ =
+ create_lock_set ();
+ this->naming_service_->bind_name (my_name_, cc_lock_set_,
+ TAO_TRY_ENV);
+ ACE_DEBUG ((LM_DEBUG,
+ "Name bound\n"));
- cc_lock_set_->lock(CosConcurrencyControl::read, TAO_TRY_ENV);
- ACE_DEBUG((LM_DEBUG, "Read lock set\n"));
+ cc_lock_set_->lock (CosConcurrencyControl::read,
+ TAO_TRY_ENV);
+ ACE_DEBUG ((LM_DEBUG,
+ "Read lock set\n"));
}
TAO_CATCHANY
{
@@ -172,29 +195,34 @@ int Test_Setup_LockSet::run(int times_to_run)
}
Test_Use_Already_Created_LockSet::
-Test_Use_Already_Created_LockSet(CC_naming_service *naming_service,
- char *name)
- : CC_Test (naming_service), my_name_ (name)
+Test_Use_Already_Created_LockSet (CC_naming_service *naming_service,
+ char *name)
+ : CC_Test (naming_service),
+ my_name_ (name)
{
}
-Test_Use_Already_Created_LockSet::~Test_Use_Already_Created_LockSet()
+Test_Use_Already_Created_LockSet::~Test_Use_Already_Created_LockSet (void)
{
}
-int Test_Use_Already_Created_LockSet::run(int times_to_run)
+int
+Test_Use_Already_Created_LockSet::run (int times_to_run)
{
CORBA::Boolean lock_held = CORBA::B_FALSE;
TAO_TRY
{
CORBA::Object_var ccls_obj =
- this->naming_service_->get_obj_from_name("", my_name_,
- TAO_TRY_ENV);
+ this->naming_service_->get_obj_from_name ("",
+ my_name_,
+ TAO_TRY_ENV);
CosConcurrencyControl::LockSet_var ccls =
- CosConcurrencyControl::LockSet::_narrow(ccls_obj.in(), TAO_TRY_ENV);
+ CosConcurrencyControl::LockSet::_narrow (ccls_obj.in (),
+ TAO_TRY_ENV);
- ccls->lock(CosConcurrencyControl::read, TAO_TRY_ENV);
+ ccls->lock (CosConcurrencyControl::read,
+ TAO_TRY_ENV);
}
TAO_CATCHANY
{
@@ -207,29 +235,33 @@ int Test_Use_Already_Created_LockSet::run(int times_to_run)
}
Test_Unlock_Already_Created_LockSet::
-Test_Unlock_Already_Created_LockSet(CC_naming_service *naming_service,
- char *name)
- : CC_Test (naming_service), my_name_ (name)
+Test_Unlock_Already_Created_LockSet (CC_naming_service *naming_service,
+ char *name)
+ : CC_Test (naming_service),
+ my_name_ (name)
{
}
-Test_Unlock_Already_Created_LockSet::~Test_Unlock_Already_Created_LockSet()
+Test_Unlock_Already_Created_LockSet::~Test_Unlock_Already_Created_LockSet (void)
{
}
-int Test_Unlock_Already_Created_LockSet::run(int times_to_run)
+int
+Test_Unlock_Already_Created_LockSet::run (int times_to_run)
{
CORBA::Boolean lock_held = CORBA::B_FALSE;
TAO_TRY
{
CORBA::Object_var ccls_obj =
- this->naming_service_->get_obj_from_name("", my_name_,
+ this->naming_service_->get_obj_from_name ("", my_name_,
TAO_TRY_ENV);
CosConcurrencyControl::LockSet_var ccls =
- CosConcurrencyControl::LockSet::_narrow(ccls_obj.in(), TAO_TRY_ENV);
+ CosConcurrencyControl::LockSet::_narrow (ccls_obj.in (),
+ TAO_TRY_ENV);
- ccls->unlock(CosConcurrencyControl::read, TAO_TRY_ENV);
+ ccls->unlock (CosConcurrencyControl::read,
+ TAO_TRY_ENV);
}
TAO_CATCHANY
{
diff --git a/TAO/orbsvcs/tests/Concurrency/CC_tests.h b/TAO/orbsvcs/tests/Concurrency/CC_tests.h
index cb9fa730b30..578a9275289 100644
--- a/TAO/orbsvcs/tests/Concurrency/CC_tests.h
+++ b/TAO/orbsvcs/tests/Concurrency/CC_tests.h
@@ -1,5 +1,6 @@
// -*- c++ -*-
// $Id$
+
// ============================================================================
//
// = LIBRARY
@@ -22,11 +23,15 @@
#include "orbsvcs/CosNamingC.h"
#include "CC_naming_service.h"
-#if !defined(_CC_TESTS_H_)
+#if !defined (_CC_TESTS_H_)
#define _CC_TESTS_H_
-enum {CC_FAIL, CC_SUCCESS = 1};
// Return codes for the tests
+enum
+{
+ CC_FAIL,
+ CC_SUCCESS = 1
+};
class CC_Test
{
@@ -36,87 +41,97 @@ class CC_Test
// = DESCRIPTION
// This class declares an interface to run the test of the
// concurrency service.
- //
public:
- CC_Test(CC_naming_service *ns);
+ CC_Test (CC_naming_service *ns);
// Default constructor
- ~CC_Test(void);
+ ~CC_Test (void);
// Destructor
- virtual int run(int times_to_run = 1) = 0;
- // Run the test times_to_run number of times. Returns CC_SUCCESS on success
- // CC_FAIL otherwise
+ virtual int run (int times_to_run = 1) = 0;
+ // Run the test times_to_run number of times. Returns CC_SUCCESS on
+ // success CC_FAIL otherwise.
- CosConcurrencyControl::LockSet_ptr
- create_lock_set(void);
- // Create a new lock set using the default global lock set factory from
- // the naming service
+ CosConcurrencyControl::LockSet_ptr create_lock_set (void);
+ // Create a new lock set using the default global lock set factory
+ // from the naming service.
- char *get_lock_mode_name(CosConcurrencyControl::lock_mode mode);
- // Returns a human readable string from the lock mode enum
+ char *get_lock_mode_name (CosConcurrencyControl::lock_mode mode);
+ // Returns a human readable string from the lock mode enum.
protected:
int result;
CC_naming_service *naming_service_;
-private:
};
-// This is a simple test that checks that it is possible to set the lock
-// in the desired mode, try it, and release it.
class Test_Single_Lock_With_Mode : public CC_Test
{
+ // = TITLE
+ // This is a simple test that checks that it is possible to set
+ // the lock in the desired mode, try it, and release it.
public:
- Test_Single_Lock_With_Mode(CC_naming_service *naming_service,
- CosConcurrencyControl::lock_mode mode);
+ // @@ Torben, can you please document these methods?
+ Test_Single_Lock_With_Mode (CC_naming_service *naming_service,
+ CosConcurrencyControl::lock_mode mode);
+ ~Test_Single_Lock_With_Mode (void);
- ~Test_Single_Lock_With_Mode();
+ virtual int run (int times_to_run = 1);
- virtual int run(int times_to_run = 1);
private:
CosConcurrencyControl::lock_mode mode_;
};
-// This class creates a read lock, registeres it with the naming
-// service and locks it.
class Test_Setup_LockSet : public CC_Test
{
+ // = TITLE
+ // This class creates a read lock, registeres it with the naming
+ // service and locks it.
public:
- Test_Setup_LockSet(CC_naming_service *naming_service_, char *name);
+ // @@ Torben, can you please document these methods?
+ Test_Setup_LockSet (CC_naming_service *naming_service_,
+ char *name);
- ~Test_Setup_LockSet();
+ ~Test_Setup_LockSet (void);
+
+ virtual int run (int times_to_run = 1);
- virtual int run(int times_to_run = 1);
private:
char *my_name_;
};
-// This class looks up the lock in the naming service and locks it
class Test_Use_Already_Created_LockSet : public CC_Test
{
+ // = TITLE
+ // This class looks up the lock in the naming service and locks
+ // it.
public:
- Test_Use_Already_Created_LockSet(CC_naming_service *naming_service_,
+ // @@ Torben, can you please document these methods?
+ Test_Use_Already_Created_LockSet (CC_naming_service *naming_service_,
char *name);
- ~Test_Use_Already_Created_LockSet();
+ ~Test_Use_Already_Created_LockSet (void);
- virtual int run(int times_to_run = 1);
+ virtual int run (int times_to_run = 1);
private:
char *my_name_;
};
-// This class looks up the lock in the naming service and unlocks it
class Test_Unlock_Already_Created_LockSet : public CC_Test
{
+ // = TITLE
+ // This class looks up the lock in the naming service and unlocks
+ // it.
public:
- Test_Unlock_Already_Created_LockSet(CC_naming_service *naming_service_,
- char *name);
+ // @@ Torben, can you please document these methods?
+ Test_Unlock_Already_Created_LockSet (CC_naming_service *naming_service_,
+ char *name);
- ~Test_Unlock_Already_Created_LockSet();
+ ~Test_Unlock_Already_Created_LockSet (void);
- virtual int run(int times_to_run = 1);
+ virtual int run (int times_to_run = 1);
+
private:
char *my_name_;
};
-#endif /* !defined(_CC_TESTS_H_) */
+#endif /* !defined (_CC_TESTS_H_) */
diff --git a/TAO/orbsvcs/tests/Concurrency/NS_client.cpp b/TAO/orbsvcs/tests/Concurrency/NS_client.cpp
index 58c734e440b..dd8861fe444 100644
--- a/TAO/orbsvcs/tests/Concurrency/NS_client.cpp
+++ b/TAO/orbsvcs/tests/Concurrency/NS_client.cpp
@@ -84,13 +84,15 @@ CosNaming_Client::run (void)
{
// @@ TODO, add some interesting test here, maybe creating some
// nested naming contexts and registering a number of objreferences
- // in there.
- // We could even use the iterators.
+ // in there. We could even use the iterators.
+
+ if (this->resolve_name_)
+ resolve_name (this->context_to_resolve_,
+ this->name_to_resolve_);
+
+ if (this->list_contents_)
+ list_contents ();
- if(this->resolve_name_)
- resolve_name(this->context_to_resolve_, this->name_to_resolve_);
- if(this->list_contents_)
- list_contents();
return 0;
}
@@ -99,7 +101,7 @@ CosNaming_Client::~CosNaming_Client (void)
}
int
-CosNaming_Client::resolve_name(char *c, char *n)
+CosNaming_Client::resolve_name (char *c, char *n)
{
TAO_TRY
{
@@ -124,7 +126,7 @@ CosNaming_Client::resolve_name(char *c, char *n)
}
void
-CosNaming_Client::list_contents(void)
+CosNaming_Client::list_contents (void)
{
CosNaming::BindingIterator_var bi;
CosNaming::BindingList_var li;
@@ -136,18 +138,24 @@ CosNaming_Client::list_contents(void)
TAO_TRY
{
- this->naming_context_->list(how_many, li, bi, TAO_TRY_ENV);
+ this->naming_context_->list (how_many, li, bi, TAO_TRY_ENV);
- while(more = bi->next_one(b, TAO_TRY_ENV))
+ while (more = bi->next_one (b, TAO_TRY_ENV))
{
n = b->binding_name;
- names = n.length();
- printf("(%i) Name: ", names);
- for(int i=0; i<names; i++)
- printf("%s ", n[i].id._retn());
- printf("type: %s\n",
- (b->binding_type==CosNaming::ncontext)?"C":"O");
- };
+ names = n.length ();
+ ACE_DEBUG ((LM_DEBUG,
+ " (%i) Name: ",
+ names));
+
+ for (int i = 0; i < names; i++)
+ ACE_DEBUG ((LM_DEBUG,
+ "%s ",
+ n[i].id._retn ()));
+
+ ACE_DEBUG ((LM_DEBUG, "type: %s\n",
+ b->binding_type == CosNaming::ncontext ? "C" : "O"));
+ }
}
TAO_CATCHANY
{
@@ -169,6 +177,7 @@ CosNaming_Client::init (int argc, char **argv)
CORBA::Object_var naming_obj =
orb_->resolve_initial_references ("NameService");
+
if (CORBA::is_nil (naming_obj.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
" (%P|%t) Unable to initialize the POA.\n"),
diff --git a/TAO/orbsvcs/tests/Concurrency/NS_client.h b/TAO/orbsvcs/tests/Concurrency/NS_client.h
index cfa872ffb48..411a314f798 100644
--- a/TAO/orbsvcs/tests/Concurrency/NS_client.h
+++ b/TAO/orbsvcs/tests/Concurrency/NS_client.h
@@ -10,8 +10,8 @@
// NS_client.h
//
// = DESCRIPTION
-// This class tests the facilities to connect to the naming service
-// and to resolve the name for the concurrency service client.
+// This class tests the facilities to connect to the naming
+// service and to resolve the name for the concurrency service client.
//
// = AUTHORS
// Sergio Flores-Gaitan <sergio@cs.wustl.edu>
@@ -24,20 +24,24 @@
#include "orbsvcs/orbsvcs/CosNamingC.h"
class CosNaming_Client
+{
// = TITLE
- // Defines a class that encapsulates behaviour of the CosNaming client
- // example. Provides a better understanding of the logic in an
- // object oriented way.
+ // Defines a class that encapsulates behaviour of the CosNaming
+ // client example. Provides a better understanding of the logic
+ // in an object oriented way.
//
// = DESCRIPTION
// This class declares an interface to run the example client for
- // CosNaming CORBA server. All the complexity for initializing the
- // server is hidden in the class. Just the run() interface is needed.
-{
+ // CosNaming CORBA server. All the complexity for initializing
+ // the server is hidden in the class. Just the run() interface
+ // is needed.
public:
- // = Constructor and destructor.
+ // = Initialization and termination methods.
CosNaming_Client (void);
+ // Constructor.
+
~CosNaming_Client (void);
+ // Destructor.
int run (void);
// Execute client example code.
@@ -50,28 +54,28 @@ private:
// Parses the arguments passed on the command line.
int resolve_name(char *c, char *n);
- // Resolves the name given on the commandlinn (-n option)
+ // Resolves the name given on the command-line (-n option).
void list_contents(void);
- // lists the contents of the naming service
+ // Lists the contents of the naming service.
CORBA::ORB_var orb_;
- // Our ORB
+ // Our ORB.
CosNaming::NamingContext_var naming_context_;
- // Our naming context
+ // Our naming context.
int list_contents_;
- // Iterate through the naming service and list the contents
+ // Iterate through the naming service and list the contents.
int resolve_name_;
- // Flag set by the -n option
+ // Flag set by the -n option.
char *name_to_resolve_;
- // Parameter given to the -n option
+ // Parameter given to the -n option.
char *context_to_resolve_;
- // Parameter given to the -c option
+ // Parameter given to the -c option.
int argc_;
// # of arguments on the command line.
diff --git a/TAO/tests/NestedUpcall/README b/TAO/tests/NestedUpcall/README
index 29153b044e8..a1147be10e4 100644
--- a/TAO/tests/NestedUpcall/README
+++ b/TAO/tests/NestedUpcall/README
@@ -5,50 +5,82 @@ $Id$
BACKGROUND
==========
-This example tests the scenario of nested upcalls. For example, a
-particular process may need to act in both the role of client and
-server. This interaction is common in situations where the process
-makes a twoway invocation on a remote servant, passing a local object
-reference 'o' to that servant. In the process of servicing that
-invocation, the servant makes a twoway invocation on 'o'.
-
-In this example, we draw upon an interaction of this sort which should
-be familiar to anyone who's used ACE: the process of registering a
-handler with a Reactor. The EventHandler is the local object
-reference, and the Reactor the remote servant. NOTE: This example in
-no way should be construed as testimony that remote Reactors make
-sense or are in any way useful. It is merely a motivating example!
+This example tests the scenario of nested upcalls in TAO. For
+example, a particular process may need to act in both the role of
+client and server. This interaction is common in situations where the
+process makes a twoway invocation on a remote servant, passing a local
+object reference 'o' to that servant. In the process of servicing
+that invocation, the servant makes a twoway invocation on 'o'.
+
+This example illustrates an interaction that should be familiar to
+anyone who's used ACE: the process of registering a handler with a
+Reactor. The EventHandler is the local object reference, and the
+Reactor the remote servant. NOTE: This example in no way should be
+construed as testimony that remote Reactors make sense or are in any
+way useful. It is merely a motivating example!
+
+You can either run the server in the background in the same window as
+the client or open a separate window for the client and server.
+
+The client and server by default make use of the Naming Service. The
+cubit server now has its own NamingServer implementation and hence you
+don't have to start the NamingService before starting the client and
+server.
+
+ You just have to use the -s flags on both the server and
+client if you don't want to use the naming service.
EXECUTION
=========
-server
-------
+server:
+-------
-$ server [orb options] [-d]
+% server [-d] [-s] [-ORBhost <serverhost>] [-ORBport <portnum>]
+ [-o <ior_output_file>]
-where
- -d turns on debugging messages
+Options:
+-------
+-s Tells the server not to use the Naming Service.
+-d Debug flag (It is additive more -d flags will give debugging).
-client
-------
+-o Outputs the ior file to the file
-$ client [orb options] [-d] [-f ior_file] [-k ior_string]
+Using -d turns on debugging messages. It is additive, i.e., the more
+-d options provided, the more debugging you can get. At the moment,
+only 2 levels of debugging are implemented, and more than 2 -d options
+are ignored.
-where
- -d turns on debugging messages
- -f specifies the name of a file in which the IOR
- for the Reactor can be found
+client:
+-------
+
+% client [-d] [-s] [-x] <-f ior_file> <-k ior> -n <iterations>
+
+Options:
+-------
+ d Debug flag
+ s Don't Use the Naming Service
+ x Tells the server to shutdown.
+ f Reads the ior from the file
+ k Reads the ior from commandline
+
+ There are 3 ways of giving the IOR to the client:
+
+ 1. From a file using the -f option. (This file can be produced using
+ the -o option of the server.)
+
+ 2. Directly on the commandline using the -k option.
- -k specifies a string which is the IOR of the Reactor
+ 3. Get it from the Naming Service (which is the default client
+ behavior).
+NestedUpCalls_Test:
+------------------
-NOTES
------
+ This is a simple test program which tests the server and
+client using the default options of the server and client. To test
+using this just run
-If running both on the same machine, it will be necessary to specify a
-different port for each the client and the server using -ORBport on
-the command line. This is because there is also a servant within the
-confines of the client executable.
+ % NestedUpCalls_Test