summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Concurrency
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/orbsvcs/orbsvcs/Concurrency')
-rw-r--r--TAO/orbsvcs/orbsvcs/Concurrency/CC_Lock.cpp240
-rw-r--r--TAO/orbsvcs/orbsvcs/Concurrency/CC_Lock.h140
-rw-r--r--TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSet.cpp341
-rw-r--r--TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSet.h174
-rw-r--r--TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSetFactory.cpp64
-rw-r--r--TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSetFactory.h55
-rw-r--r--TAO/orbsvcs/orbsvcs/Concurrency/Concurrency_Utils.cpp96
-rw-r--r--TAO/orbsvcs/orbsvcs/Concurrency/Concurrency_Utils.h65
8 files changed, 0 insertions, 1175 deletions
diff --git a/TAO/orbsvcs/orbsvcs/Concurrency/CC_Lock.cpp b/TAO/orbsvcs/orbsvcs/Concurrency/CC_Lock.cpp
deleted file mode 100644
index a2dcf82c144..00000000000
--- a/TAO/orbsvcs/orbsvcs/Concurrency/CC_Lock.cpp
+++ /dev/null
@@ -1,240 +0,0 @@
-// $Id$
-
-// ============================================================================
-//
-// = LIBRARY
-// TAO/orbsvcs/Concurrency_Service
-//
-// = FILENAME
-// CC_Lock.cpp
-//
-// = DESCRIPTION
-// This class implements a lock used by the lock set from the
-// concurrency control service.
-//
-// = AUTHORS
-// Torben Worm <tworm@cs.wustl.edu>
-//
-// ============================================================================
-
-#include "CC_Lock.h"
-#include "tao/corba.h"
-
-ACE_RCSID(Concurrency, CC_Lock, "$Id$")
-
-CC_Lock::CC_Lock (void)
- : mode_ (CosConcurrencyControl::intention_read),
- lock_held_ (0)
-{
-}
-
-CC_Lock::CC_Lock (CosConcurrencyControl::lock_mode mode)
- : mode_ (mode),
- lock_held_ (0)
-{
-}
-
-CC_Lock::~CC_Lock (void)
-{
-}
-
-void
-CC_Lock::lock (CORBA::Environment &_env)
-{
- ACE_DEBUG ((LM_DEBUG,
- "CC_Lock::lock\n"));
- lock_held_++;
-
- // if (semaphore_.acquire () == -1)
- // TAO_THROW (CORBA::INTERNAL (CORBA::COMPLETED_NO));
-}
-
-CORBA::Boolean
-CC_Lock::try_lock (CORBA::Environment &_env)
-{
- ACE_DEBUG ((LM_DEBUG,
- "CC_Lock::try_lock. "));
-
- lock_held_++;
-
- ACE_DEBUG ((LM_DEBUG,
- "lock_held_: %i, ",
- lock_held_));
-
- int success = 0;//semaphore_.tryacquire ();
-
- ACE_DEBUG ((LM_DEBUG,
- "success: %i\n", success));
-
- if (success == -1)
- {
- if (errno == EBUSY)
- {
- lock_held_--;
- return 0;
- }
- else
- TAO_THROW_RETURN (CORBA::INTERNAL (CORBA::COMPLETED_NO),
- 0);
- }
- ACE_DEBUG ((LM_DEBUG,
- "lock_held_: %i, ",
- lock_held_));
-
- return 1;
-}
-
-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 = 0; //semaphore_.release ();
-
- if (success == -1)
- TAO_THROW (CORBA::INTERNAL (CORBA::COMPLETED_NO));
-
- lock_held_--;
-
- ACE_DEBUG ((LM_DEBUG,
- "lock_held_: %i, ",
- lock_held_));
-}
-
-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());
-
- this->mode_ = new_mode;
-}
-
-void
-CC_Lock::set_mode (CosConcurrencyControl::lock_mode mode)
-{
- this->mode_ = mode;
-}
-
-CORBA::Boolean
-CC_Lock::Compatible (const CC_Lock &other)
-{
- return this->Compatible (other.mode_);
-}
-
-CORBA::Boolean
-CC_Lock::Compatible (CosConcurrencyControl::lock_mode mode)
-{
- return compatible_[this->mode_][mode];
-}
-
-CosConcurrencyControl::lock_mode
-CC_Lock::GetMode (void)
-{
- return mode_;
-}
-
-int
-CC_Lock::GetLocksHeld(void)
-{
- return this->lock_held_;
-}
-
-void
-CC_Lock::DecLocksHeld(void)
-{
- this->lock_held_--;
-}
-
-void
-CC_Lock::dump(void)
-{
- printf("mode_ %i, lock_held_: %i\n", mode_, lock_held_);
-}
-
-// 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. 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] ={
- {1, 0, 1, 1, 0},
- {0, 0, 0, 0, 0},
- {1, 0, 0, 1, 0},
- {1, 0, 1, 1, 1},
- {0, 0, 0, 1, 1}};
-
-// CC_LockModeterator
-
-CC_LockModeIterator::CC_LockModeIterator(void)
- : current_ (CosConcurrencyControl::intention_read)
-{
-}
-
-CC_LockModeIterator::~CC_LockModeIterator(void)
-{
- // Do nothing
-}
-void CC_LockModeIterator::First(void)
-{
- current_ = CosConcurrencyControl::intention_read;
-}
-
-void CC_LockModeIterator::Next(CORBA::Environment &_env)
-{
- switch(current_)
- {
- case CosConcurrencyControl::intention_read:
- current_ = CosConcurrencyControl::read;
- break;
- case CosConcurrencyControl::read:
- current_ = CosConcurrencyControl::upgrade;
- break;
- case CosConcurrencyControl::upgrade:
- current_ = CosConcurrencyControl::intention_write;
- break;
- case CosConcurrencyControl::intention_write:
- current_ = CosConcurrencyControl::write;
- break;
- case CosConcurrencyControl::write:
- TAO_THROW(CORBA::INTERNAL (CORBA::COMPLETED_NO));
- default:
- TAO_THROW(CORBA::INTERNAL (CORBA::COMPLETED_NO));
- }
-}
-
-CORBA::Boolean
-CC_LockModeIterator::IsDone(void)
-{
- if(current_==CosConcurrencyControl::write)
- return 1;
- else
- return 0;
-}
-
-CosConcurrencyControl::lock_mode
-CC_LockModeIterator::GetLockMode(void)
-{
- return current_;
-}
diff --git a/TAO/orbsvcs/orbsvcs/Concurrency/CC_Lock.h b/TAO/orbsvcs/orbsvcs/Concurrency/CC_Lock.h
deleted file mode 100644
index 129022f97ae..00000000000
--- a/TAO/orbsvcs/orbsvcs/Concurrency/CC_Lock.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/* -*- C++ -*- */
-// $Id$
-
-// ============================================================================
-//
-// = LIBRARY
-// TAO/orbsvcs/Concurrency_Service
-//
-// = FILENAME
-// CC_Lock.h
-//
-// = DESCRIPTION
-// This class implements a lock used by the lock set from the
-// concurrency control service
-//
-// = AUTHORS
-// Torben Worm <tworm@cs.wustl.edu>
-//
-// ============================================================================
-
-#ifndef _CC_LOCK_H
-#define _CC_LOCK_H
-
-#include "ace/Synch.h"
-
-#if !defined (ACE_LACKS_PRAGMA_ONCE)
-# pragma once
-#endif /* ACE_LACKS_PRAGMA_ONCE */
-
-#include "orbsvcs/CosConcurrencyControlC.h"
-
-#define NUMBER_OF_LOCK_MODES 5
-// This constant 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
- // 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.
-public:
- CC_Lock (void);
- // Creates the lock with mode = intention_read (weakest)
-
- CC_Lock (CosConcurrencyControl::lock_mode mode);
- // Creates the lock with the desired mode
-
- ~CC_Lock (void);
- // Deletes the lock
-
- void lock (CORBA::Environment &env);
- // Acquires this lock. Blocks until lock is obtained
-
- 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 change_mode (CosConcurrencyControl::lock_mode new_mode,
- CORBA::Environment &env);
- // Changes the mode of this lock.
-
- void set_mode (CosConcurrencyControl::lock_mode mode);
- // Sets the mode_ of the lock. Used in initialization
-
- 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.
-
- CosConcurrencyControl::lock_mode GetMode (void);
- // Returns the mode of the lock.
-
- int GetLocksHeld(void);
- // Returns the number of times this lock have been locked
-
- void DecLocksHeld(void);
- // Decrements the number of locks held in this mode. Used by change_mode.
-
- void dump(void);
- // Dumps the state of the object to stdout
-
-protected:
- CosConcurrencyControl::lock_mode mode_;
- // Holds the lock's mode.
-
-private:
- int lock_held_;
- // If greater than zero the lock is held (that number of times).
-
- static CORBA::Boolean compatible_[NUMBER_OF_LOCK_MODES][NUMBER_OF_LOCK_MODES];
- // Defines the compatibility of the locks.
-};
-
-class TAO_ORBSVCS_Export CC_LockModeIterator
-{
- // = TITLE
- // CC_LockModeIterator
- //
- // = DESCRIPTION
- // This class implements an iterator over the lock modes in
- // order to make an ordered traversal over the locks from the
- // weakest (intention read) to the strongest (write).
- // Ordering: IR -> R -> U -> IW -> W
-public:
- CC_LockModeIterator(void);
- // Default constructor
-
- ~CC_LockModeIterator(void);
- // Destructor
-
- void First(void);
- // Reset the iterator to the first element
-
- void Next(CORBA::Environment &_env);
- // Advance the iterator to the next element
- // Throws exception if out of range
-
- CORBA::Boolean IsDone(void);
- // Returns true if the iterator has reached the last element
-
- CosConcurrencyControl::lock_mode GetLockMode(void);
- // Get the current element
-
-private:
- CosConcurrencyControl::lock_mode current_;
-};
-
-#endif /* !defined (_CC_LOCK_H) */
diff --git a/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSet.cpp b/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSet.cpp
deleted file mode 100644
index 191ebc98442..00000000000
--- a/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSet.cpp
+++ /dev/null
@@ -1,341 +0,0 @@
-// $Id$
-
-// ============================================================================
-//
-// = LIBRARY
-// cos
-//
-// = FILENAME
-// CC_LockSet.cpp
-//
-// = AUTHOR
-// Torben Worm <tworm@cs.wustl.edu>
-//
-// ============================================================================
-
-#include "CC_LockSet.h"
-
-ACE_RCSID(Concurrency, CC_LockSet, "$Id$")
-
-// Default constructor.
-
-CC_LockSet::CC_LockSet (void)
- : related_lockset_ (0)
-{
- TAO_TRY
- {
- this->Init (TAO_TRY_ENV);
- TAO_CHECK_ENV;
- }
- TAO_CATCHANY
- {
- TAO_TRY_ENV.print_exception ("CC_LockSet::CC_LockSet (void)");
- }
- TAO_ENDTRY;
-}
-
-// Constructor used to create related lock sets.
-
-CC_LockSet::CC_LockSet (CosConcurrencyControl::LockSet_ptr related)
- : related_lockset_ (related)
-{
- TAO_TRY
- {
- this->Init (TAO_TRY_ENV);
- TAO_CHECK_ENV;
- }
- TAO_CATCHANY
- {
- TAO_TRY_ENV.print_exception ("CC_LockSet::CC_LockSet (...)");
- }
- TAO_ENDTRY;
-}
-
-// Initialization.
-
-void
-CC_LockSet::Init (CORBA::Environment &_env)
-{
- // Set the mode of the statically allocated locks
- lock_[CC_IR] = 0;
- lock_[CC_R] = 0;
- lock_[CC_U] = 0;
- lock_[CC_IW] = 0;
- lock_[CC_W] = 0;
-
- // Acquire the semaphore in order to be able to put requests on hold
- if (semaphore_.acquire () == -1)
- TAO_THROW (CORBA::INTERNAL (CORBA::COMPLETED_NO));
-}
-
-// Destructor
-
-CC_LockSet::~CC_LockSet (void)
-{
-}
-
-// Returns true if the requested lock mode is compatible with the
-// modes held. False otherwise.
-
-CORBA::Boolean CC_LockSet::compatible (CC_LockModeEnum mr)
-{
- for (size_t i = CC_IR; i <= CC_W; i++)
- if (this->lock_[i] > 0)
- if (this->compatible_[i][mr] == 0)
- return 0;
-
- return 1;
-}
-
-// Locks the lock in the desired mode. Blocks until success.
-
-void
-CC_LockSet::lock (CosConcurrencyControl::lock_mode mode,
- CORBA::Environment &_env)
-{
- ACE_DEBUG ((LM_DEBUG, "CC_LockSet::lock\n"));
-
- CC_LockModeEnum lm = lmconvert (mode);
-
- // Check to see if the requested mode is compatible with the modes
- // held so far. If not put the request on hold.
-
- // @@ It's important to document somewhere that this code relies on
- // the FIFO properties of ACE_Token!
- if (this->lock_i (lm) == 1)
- if (semaphore_.acquire () == -1)
- TAO_THROW (CORBA::INTERNAL (CORBA::COMPLETED_NO));
-}
-
-// Tries to lock. If it is not possible false is returned.
-
-CORBA::Boolean
-CC_LockSet::try_lock (CosConcurrencyControl::lock_mode mode,
- CORBA::Environment &_env)
-{
- CC_LockModeEnum lm = lmconvert (mode);
-
- ACE_DEBUG ((LM_DEBUG,
- "CC_LockSet::try_lock\n"));
-
- if (this->try_lock_i (lm) == 0)
- return 0;
- else
- return 1;
-}
-
-// Converts the enum from the spec to the internally (ordered)
-// enum.
-
-CC_LockModeEnum
-CC_LockSet::lmconvert (CosConcurrencyControl::lock_mode mode)
-{
- switch (mode)
- {
- case CosConcurrencyControl::intention_read:
- return CC_IR;
- case CosConcurrencyControl::read:
- return CC_R;
- case CosConcurrencyControl::upgrade:
- return CC_U;
- case CosConcurrencyControl::intention_write:
- return CC_IW;
- case CosConcurrencyControl::write:
- return CC_W;
- default:
- return CC_EM;
- }
-}
-
-// Unlock the lock
-
-void
-CC_LockSet::unlock (CosConcurrencyControl::lock_mode mode,
- CORBA::Environment &_env)
-{
- ACE_DEBUG ((LM_DEBUG,
- "CC_LockSet::unlock\n"));
-
- CC_LockModeEnum lm = lmconvert (mode);
-
- ACE_GUARD (ACE_SYNCH_MUTEX, ace_mon, this->mlock_);
-
- TAO_TRY
- {
- if (lock_[lm] == 0) // This lock is not held.
- TAO_THROW (CosConcurrencyControl::LockNotHeld());
- else
- lock_[lm]--;
-
- TAO_CHECK_ENV;
-
- // If we do not have a lock held in a weaker mode than the
- // strongest held and we have requests on the semaphore signal
- // the semaphore.
- while (lock_queue_.size () > 0)
- {
- CC_LockModeEnum lock_on_queue = CC_EM;
-
- lock_queue_.dequeue_head (lock_on_queue);
-
- if (compatible (lock_on_queue) == 1)
- {
- if (semaphore_.release () == -1)
- TAO_THROW (CORBA::INTERNAL (CORBA::COMPLETED_NO));
- lock_[lock_on_queue]++;
- }
- else
- {
- lock_queue_.enqueue_head (lock_on_queue);
- break;
- }
- }
- }
- TAO_CATCHANY
- {
- TAO_RETHROW;
- }
- TAO_ENDTRY;
- this->dump ();
-}
-
-// Changes the mode of a held lock.
-
-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"));
- CC_LockModeEnum lm_held = lmconvert (held_mode);
- CC_LockModeEnum lm_new = lmconvert (new_mode);
-
- TAO_TRY
- {
- if (this->lock_held (lm_held) == 0) // This lock is not held
- TAO_THROW (CosConcurrencyControl::LockNotHeld());
- else if (this->change_mode_i (lm_held, lm_new)==1)
- {
- this->unlock (held_mode, _env);
- TAO_CHECK_ENV;
-
- if (semaphore_.acquire () == -1)
- TAO_THROW (CORBA::INTERNAL (CORBA::COMPLETED_NO));
- }
- }
- TAO_CATCHANY
- {
- TAO_RETHROW;
- }
- TAO_ENDTRY;
-
- // this->dump ();
-}
-
-int
-CC_LockSet::lock_i (CC_LockModeEnum lm)
-{
- ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->mlock_, 1);
- // If the lock is not compatible with the locks we hold allready or
- // there is lock requests in the queue we cannot grant the lock and
- // thus we queue the request. Otherwise update the lock count.
- if (compatible (lm) == 0 || lock_queue_.size () > 0)
- {
- // Put the lock mode in the queue
- lock_queue_.enqueue_tail (lm);
- this->dump ();
- return 1; // Lock the semaphore.
- }
- else
- lock_[lm]++;
-
- this->dump ();
- return 0;
-}
-
-int
-CC_LockSet::try_lock_i (CC_LockModeEnum lm)
-{
- ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->mlock_, 1);
- // If the lock we try is compatible with the locks we hold we just
- // opdates the count. Otherwise we return false.
- if (compatible (lm) == 0)
- {
- this->dump ();
- return 0;
- }
- else
- lock_[lm]++;
-
- this->dump ();
- return 1;
-}
-
-int
-CC_LockSet::change_mode_i (CC_LockModeEnum lm_held,
- CC_LockModeEnum lm_new)
-{
- ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->mlock_, 1);
- // If the new mode is compatible with the modes we hold we change
- // the counts for the two locks. If not we must queue the new
- // request. We can decrement the count for the old mode without
- // signalling the semaphore because we know we only check modes
- // granted this far.
-
- lock_[lm_held]--;
-
- if (compatible (lm_new) == 1)
- {
- lock_[lm_new]++;
- this->dump ();
- return 0;
- }
- else
- {
- lock_[lm_held]++;
- lock_queue_.enqueue_tail (lm_new);
- this->dump ();
- return 1;
- }
-}
-
-int
-CC_LockSet::lock_held (CC_LockModeEnum lm)
-{
- ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->mlock_, 1);
- if (lock_[lm] > 0)
- return 1;
- else
- return 0;
-}
-
-void
-CC_LockSet::dump (void)
-{
- ACE_DEBUG ((LM_DEBUG,
- "waiting_calls_: %i, IR: %i, R: %i, U: %i, IW: %i, W: %i\n",
- lock_queue_.size (),
- lock_[CC_IR],
- lock_[CC_R],
- lock_[CC_U],
- lock_[CC_IW],
- lock_[CC_W]));
-}
-
-CORBA::Boolean CC_LockSet::compatible_[NUMBER_OF_LOCK_MODES][NUMBER_OF_LOCK_MODES] ={
- {1, 1, 1, 1, 0},
- {1, 1, 1, 0, 0},
- {1, 1, 0, 0, 0},
- {1, 0, 0, 1, 0},
- {0, 0, 0, 0, 0}};
-
-#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
-template class ACE_Node<CC_LockModeEnum>;
-template class ACE_Unbounded_Queue<CC_LockModeEnum>;
-template class ACE_Unbounded_Queue_Iterator<CC_LockModeEnum>;
-#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
-#pragma instantiate ACE_Node<CC_LockModeEnum>
-#pragma instantiate ACE_Unbounded_Queue<CC_LockModeEnum>
-#pragma instantiate ACE_Unbounded_Queue_Iterator<CC_LockModeEnum>
-#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
diff --git a/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSet.h b/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSet.h
deleted file mode 100644
index 5b6087189c5..00000000000
--- a/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSet.h
+++ /dev/null
@@ -1,174 +0,0 @@
-/* -*- C++ -*- */
-// $Id$
-
-// ============================================================================
-//
-// = LIBRARY
-// TAO/orbsvcs/Concurrency_Service
-//
-// = FILENAME
-// CC_LockSet.h
-//
-// = DESCRIPTION
-// This class implements the lock set interface from the
-// concurrency service.
-//
-// In the present implementation the multiple possesion semantics
-// is implemented for non-transactional clients. In future
-// versions this should be changed because the multiple possesion
-// semantics does not apply to non-transactional clients. This
-// can be accomplished in the following manner:
-// - Make a class with the same functiallity as the CC_LockSet
-// class as a base class for both implementations.
-// - The functionallity that should be separated out in the
-// subclasses is the compatible function which should always
-// return false because no locks can be held simultanously with
-// non-transactional clients.
-// - Use these classes from the classes that inherits the
-// servant properties, i.e. the way CC_LockSet does now.
-//
-// = AUTHORS
-// Torben Worm <tworm@cs.wustl.edu>
-//
-// ============================================================================
-
-#ifndef _CC_LOCKSET_H
-#define _CC_LOCKSET_H
-
-#include "ace/Synch.h"
-
-#if !defined (ACE_LACKS_PRAGMA_ONCE)
-# pragma once
-#endif /* ACE_LACKS_PRAGMA_ONCE */
-
-#include "ace/Token.h"
-#include "orbsvcs/CosConcurrencyControlS.h"
-
-#define NUMBER_OF_LOCK_MODES 5
-// This constant 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.
-
-typedef enum {CC_EM=-1, CC_IR=0, CC_R, CC_U, CC_IW, CC_W} CC_LockModeEnum;
-// Enummeration representing the lock modes. The incomming request is
-// always converted to this representation. There are two reasons for
-// this: Firstly the lock modes are ordered from weakest to strongest
-// in the internal representation, and secondly it is possible to
-// indicate a 'non-mode' (CC_EM)
-
-class TAO_ORBSVCS_Export CC_LockSet : public POA_CosConcurrencyControl::LockSet
-{
- // = TITLE
- // 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.
-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.
-
- ~CC_LockSet (void);
- // Destructor.
-
- // = CosConcurrencyControl 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.
-
- // = Debugging methods
- void dump (void);
- // Dump the state of the object to stdout
-
-private:
- CC_LockModeEnum lmconvert (CosConcurrencyControl::lock_mode mode);
- // Converts the CORBA specification's lock mode to the internal
- // representation
-
- void Init (CORBA::Environment &_env);
- // Initiatlizes the lock set array and acquires the initial
- // semaphore.
-
- CORBA::Boolean compatible (CC_LockModeEnum mr);
- // Returns true if the held lock and the requested lock are compatible
-
- // The _i functions below ensures atomical access the the state data
- // for the lock set. The functions acquires a thread lock in order
- // to insure consistency within the lock set. The return value
- // typically indicates whether the current thread should be
- // suspended or not (by locking the semaphore.
-
- int lock_i (CC_LockModeEnum lm);
- // Locks the access to the data and decides whether to lock or
- // not. Returns 1 if the semaphore should be locked.
-
- // int unlock_i (CosConcurrencyControl::lock_mode lm);
- // This function is not necessary because we lock access to the data
- // and unlocks the semaphore until an invalid lock mode is first on
- // the queue. Thereafter we release the lock.
-
- int try_lock_i (CC_LockModeEnum lm);
- // Locks the access to the data and determines whether to return
- // true or false. Returns 1 if true should be returned.
-
- int change_mode_i (CC_LockModeEnum lm_held,
- CC_LockModeEnum lm_new);
- // Locks access to the data and determines if the semaphore should
- // be locked. Returns 1 if the semaphore should be locked.
-
- int lock_held (CC_LockModeEnum lm);
- // Locks access ti the data and checks whether the lock is held.
-
- int lock_[NUMBER_OF_LOCK_MODES];
- // An array of lock counters that counts how many locks of that type
- // that the lock set holds.
-
- // ACE_Thread_Semaphore semaphore_;
- ACE_Token semaphore_;
- // This is the semaphore for the lock set. The semaphore is used to
- // queue requests for locks in modes stronger than currently
- // possible to grant. Note that the <ACE_Token> provides strict
- // FIFO ordering of acquisition/release of the 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).
-
- static CORBA::Boolean compatible_[NUMBER_OF_LOCK_MODES][NUMBER_OF_LOCK_MODES];
- // Mapping between requested and held lock modes. Used by compatible
- // (...). Uses the internal enumeration as indices.
-
- ACE_SYNCH_MUTEX mlock_;
- // Lock to ensure that race conditions does not occur.
-
- ACE_Unbounded_Queue <CC_LockModeEnum> lock_queue_;
- // Queue to hold the requested locks not yet granted.
-};
-
-#endif /* _CC_LOCKSET_H */
diff --git a/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSetFactory.cpp b/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSetFactory.cpp
deleted file mode 100644
index 5a0c9db08be..00000000000
--- a/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSetFactory.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-// $Id$
-
-// ============================================================================
-//
-// = LIBRARY
-// cos
-//
-// = FILENAME
-// CC_LockSetFactory.cpp
-//
-// = AUTHOR
-// Torben Worm <tworm@cs.wustl.edu>
-//
-// ============================================================================
-
-#include "CC_LockSetFactory.h"
-#include "CC_LockSet.h"
-
-ACE_RCSID(Concurrency, CC_LockSetFactory, "$Id$")
-
-// Default constructor
-CC_LockSetFactory::CC_LockSetFactory (void)
-{
-}
-
-// Destructor.
-CC_LockSetFactory::~CC_LockSetFactory (void)
-{
-}
-
-CosConcurrencyControl::LockSet_ptr
-CC_LockSetFactory::create (CORBA::Environment &_env)
-{
- CC_LockSet *ls = 0;
-
- ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, CosConcurrencyControl::LockSet::_nil ());
-
- _env.exception (new CORBA::NO_MEMORY (CORBA::COMPLETED_NO));
- ACE_NEW_THROW_RETURN (ls,
- CC_LockSet,
- CORBA::NO_MEMORY(CORBA::COMPLETED_NO),
- CosConcurrencyControl::LockSet::_nil ());
- _env.clear ();
-
- return ls->_this (_env);
-}
-
-CosConcurrencyControl::LockSet_ptr
-CC_LockSetFactory::create_related (CosConcurrencyControl::LockSet_ptr which,
- CORBA::Environment &_env)
-{
- CC_LockSet *ls = 0;
-
- ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, CosConcurrencyControl::LockSet::_nil ());
-
- _env.exception (new CORBA::NO_MEMORY (CORBA::COMPLETED_NO));
- ACE_NEW_THROW_RETURN (ls,
- CC_LockSet (which),
- CORBA::NO_MEMORY(CORBA::COMPLETED_NO),
- CosConcurrencyControl::LockSet::_nil ());
- _env.clear ();
-
- return ls->_this (_env);
-}
diff --git a/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSetFactory.h b/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSetFactory.h
deleted file mode 100644
index f0f12c6d214..00000000000
--- a/TAO/orbsvcs/orbsvcs/Concurrency/CC_LockSetFactory.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* -*- C++ -*- */
-// $Id$
-
-// ============================================================================
-//
-// = LIBRARY
-// TAO/orbsvcs/Concurrency_Service
-//
-// = FILENAME
-// CC_LockSetFactory.h
-//
-// = DESCRIPTION
-// This class implements the lock set factory interface from the
-// concurrency service.
-//
-// = AUTHORS
-// Torben Worm <tworm@cs.wustl.edu>
-//
-// ============================================================================
-
-#ifndef _CC_LOCKSETFACTORY_H
-#define _CC_LOCKSETFACTORY_H
-
-// #include "tao/corba.h"
-#include "orbsvcs/CosConcurrencyControlS.h"
-
-class TAO_ORBSVCS_Export CC_LockSetFactory : public POA_CosConcurrencyControl::LockSetFactory
-{
- // = TITLE
- // 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.
-public:
-
- // = Initialization and termination methods.
- CC_LockSetFactory (void);
- // Default constructor.
-
- ~CC_LockSetFactory (void);
- // Destructor.
-
- virtual CosConcurrencyControl::LockSet_ptr create (CORBA::Environment &env);
-
- virtual CosConcurrencyControl::LockSet_ptr create_related (CosConcurrencyControl::LockSet_ptr which,
- CORBA::Environment &env);
-private:
- ACE_SYNCH_MUTEX lock_;
- // Lock to serialize the access to the factory.
-};
-
-#endif /* _CC_LOCKSETFACTORY_H */
diff --git a/TAO/orbsvcs/orbsvcs/Concurrency/Concurrency_Utils.cpp b/TAO/orbsvcs/orbsvcs/Concurrency/Concurrency_Utils.cpp
deleted file mode 100644
index 6a376c9de47..00000000000
--- a/TAO/orbsvcs/orbsvcs/Concurrency/Concurrency_Utils.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-// $Id$
-
-// ============================================================================
-//
-// = LIBRARY
-// TAO/orbsvcs/Concurrency_Service
-//
-// = FILENAME
-// Concurrency_Utils.cpp
-//
-// = AUTHOR
-// Torben Worm <tworm@cs.wustl.edu>
-//
-// ============================================================================
-
-#include "ace/streams.h"
-#include "orbsvcs/CosConcurrencyControlC.h"
-#include "tao/corba.h"
-#include "Concurrency_Utils.h"
-
-ACE_RCSID(Concurrency, Concurrency_Utils, "$Id$")
-
-// Default constructor
-
-TAO_Concurrency_Server::TAO_Concurrency_Server (void)
-{
-}
-
-// Constructor which takes an ORB and POA.
-
-TAO_Concurrency_Server::TAO_Concurrency_Server (CORBA::ORB_var &orb,
- PortableServer::POA_var &poa)
-{
- this->init (orb, poa);
-}
-
-// Function to initialize the concurrency server object under the
-// passed orb and poa.
-
-int
-TAO_Concurrency_Server::init (CORBA::ORB_var &orb,
- PortableServer::POA_var &poa)
-{
- TAO_TRY
- {
- // Get the naming context ptr to NameService.
- TAO_CHECK_ENV;
-
- PortableServer::ObjectId_var id =
- PortableServer::string_to_ObjectId ("ConcurrencyService");
-
- poa->activate_object_with_id (id.in (),
- &lock_set_factory_,
- TAO_TRY_ENV);
- TAO_CHECK_ENV;
-
- // Stringify the objref we'll be implementing, and print it to
- // stdout. Someone will take that string and give it to a
- // client. Then release the object.
- CORBA::Object_var obj =
- poa->id_to_reference (id.in (),
- TAO_TRY_ENV);
- TAO_CHECK_ENV;
-
- CORBA::String_var str =
- orb->object_to_string (obj.in (),
- TAO_TRY_ENV);
- TAO_CHECK_ENV;
-
- ACE_DEBUG ((LM_DEBUG,
- "listening as object <%s>\n",
- str.in ()));
- }
- TAO_CATCHANY
- {
- TAO_TRY_ENV.print_exception ("Concurrency Service");
- }
- TAO_ENDTRY;
- return 0;
-}
-
-// Get the lock set factory.
-
-CC_LockSetFactory *
-TAO_Concurrency_Server::GetLockSetFactory(void)
-{
- return &this->lock_set_factory_;
-}
-
-// Destructor.
-
-TAO_Concurrency_Server::~TAO_Concurrency_Server (void)
-{
-}
-
-
diff --git a/TAO/orbsvcs/orbsvcs/Concurrency/Concurrency_Utils.h b/TAO/orbsvcs/orbsvcs/Concurrency/Concurrency_Utils.h
deleted file mode 100644
index 112b433a9c3..00000000000
--- a/TAO/orbsvcs/orbsvcs/Concurrency/Concurrency_Utils.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* -*- C++ -*- */
-// $Id$
-
-// ============================================================================
-//
-// = LIBRARY
-// TAO/orbsvcs/Concurrency_Service
-//
-// = FILENAME
-// 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.
-//
-// = AUTHORS
-// Torben Worm <tworm@cs.wustl.edu>
-//
-// ============================================================================
-
-#ifndef _CONCURRENCY_SERVER_H
-#define _CONCURRENCY_SERVER_H
-
-#include "tao/corba.h"
-#include "orbsvcs/CosConcurrencyControlC.h"
-#include "CC_LockSetFactory.h"
-
-class TAO_ORBSVCS_Export TAO_Concurrency_Server
-{
- // = TITLE
- // Defines a wrapper class for the implementation of the
- // concurrency server.
- //
- // = DESCRIPTION
- // 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);
- //Default constructor.
-
- TAO_Concurrency_Server (CORBA::ORB_var &orb,
- PortableServer::POA_var &poa);
- // 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.
-
-private:
- CC_LockSetFactory lock_set_factory_;
- // This is the lock set factory activated under the POA.
-};
-
-#endif /* _CONCURRENCY_SERVER_H */
-