diff options
author | kircher_m <kircher_m@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2001-11-21 17:34:50 +0000 |
---|---|---|
committer | kircher_m <kircher_m@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2001-11-21 17:34:50 +0000 |
commit | f6ed44bf3520fbb91b05fa24d0bf3ea4cb4825b4 (patch) | |
tree | 2e196eec58a3bae5f8ba02e6a182985951baef62 /ace | |
parent | d56c392e9961ffbf780734f0463e47efb9867128 (diff) | |
download | ATCD-f6ed44bf3520fbb91b05fa24d0bf3ea4cb4825b4.tar.gz |
ChangeLogTag: Wed Nov 21 11:35:50 2001 Michael Kircher <Michael.Kircher@mchp.siemens.de>
Diffstat (limited to 'ace')
-rw-r--r-- | ace/Bound_Ptr.h | 4 | ||||
-rw-r--r-- | ace/Bound_Ptr.i | 33 | ||||
-rw-r--r-- | ace/Future.cpp | 19 | ||||
-rw-r--r-- | ace/Future.h | 4 | ||||
-rw-r--r-- | ace/Refcounted_Auto_Ptr.h | 4 | ||||
-rw-r--r-- | ace/Refcounted_Auto_Ptr.i | 17 |
6 files changed, 68 insertions, 13 deletions
diff --git a/ace/Bound_Ptr.h b/ace/Bound_Ptr.h index 4b5bbec5bed..094bdb6b8d2 100644 --- a/ace/Bound_Ptr.h +++ b/ace/Bound_Ptr.h @@ -66,6 +66,10 @@ public: static int object_was_deleted (ACE_Bound_Ptr_Counter<ACE_LOCK> *counter); private: + /// Allocate a new ACE_Bound_Ptr_Counter<ACE_LOCK> instance, returning NULL + /// if it cannot be created. + static ACE_Bound_Ptr_Counter<ACE_LOCK> *internal_create (int init_obj_ref_count); + /// Reference count of underlying object. Is set to -1 once the object has /// been destroyed to indicate to all weak pointers that it is no longer valid. int obj_ref_count_; diff --git a/ace/Bound_Ptr.i b/ace/Bound_Ptr.i index 8bacc270309..964c7975dd9 100644 --- a/ace/Bound_Ptr.i +++ b/ace/Bound_Ptr.i @@ -6,17 +6,31 @@ #include "Synch_T.h" template <class ACE_LOCK> inline ACE_Bound_Ptr_Counter<ACE_LOCK> * -ACE_Bound_Ptr_Counter<ACE_LOCK>::create_strong (void) +ACE_Bound_Ptr_Counter<ACE_LOCK>::internal_create (int init_obj_ref_count) { - // Set initial object reference count to 1. - ACE_Bound_Ptr_Counter<ACE_LOCK> *temp = 0; ACE_NEW_RETURN (temp, - ACE_Bound_Ptr_Counter<ACE_LOCK> (1), + ACE_Bound_Ptr_Counter<ACE_LOCK> (init_obj_ref_count), 0); return temp; } +template <class ACE_LOCK> inline ACE_Bound_Ptr_Counter<ACE_LOCK> * +ACE_Bound_Ptr_Counter<ACE_LOCK>::create_strong (void) +{ + // Set initial object reference count to 1. + ACE_Bound_Ptr_Counter<ACE_LOCK> *temp = internal_create (1); +#if defined (ACE_NEW_THROWS_EXCEPTIONS) + if (temp == 0) + ACE_throw_bad_alloc; +#else + ACE_ASSERT (temp != 0); +#endif /* ACE_NEW_THROWS_EXCEPTIONS */ + return temp; +} + + + template <class ACE_LOCK> inline int ACE_Bound_Ptr_Counter<ACE_LOCK>::attach_strong (ACE_Bound_Ptr_Counter<ACE_LOCK>* counter) { @@ -66,10 +80,13 @@ ACE_Bound_Ptr_Counter<ACE_LOCK>::create_weak (void) { // Set initial object reference count to 0. - ACE_Bound_Ptr_Counter<ACE_LOCK> *temp = 0; - ACE_NEW_RETURN (temp, - ACE_Bound_Ptr_Counter<ACE_LOCK> (), - 0); + ACE_Bound_Ptr_Counter<ACE_LOCK> *temp = internal_create (0); +#if defined (ACE_NEW_THROWS_EXCEPTIONS) + if (temp == 0) + ACE_throw_bad_alloc; +#else + ACE_ASSERT (temp != 0); +#endif /* ACE_NEW_THROWS_EXCEPTIONS */ return temp; } diff --git a/ace/Future.cpp b/ace/Future.cpp index c132ba240d3..d2f452b1874 100644 --- a/ace/Future.cpp +++ b/ace/Future.cpp @@ -62,10 +62,8 @@ ACE_Future_Rep<T>::dump (void) const } template <class T> ACE_Future_Rep<T> * -ACE_Future_Rep<T>::create (void) +ACE_Future_Rep<T>::internal_create (void) { - // Yes set ref count to zero. - ACE_Future_Rep<T> *temp = 0; ACE_NEW_RETURN (temp, ACE_Future_Rep<T> (), @@ -74,6 +72,21 @@ ACE_Future_Rep<T>::create (void) } template <class T> ACE_Future_Rep<T> * +ACE_Future_Rep<T>::create (void) +{ + // Yes set ref count to zero. + ACE_Future_Rep<T> *temp = internal_create (); +#if defined (ACE_NEW_THROWS_EXCEPTIONS) + if (temp == 0) + ACE_throw_bad_alloc; +#else + ACE_ASSERT (temp != 0); +#endif /* ACE_NEW_THROWS_EXCEPTIONS */ + return temp; + } + + +template <class T> ACE_Future_Rep<T> * ACE_Future_Rep<T>::attach (ACE_Future_Rep<T>*& rep) { ACE_ASSERT (rep != 0); diff --git a/ace/Future.h b/ace/Future.h index 58f30cdf60a..b0bf55816b3 100644 --- a/ace/Future.h +++ b/ace/Future.h @@ -161,6 +161,10 @@ private: // These methods must go after the others to work around a bug with // Borland's C++ Builder... + /// Allocate a new ACE_Future_Rep<T> instance, returning NULL if it + /// cannot be created. + static ACE_Future_Rep<T> *internal_create (void); + /// Create a ACE_Future_Rep<T> and initialize the reference count. static ACE_Future_Rep<T> *create (void); diff --git a/ace/Refcounted_Auto_Ptr.h b/ace/Refcounted_Auto_Ptr.h index 0e95f360f1e..f28fdc2cbfb 100644 --- a/ace/Refcounted_Auto_Ptr.h +++ b/ace/Refcounted_Auto_Ptr.h @@ -133,6 +133,10 @@ private: // These methods must go after the others to work around a bug with // Borland's C++ Builder... + /// Allocate a new ACE_Refcounted_Auto_Ptr_Rep<X, ACE_LOCK> instance, + /// returning NULL if it cannot be created. + static ACE_Refcounted_Auto_Ptr_Rep<X, ACE_LOCK> *internal_create (X *p); + /// Create a ACE_Refcounted_Auto_Ptr_Rep<X, ACE_LOCK> and initialize /// the reference count. static ACE_Refcounted_Auto_Ptr_Rep<X, ACE_LOCK> *create (X *p); diff --git a/ace/Refcounted_Auto_Ptr.i b/ace/Refcounted_Auto_Ptr.i index e927cdd4b66..90baf4dac92 100644 --- a/ace/Refcounted_Auto_Ptr.i +++ b/ace/Refcounted_Auto_Ptr.i @@ -21,9 +21,8 @@ ACE_Refcounted_Auto_Ptr<X, ACE_LOCK>::null (void) const } template <class X, class ACE_LOCK> inline ACE_Refcounted_Auto_Ptr_Rep<X, ACE_LOCK> * -ACE_Refcounted_Auto_Ptr_Rep<X, ACE_LOCK>::create (X *p) +ACE_Refcounted_Auto_Ptr_Rep<X, ACE_LOCK>::internal_create (X *p) { - // Yes set ref count to zero. ACE_Refcounted_Auto_Ptr_Rep<X, ACE_LOCK> *temp = 0; ACE_NEW_RETURN (temp, (ACE_Refcounted_Auto_Ptr_Rep<X, ACE_LOCK>) (p), @@ -32,6 +31,20 @@ ACE_Refcounted_Auto_Ptr_Rep<X, ACE_LOCK>::create (X *p) } template <class X, class ACE_LOCK> inline ACE_Refcounted_Auto_Ptr_Rep<X, ACE_LOCK> * +ACE_Refcounted_Auto_Ptr_Rep<X, ACE_LOCK>::create (X *p) +{ + // Yes set ref count to zero. + ACE_Refcounted_Auto_Ptr_Rep<X, ACE_LOCK> *temp = internal_create (p); +#if defined (ACE_NEW_THROWS_EXCEPTIONS) + if (temp == 0) + ACE_throw_bad_alloc; +#else + ACE_ASSERT (temp != 0); +#endif /* ACE_NEW_THROWS_EXCEPTIONS */ + return temp; +} + +template <class X, class ACE_LOCK> inline ACE_Refcounted_Auto_Ptr_Rep<X, ACE_LOCK> * ACE_Refcounted_Auto_Ptr_Rep<X, ACE_LOCK>::attach (ACE_Refcounted_Auto_Ptr_Rep<X, ACE_LOCK>*& rep) { ACE_ASSERT (rep != 0); |