diff options
author | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-09-18 14:08:44 +0000 |
---|---|---|
committer | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-09-18 14:08:44 +0000 |
commit | 2a067002d4ba539e64102adb2dc442dd6d5a4e1f (patch) | |
tree | ec3df18cdcd092fc1514c25d2930282e29469a9a | |
parent | 59034a0d002f307c0d2eac1624ec8e8f850ae399 (diff) | |
download | ATCD-2a067002d4ba539e64102adb2dc442dd6d5a4e1f.tar.gz |
*** empty log message ***
-rw-r--r-- | ChangeLog-97b | 11 | ||||
-rw-r--r-- | ace/ACE_Library.mdp | bin | 163328 -> 163328 bytes | |||
-rw-r--r-- | ace/Dynamic.cpp | 2 | ||||
-rw-r--r-- | ace/Dynamic.h | 21 | ||||
-rw-r--r-- | ace/Dynamic.i | 18 | ||||
-rw-r--r-- | ace/Svc_Handler.cpp | 8 |
6 files changed, 44 insertions, 16 deletions
diff --git a/ChangeLog-97b b/ChangeLog-97b index 873ce74ffb4..d8908de96e8 100644 --- a/ChangeLog-97b +++ b/ChangeLog-97b @@ -1,3 +1,14 @@ +Thu Sep 18 09:04:40 1997 <irfan@TWOSTEP> + + * ace/Dynamic: Changed the way ACE_Dynamic worked. Instead of + keeping the "this" pointer of the object in question, we are now + simply keeping a flag that indicates whether the object was + dynamically created. The trick to this approach is to make sure + to reset the flag in the constructor. The "this" pointer + approach was broken when used with multiple inheritance, because + of "shearing" of the "this" pointer to get to the base + Svc_Handler class. + Thu Sep 18 01:12:36 1997 Douglas C. Schmidt <schmidt@cs.wustl.edu> * ACE version 4.3.8, released Thu Sep 18 01:12:36 1997. diff --git a/ace/ACE_Library.mdp b/ace/ACE_Library.mdp Binary files differindex be7298371ef..1cf17afeee4 100644 --- a/ace/ACE_Library.mdp +++ b/ace/ACE_Library.mdp diff --git a/ace/Dynamic.cpp b/ace/Dynamic.cpp index a94654b56a8..1cc0bdafd45 100644 --- a/ace/Dynamic.cpp +++ b/ace/Dynamic.cpp @@ -9,7 +9,7 @@ #endif /* __ACE_INLINE__ */ ACE_Dynamic::ACE_Dynamic (void) - : instance_ (0) + : is_dynamic_ (0) { ACE_TRACE ("ACE_Dynamic::ACE_Dynamic"); } diff --git a/ace/Dynamic.h b/ace/Dynamic.h index 569f029b6c6..8411dc9ad25 100644 --- a/ace/Dynamic.h +++ b/ace/Dynamic.h @@ -22,7 +22,7 @@ class ACE_Export ACE_Dynamic // = TITLE - // Checks to see if a Svc_Handler was dynamically allocated. + // Checks to see if an object was dynamically allocated. // // = DESCRIPTION // This class holds the pointer in a thread-safe manner between @@ -31,17 +31,22 @@ class ACE_Export ACE_Dynamic public: ACE_Dynamic (void); - void *set (void *x); - // Assign the new pointer to <instance_> in order to keep it safe - // until we can compare it in the constructor. + void set (void); + // Sets a flag that indicates that the object was dynamically + // created. This method is usually called in operator new and then + // checked and reset in the constructor. - int is_dynamic (void *x); + int is_dynamic (void); // 1 if we were allocated dynamically, else 0. + void reset (void); + // Resets state flag. + private: - void *instance_; - // Holds the pointer in a thread-safe manner between the call to - // operator new and the call to the constructor. + int is_dynamic_; + // Flag that indicates that the object was dynamically created. This + // method is usually called in operator new and then checked and + // reset in the constructor. }; #if defined (__ACE_INLINE__) diff --git a/ace/Dynamic.i b/ace/Dynamic.i index 9f051363c30..a8395adc4a5 100644 --- a/ace/Dynamic.i +++ b/ace/Dynamic.i @@ -3,16 +3,24 @@ // Dynamic.i -ACE_INLINE void * -ACE_Dynamic::set (void *x) +ACE_INLINE void +ACE_Dynamic::set (void) { ACE_TRACE ("ACE_Dynamic::set"); - return this->instance_ = x; + this->is_dynamic_ = 1; } ACE_INLINE int -ACE_Dynamic::is_dynamic (void *x) +ACE_Dynamic::is_dynamic () { ACE_TRACE ("ACE_Dynamic::is_dynamic"); - return this->instance_ == x; + return this->is_dynamic_; } + +ACE_INLINE void +ACE_Dynamic::reset (void) +{ + ACE_TRACE ("ACE_Dynamic::set"); + this->is_dynamic_ = 0; +} + diff --git a/ace/Svc_Handler.cpp b/ace/Svc_Handler.cpp index 93638b76c33..ee4113600f9 100644 --- a/ace/Svc_Handler.cpp +++ b/ace/Svc_Handler.cpp @@ -85,7 +85,8 @@ ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_2>::operator new (size_t n) ACE_TRACE ("ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_2>::operator new"); // Allocate the memory and store it (usually in thread-specific // storage, depending on config flags). - return ACE_Svc_Handler<ACE_PEER_STREAM_2, ACE_SYNCH_2>::instance ()->set (::new char[n]); + ACE_Svc_Handler<ACE_PEER_STREAM_2, ACE_SYNCH_2>::instance ()->set (); + return ::new char[n]; } template <PR_ST_1, ACE_SYNCH_1> void @@ -132,7 +133,10 @@ ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_2>::ACE_Svc_Handler (ACE_Thread_Manager *tm, // in the April '96 issue of the C++ Report. We've spruced it up to // work correctly in multi-threaded programs by using our ACE_TSS // class. - this->dynamic_ = ACE_Svc_Handler<ACE_PEER_STREAM_2, ACE_SYNCH_2>::instance()->is_dynamic (this); + this->dynamic_ = ACE_Svc_Handler<ACE_PEER_STREAM_2, ACE_SYNCH_2>::instance()->is_dynamic (); + if (this->dynamic_) + // Make sure to reset the flag + ACE_Svc_Handler<ACE_PEER_STREAM_2, ACE_SYNCH_2>::instance()->reset (); this->closing_ = 0; } |