diff options
author | tworm <tworm@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-04-06 22:18:21 +0000 |
---|---|---|
committer | tworm <tworm@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-04-06 22:18:21 +0000 |
commit | 2337a21a71cbe9774fd6990a1fb89b1ba6d1147a (patch) | |
tree | 369c978cdb86bef7dc360e02d4affe2d706c1a16 /TAO/orbsvcs/orbsvcs/Concurrency/CC_Lock.cpp | |
parent | b93258473142ddef0371b1ea0bb351d495639ae1 (diff) | |
download | ATCD-2337a21a71cbe9774fd6990a1fb89b1ba6d1147a.tar.gz |
Initial version
Diffstat (limited to 'TAO/orbsvcs/orbsvcs/Concurrency/CC_Lock.cpp')
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Concurrency/CC_Lock.cpp | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/TAO/orbsvcs/orbsvcs/Concurrency/CC_Lock.cpp b/TAO/orbsvcs/orbsvcs/Concurrency/CC_Lock.cpp new file mode 100644 index 00000000000..95b81728b88 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Concurrency/CC_Lock.cpp @@ -0,0 +1,83 @@ +/* -*- C++ -*- */ +// $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 "tao/corba.h" +#include "CC_Lock.h" + +CC_Lock::CC_Lock(CosConcurrencyControl::lock_mode mode) : mode_ (mode) +{ + semaphore_.open("test"); // @@ The semaphore must have a unique name?? +} + +CC_Lock::~CC_Lock() +{ + semaphore_.close(); +} + +void CC_Lock::lock(void) +{ + semaphore_.acquire(); +} + +CORBA::Boolean CC_Lock::try_lock() +{ + semaphore_.tryacquire(); //@@ What does tryacquire return?? + return CORBA::B_TRUE; +} + +void CC_Lock::unlock(void) +{ + semaphore_.release(); +} + +void CC_Lock::change_mode(CosConcurrencyControl::lock_mode new_mode) +{ + // @@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 +} + +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_; +} + +// 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 +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}}; + +//#if defined (__ACE_INLINE__) +//#include "CC_Lock.i" +//#endif // defined INLINE |