summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-06-23 20:48:03 +0000
committernanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-06-23 20:48:03 +0000
commiteb7071a9033a3cb2c88d16e35c2bfdf8d291114d (patch)
tree7e763b5e2a11fc157ce1d341991a58f482591f20
parentbb48543255eab1927965a15b438356d22d099cb3 (diff)
downloadATCD-eb7071a9033a3cb2c88d16e35c2bfdf8d291114d.tar.gz
Added ACE_Adaptive_Lock.
-rw-r--r--ace/Synch.cpp59
-rw-r--r--ace/Synch.h37
2 files changed, 95 insertions, 1 deletions
diff --git a/ace/Synch.cpp b/ace/Synch.cpp
index 9368121b01c..3e2f07969ea 100644
--- a/ace/Synch.cpp
+++ b/ace/Synch.cpp
@@ -23,6 +23,65 @@ ACE_Lock::~ACE_Lock (void)
{
}
+ACE_Adaptive_Lock::ACE_Adaptive_Lock (void)
+ : lock_ (0)
+{
+}
+
+int
+ACE_Adaptive_Lock::remove (void)
+{
+ return this->lock_->remove ();
+}
+
+int
+ACE_Adaptive_Lock::acquire (void)
+{
+ return this->lock_->acquire ();
+}
+
+int
+ACE_Adaptive_Lock::tryacquire (void)
+{
+ return this->lock_->tryacquire ();
+}
+
+int
+ACE_Adaptive_Lock::release (void)
+{
+ return this->lock_->release ();
+}
+
+int
+ACE_Adaptive_Lock::acquire_read (void)
+{
+ return this->lock_->acquire_read ();
+}
+
+int
+ACE_Adaptive_Lock::acquire_write (void)
+{
+ return this->lock_->acquire_write ();
+}
+
+int
+ACE_Adaptive_Lock::tryacquire_read (void)
+{
+ return this->lock_->tryacquire_read ();
+}
+
+int
+ACE_Adaptive_Lock::tryacquire_write (void)
+{
+ return this->lock_->tryacquire_write ();
+}
+
+void
+ACE_Adaptive_Lock::dump (void) const
+{
+ // return this->lock_->dump ();
+}
+
ACE_TSS_Adapter::ACE_TSS_Adapter (void *object, ACE_THR_DEST f)
: ts_obj_ (object),
func_ (f)
diff --git a/ace/Synch.h b/ace/Synch.h
index 3d262fdf62d..43325c4982f 100644
--- a/ace/Synch.h
+++ b/ace/Synch.h
@@ -90,6 +90,41 @@ public:
// already had the lock, <errno> is set to <EBUSY>.
};
+class ACE_Adaptive_Lock : public ACE_Lock
+{
+ // = TITLE
+ // An adaptive general locking class that defers the decision of
+ // lock type to run time.
+ //
+ // = DESCRIPTION
+ // This class, as ACE_Lock, provide a set of general locking APIs.
+ // However, it defers our decision of what kind of lock to use
+ // to the run time and delegates all locking operations to the actual
+ // lock. Users must overwrite the constructor to initialize <lock_>.
+public:
+ virtual ~ACE_Adaptive_Lock (void) = 0;
+
+ // = Lock/unlock operations.
+
+ virtual int remove (void);
+ virtual int acquire (void);
+ virtual int tryacquire (void);
+ virtual int release (void);
+ virtual int acquire_read (void);
+ virtual int acquire_write (void);
+ virtual int tryacquire_read (void);
+ virtual int tryacquire_write (void);
+ void dump () const;
+
+protected:
+ ACE_Adaptive_Lock (void);
+ // Create and initialize create the actual lcok used in the class.
+ // The default constructor simply set the <lock_> to 0 (null).
+ // You must overwrite this method for this class to work.
+
+ ACE_Lock *lock_;
+};
+
class ACE_Export ACE_File_Lock
{
// = TITLE
@@ -1336,7 +1371,7 @@ private:
#if 0
// The following two classes are commented out since there doesn't
// appear to be a portable and robust means of implementing this
-// functionality across platforms.
+// functionality across platforms.
class ACE_Export ACE_Process_Condition
{