summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-07-03 17:31:34 +0000
committerirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-07-03 17:31:34 +0000
commitddb2b70c40592575f0d77588c2509315e4e0e1f8 (patch)
tree528ae3e949c929e7dbe58cfad9581428f98463e3
parent3cf6c611c1b2427e9fefd4be02cb6d751bd3fcbf (diff)
downloadATCD-ddb2b70c40592575f0d77588c2509315e4e0e1f8.tar.gz
ChangeLogTag: Tue Jul 03 12:26:33 2001 Irfan Pyarali <irfan@cs.wustl.edu>
-rw-r--r--ChangeLog14
-rw-r--r--ChangeLogs/ChangeLog-02a14
-rw-r--r--ChangeLogs/ChangeLog-03a14
-rw-r--r--ace/Synch_T.h30
-rw-r--r--ace/Synch_T.i13
5 files changed, 79 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 9edecc12ffd..3f5c51425d7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+Tue Jul 03 12:26:33 2001 Irfan Pyarali <irfan@cs.wustl.edu>
+
+ * ace/Synch_T.h (class ACE_Reverse_Lock): Added a parameter to the
+ constructor of the reverse lock. The ACE_ACQUIRE_METHOD
+ parameter is used to indicate which acquire() method will be
+ called on the real lock when the release() method is called on
+ the reverse lock. REGULAR indicated the acquire() method, READ
+ indicates the acquire_read() method, and WRITE indicates the
+ acquire_write() method. Note that the try_*() methods are not
+ represented here because we have to make sure that the release()
+ method on the reverse lock acquires a lock on the real lock.
+
+ Thanks to Edan Ayal <edana@bandwiz.com> for suggesting this.
+
Tue Jul 3 06:20:13 2001 Douglas C. Schmidt <schmidt@tango.doc.wustl.edu>
* ace/Reactor.h,
diff --git a/ChangeLogs/ChangeLog-02a b/ChangeLogs/ChangeLog-02a
index 9edecc12ffd..3f5c51425d7 100644
--- a/ChangeLogs/ChangeLog-02a
+++ b/ChangeLogs/ChangeLog-02a
@@ -1,3 +1,17 @@
+Tue Jul 03 12:26:33 2001 Irfan Pyarali <irfan@cs.wustl.edu>
+
+ * ace/Synch_T.h (class ACE_Reverse_Lock): Added a parameter to the
+ constructor of the reverse lock. The ACE_ACQUIRE_METHOD
+ parameter is used to indicate which acquire() method will be
+ called on the real lock when the release() method is called on
+ the reverse lock. REGULAR indicated the acquire() method, READ
+ indicates the acquire_read() method, and WRITE indicates the
+ acquire_write() method. Note that the try_*() methods are not
+ represented here because we have to make sure that the release()
+ method on the reverse lock acquires a lock on the real lock.
+
+ Thanks to Edan Ayal <edana@bandwiz.com> for suggesting this.
+
Tue Jul 3 06:20:13 2001 Douglas C. Schmidt <schmidt@tango.doc.wustl.edu>
* ace/Reactor.h,
diff --git a/ChangeLogs/ChangeLog-03a b/ChangeLogs/ChangeLog-03a
index 9edecc12ffd..3f5c51425d7 100644
--- a/ChangeLogs/ChangeLog-03a
+++ b/ChangeLogs/ChangeLog-03a
@@ -1,3 +1,17 @@
+Tue Jul 03 12:26:33 2001 Irfan Pyarali <irfan@cs.wustl.edu>
+
+ * ace/Synch_T.h (class ACE_Reverse_Lock): Added a parameter to the
+ constructor of the reverse lock. The ACE_ACQUIRE_METHOD
+ parameter is used to indicate which acquire() method will be
+ called on the real lock when the release() method is called on
+ the reverse lock. REGULAR indicated the acquire() method, READ
+ indicates the acquire_read() method, and WRITE indicates the
+ acquire_write() method. Note that the try_*() methods are not
+ represented here because we have to make sure that the release()
+ method on the reverse lock acquires a lock on the real lock.
+
+ Thanks to Edan Ayal <edana@bandwiz.com> for suggesting this.
+
Tue Jul 3 06:20:13 2001 Douglas C. Schmidt <schmidt@tango.doc.wustl.edu>
* ace/Reactor.h,
diff --git a/ace/Synch_T.h b/ace/Synch_T.h
index 191f1d33749..827d4d1b3a4 100644
--- a/ace/Synch_T.h
+++ b/ace/Synch_T.h
@@ -114,7 +114,7 @@ private:
* the lock.
* One motivation for this class is when we temporarily want to
* release a lock (which we have already acquired) but then
- * reaquire it soon after. An alternative design would be to
+ * reacquire it soon after. An alternative design would be to
* add a Anti_Guard or Reverse_Guard class which would <release>
* on construction and <acquire> destruction. However, there
* are *many* varieties of the Guard class and this design
@@ -125,12 +125,31 @@ template <class ACE_LOCKING_MECHANISM>
class ACE_Reverse_Lock : public ACE_Lock
{
public:
+
+ /**
+ * The ACE_ACQUIRE_METHOD is used to indicate which acquire() method
+ * will be called on the real lock when the release() method is
+ * called on the reverse lock. REGULAR indicated the acquire()
+ * method, READ indicates the acquire_read() method, and WRITE
+ * indicates the acquire_write() method. Note that the try_*()
+ * methods are not represented here because we have to make sure
+ * that the release() method on the reverse lock acquires a lock on
+ * the real lock.
+ **/
+ enum ACE_ACQUIRE_METHOD
+ {
+ ACE_REGULAR,
+ ACE_READ,
+ ACE_WRITE
+ };
+
typedef ACE_LOCKING_MECHANISM ACE_LOCK;
// = Initialization/Finalization methods.
/// Constructor. All locking requests will be forwarded to <lock>.
- ACE_Reverse_Lock (ACE_LOCKING_MECHANISM &lock);
+ ACE_Reverse_Lock (ACE_LOCKING_MECHANISM &lock,
+ ACE_ACQUIRE_METHOD acquire_method = ACE_REGULAR);
/// Destructor. If <lock_> was not passed in by the user, it will be
/// deleted.
@@ -167,6 +186,9 @@ public:
private:
/// The concrete locking mechanism that all the methods delegate to.
ACE_LOCKING_MECHANISM &lock_;
+
+ /// This indicates what kind of acquire method will be called.
+ ACE_ACQUIRE_METHOD acquire_method_;
};
/**
@@ -427,14 +449,14 @@ public:
/// Implicitly and automatically acquire (or try to acquire) the
/// lock. If <block> is non-0 then <acquire> the <ACE_LOCK>, else
- /// <tryacquire> it.
+ /// <tryacquire> it.
ACE_Guard (ACE_LOCK &l, int block);
/// Initialise the guard without implicitly acquiring the lock. The
/// <become_owner> parameter indicates whether the guard should release
/// the lock implicitly on destruction. The <block> parameter is
/// ignored and is used here to disambiguate with the preceding
- /// constructor.
+ /// constructor.
ACE_Guard (ACE_LOCK &l, int block, int become_owner);
/// Implicitly release the lock.
diff --git a/ace/Synch_T.i b/ace/Synch_T.i
index e64a5fe08e3..ff4d7fe7a50 100644
--- a/ace/Synch_T.i
+++ b/ace/Synch_T.i
@@ -258,8 +258,10 @@ ACE_Lock_Adapter<ACE_LOCKING_MECHANISM>::tryacquire_write_upgrade (void)
}
template <class ACE_LOCKING_MECHANISM> ACE_INLINE
-ACE_Reverse_Lock<ACE_LOCKING_MECHANISM>::ACE_Reverse_Lock (ACE_LOCKING_MECHANISM &lock)
- : lock_ (lock)
+ACE_Reverse_Lock<ACE_LOCKING_MECHANISM>::ACE_Reverse_Lock (ACE_LOCKING_MECHANISM &lock,
+ ACE_ACQUIRE_METHOD acquire_method)
+ : lock_ (lock),
+ acquire_method_ (acquire_method)
{
}
@@ -288,6 +290,13 @@ ACE_Reverse_Lock<ACE_LOCKING_MECHANISM>::tryacquire (void)
template <class ACE_LOCKING_MECHANISM> ACE_INLINE int
ACE_Reverse_Lock<ACE_LOCKING_MECHANISM>::release (void)
{
+ switch (this->acquire_method_)
+ {
+ case ACE_READ:
+ return this->lock_.acquire_read ();
+ case ACE_WRITE:
+ return this->lock_.acquire_write ();
+ }
return this->lock_.acquire ();
}