From 2c28ab22fbf439fd14e1636fb4b7872471fa8137 Mon Sep 17 00:00:00 2001 From: tworm Date: Tue, 12 May 1998 15:32:51 +0000 Subject: Remowed warning from g++ and added comments to the header files --- TAO/orbsvcs/orbsvcs/Concurrency/CC_Lock.cpp | 28 +++++++++++++++------- TAO/orbsvcs/orbsvcs/Concurrency/CC_Lock.h | 13 +++++----- TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSet.h | 11 ++++++--- .../orbsvcs/Concurrency/CC_LockSetFactory.cpp | 4 +++- .../orbsvcs/Concurrency/CC_LockSetFactory.h | 4 ---- .../orbsvcs/Concurrency/Concurrency_Utils.h | 5 ++-- 6 files changed, 40 insertions(+), 25 deletions(-) (limited to 'TAO/orbsvcs/orbsvcs/Concurrency') diff --git a/TAO/orbsvcs/orbsvcs/Concurrency/CC_Lock.cpp b/TAO/orbsvcs/orbsvcs/Concurrency/CC_Lock.cpp index d777f3807a2..d637b098435 100644 --- a/TAO/orbsvcs/orbsvcs/Concurrency/CC_Lock.cpp +++ b/TAO/orbsvcs/orbsvcs/Concurrency/CC_Lock.cpp @@ -123,13 +123,23 @@ CosConcurrencyControl::lock_mode CC_Lock::GetMode (void) // 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}, - {CORBA::B_TRUE, 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_TRUE}, - {CORBA::B_FALSE, CORBA::B_FALSE, CORBA::B_FALSE, CORBA::B_FALSE, CORBA::B_FALSE}}; +// or their compatibility are changed. The table here looks different +// from the table in the spec, this is due to the different ordering +// of the lock modes in the table and in the enum in the IDL. The +// first index in the array is the mode held by this lock and the +// second index is the requested mode. +// Requested mode +// Held mode R W U IR IW +// R X X +// W X X X X X +// U X X X X = conflict +// IR X +// IW X X X +// +CORBA::Boolean CC_Lock::compatible_[NUMBER_OF_LOCK_MODES][NUMBER_OF_LOCK_MODES] ={ + {CORBA::B_TRUE, CORBA::B_FALSE, CORBA::B_TRUE, CORBA::B_TRUE, CORBA::B_FALSE}, + {CORBA::B_FALSE, CORBA::B_FALSE, CORBA::B_FALSE, CORBA::B_FALSE, CORBA::B_FALSE}, + {CORBA::B_TRUE, CORBA::B_FALSE, CORBA::B_FALSE, CORBA::B_TRUE, CORBA::B_FALSE}, + {CORBA::B_TRUE, CORBA::B_FALSE, CORBA::B_TRUE, CORBA::B_TRUE, CORBA::B_TRUE}, + {CORBA::B_FALSE, CORBA::B_FALSE, CORBA::B_FALSE, CORBA::B_TRUE, CORBA::B_TRUE}}; diff --git a/TAO/orbsvcs/orbsvcs/Concurrency/CC_Lock.h b/TAO/orbsvcs/orbsvcs/Concurrency/CC_Lock.h index cc40ccff0f8..2e7b117095b 100644 --- a/TAO/orbsvcs/orbsvcs/Concurrency/CC_Lock.h +++ b/TAO/orbsvcs/orbsvcs/Concurrency/CC_Lock.h @@ -24,6 +24,11 @@ #include "ace/Synch.h" #include "orbsvcs/CosConcurrencyControlC.h" +#define NUMBER_OF_LOCK_MODES 5 +// This contant defines the number of lock modes. There is really no +// way to set this constant dynamically because the nuber of lock +// modes are not stated as part of the IDL. + class TAO_ORBSVCS_Export CC_Lock { // = TITLE @@ -78,12 +83,8 @@ private: int lock_held_; // 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. - // @@ 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." - // + static CORBA::Boolean compatible_[NUMBER_OF_LOCK_MODES][NUMBER_OF_LOCK_MODES]; + // Defines the compatibility of the locks. }; #endif /* !defined (_CC_LOCK_H) */ diff --git a/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSet.h b/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSet.h index 0dc03fcba8b..9388710c92f 100644 --- a/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSet.h +++ b/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSet.h @@ -47,19 +47,24 @@ public: ~CC_LockSet(void); // Destructor. - // @@ Torben, please add comments to the following methods. virtual void lock (CosConcurrencyControl::lock_mode mode, CORBA::Environment &env); - + // Acquires this lock. Blocks until lock is obtained + virtual CORBA::Boolean try_lock (CosConcurrencyControl::lock_mode mode, CORBA::Environment &env); - + // Tries to acquire this lock. If it is not possible to acquire the + // lock, false is returned + virtual void unlock (CosConcurrencyControl::lock_mode mode, CORBA::Environment &env); + // Releases this lock. virtual void change_mode (CosConcurrencyControl::lock_mode held_mode, CosConcurrencyControl::lock_mode new_mode, CORBA::Environment &env); + // Changes the mode of this lock. + private: CC_Lock *lock_; // At present the lock set contains only one lock. diff --git a/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSetFactory.cpp b/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSetFactory.cpp index 8144ae197a2..48707c04a2b 100644 --- a/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSetFactory.cpp +++ b/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSetFactory.cpp @@ -20,14 +20,16 @@ // Default constructor CC_LockSetFactory::CC_LockSetFactory (void) { - // @@ Torben, can you please comment this code? ACE_NEW (this->lock_, ACE_Lock_Adapter); + // Acquire a lock to ensure only one client will be in the factory + // at any time } // Destructor. CC_LockSetFactory::~CC_LockSetFactory (void) { delete this->lock_; + // Delete the serialization lock } CosConcurrencyControl::LockSet_ptr diff --git a/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSetFactory.h b/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSetFactory.h index 4ea7853c282..12fbcfdaf57 100644 --- a/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSetFactory.h +++ b/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSetFactory.h @@ -52,8 +52,4 @@ private: }; -// @@ 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.h b/TAO/orbsvcs/orbsvcs/Concurrency/Concurrency_Utils.h index 06d5947e4cc..0958472b535 100644 --- a/TAO/orbsvcs/orbsvcs/Concurrency/Concurrency_Utils.h +++ b/TAO/orbsvcs/orbsvcs/Concurrency/Concurrency_Utils.h @@ -34,7 +34,8 @@ class TAO_ORBSVCS_Export TAO_Concurrency_Server // concurrency server. // // = DESCRIPTION - // @@ Torben, please fill in here... + // This class takes an orb and Poa reference and activates the + // concurrency service lock set factory object under them. public: // = Initialization and termination methods. TAO_Concurrency_Server (void); @@ -57,7 +58,7 @@ public: private: CC_LockSetFactory lock_set_factory_; - // @@ Torben, please comment this. + // This is the lock set factory activated under the POA. }; #endif /* _CONCURRENCY_SERVER_H */ -- cgit v1.2.1