From ddb2b70c40592575f0d77588c2509315e4e0e1f8 Mon Sep 17 00:00:00 2001 From: irfan Date: Tue, 3 Jul 2001 17:31:34 +0000 Subject: ChangeLogTag: Tue Jul 03 12:26:33 2001 Irfan Pyarali --- ChangeLog | 14 ++++++++++++++ ChangeLogs/ChangeLog-02a | 14 ++++++++++++++ ChangeLogs/ChangeLog-03a | 14 ++++++++++++++ ace/Synch_T.h | 30 ++++++++++++++++++++++++++---- ace/Synch_T.i | 13 +++++++++++-- 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 + + * 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 for suggesting this. + Tue Jul 3 06:20:13 2001 Douglas C. Schmidt * 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 + + * 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 for suggesting this. + Tue Jul 3 06:20:13 2001 Douglas C. Schmidt * 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 + + * 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 for suggesting this. + Tue Jul 3 06:20:13 2001 Douglas C. Schmidt * 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 * on construction and destruction. However, there * are *many* varieties of the Guard class and this design @@ -125,12 +125,31 @@ template 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 . - ACE_Reverse_Lock (ACE_LOCKING_MECHANISM &lock); + ACE_Reverse_Lock (ACE_LOCKING_MECHANISM &lock, + ACE_ACQUIRE_METHOD acquire_method = ACE_REGULAR); /// Destructor. If 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 is non-0 then the , else - /// it. + /// it. ACE_Guard (ACE_LOCK &l, int block); /// Initialise the guard without implicitly acquiring the lock. The /// parameter indicates whether the guard should release /// the lock implicitly on destruction. The 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::tryacquire_write_upgrade (void) } template ACE_INLINE -ACE_Reverse_Lock::ACE_Reverse_Lock (ACE_LOCKING_MECHANISM &lock) - : lock_ (lock) +ACE_Reverse_Lock::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::tryacquire (void) template ACE_INLINE int ACE_Reverse_Lock::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 (); } -- cgit v1.2.1