diff options
-rw-r--r-- | ChangeLog-99b | 9 | ||||
-rw-r--r-- | ace/Future.cpp | 16 | ||||
-rw-r--r-- | ace/Future.h | 99 | ||||
-rw-r--r-- | ace/Future_Node.cpp | 43 | ||||
-rw-r--r-- | ace/Future_Node.h | 72 | ||||
-rw-r--r-- | ace/Future_Set.cpp | 21 | ||||
-rw-r--r-- | ace/Future_Set.h | 28 | ||||
-rwxr-xr-x | tests/run_tests.sh | 2 |
8 files changed, 92 insertions, 198 deletions
diff --git a/ChangeLog-99b b/ChangeLog-99b index 7c118c14b15..9cab1c181f6 100644 --- a/ChangeLog-99b +++ b/ChangeLog-99b @@ -1,5 +1,14 @@ Sun Jul 18 14:30:54 1999 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> + * tests/run_tests.sh: Reenabled the Future_Set_Test. Hopefully, + this will work on Solaris and the other platforms now! + + * ace/Future*: Added some fixes for Future_Set that should prevent + it from hanging indefinitely on certain platforms. Also, + removed the Future_Node.h and Future_Node.cpp files since they + are no longer used. Thanks to John Tucker + <jtucker@infoglide.com> for contributing these fixes. + * ace/SOCK_Dgram_Mcast: Finished implementing the QoS-enabled APIs for socket datagram multicast. This required refactoring quite a bit of code and adding some new methods that take the diff --git a/ace/Future.cpp b/ace/Future.cpp index eb54be3b2fa..f9958779411 100644 --- a/ace/Future.cpp +++ b/ace/Future.cpp @@ -5,7 +5,7 @@ #ifndef ACE_FUTURE_CPP #define ACE_FUTURE_CPP -#include "ace/Future.h" +#include /**/ "ace/Future.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once @@ -49,7 +49,7 @@ ACE_Future_Rep<T>::dump (void) const ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); ACE_DEBUG ((LM_DEBUG, "ref_count_ = %d\n", - (int) this->ref_count_)); + (int) this->ref_count_)); ACE_DEBUG ((LM_INFO,"value_: \n")); if (this->value_) ACE_DEBUG ((LM_DEBUG, ASYS_TEXT (" (NON-NULL)\n"))); @@ -67,11 +67,7 @@ template <class T> ACE_Future_Rep<T> * ACE_Future_Rep<T>::create (void) { // Yes set ref count to zero. - ACE_Future_Rep<T> *t = 0; - ACE_NEW_RETURN (t, - ACE_Future_Rep<T>, - 0); - return t; + return new ACE_Future_Rep<T> (); } template <class T> ACE_Future_Rep<T> * @@ -160,10 +156,10 @@ ACE_Future_Rep<T>::set (const T &r, -1); // Remove and notify all subscribed observers. - ACE_TYPENAME OBSERVER_COLLECTION::iterator iterator = + OBSERVER_COLLECTION::iterator iterator = this->observer_collection_.begin (); - ACE_TYPENAME OBSERVER_COLLECTION::iterator end = + OBSERVER_COLLECTION::iterator end = this->observer_collection_.end (); for (; @@ -273,7 +269,7 @@ ACE_Future<T>::ACE_Future (void) template <class T> ACE_Future<T>::ACE_Future (const ACE_Future<T> &r) - : future_rep_ (FUTURE_REP::attach (( (ACE_Future<T> &) r).future_rep_)) + : future_rep_ (FUTURE_REP::attach (((ACE_Future<T> &) r).future_rep_)) { } diff --git a/ace/Future.h b/ace/Future.h index 6a001c677ee..b93fefa3ee6 100644 --- a/ace/Future.h +++ b/ace/Future.h @@ -9,7 +9,7 @@ // = FILENAME // Future.h // -// = AUTHOR +// = AUTHOR (S) // Andres Kruse <Andres.Kruse@cern.ch>, // Douglas C. Schmidt <schmidt@cs.wustl.edu>, // Per Andersson <Per.Andersson@hfera.ericsson.se>, and @@ -20,8 +20,8 @@ #ifndef ACE_FUTURE_H #define ACE_FUTURE_H -#include "ace/Synch.h" -#include "ace/Strategies_T.h" +#include /**/ "ace/Synch.h" +#include /**/ "ace/Strategies_T.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once @@ -61,9 +61,9 @@ class ACE_Future_Observer // ACE_Future_Observer<T> // // = DESCRIPTION - // An ACE_Future_Observer<T> object implements an object that is - // subscribed with an ACE_Future<T> object so that it may be - // notified when the value of the ACE_Future<T> object is + // An ACE_Future_Observer object implements an object that is + // subscribed with an ACE_Future object so that it may be + // notified when the value of the ACE_Future object is // written to by a writer thread. // // It uses the Observer pattern @@ -71,8 +71,8 @@ public: // = Destructor virtual ~ACE_Future_Observer (void); - virtual void update(const ACE_Future<T> &future) = 0; - // Called by the ACE_Future<T> in which we are subscribed to when + virtual void update (const ACE_Future<T> &future) = 0; + // Called by the ACE_Future in which we are subscribed to when // its value is written to. ACE_ALLOC_HOOK_DECLARE; @@ -97,6 +97,33 @@ class ACE_Future_Rep private: friend class ACE_Future<T>; + // Create, attach, detach and assign encapsulates the reference + // count handling and the object lifetime of ACE_Future_Rep<T> + // instances. + + static ACE_Future_Rep<T> *create (void); + // Create a ACE_Future_Rep<T> and initialize the reference count. + + static ACE_Future_Rep<T> *attach (ACE_Future_Rep<T> *&rep); + // Increase the reference count and return argument. Uses the + // attribute "value_ready_mutex_" to synchronize reference count + // updating. + // + // Precondition (rep != 0). + + static void detach (ACE_Future_Rep<T> *&rep); + // Decreases the reference count and and deletes rep if there are no + // more references to rep. + // + // Precondition (rep != 0) + + static void assign (ACE_Future_Rep<T> *&rep, + ACE_Future_Rep<T> *new_rep); + // Decreases the rep's reference count and and deletes rep if there + // are no more references to rep. Then assigns new_rep to rep. + // + // Precondition (rep != 0 && new_rep != 0) + int set (const T &r, ACE_Future<T> &caller); // Set the result value. The specified <caller> represents the @@ -111,8 +138,8 @@ private: int attach (ACE_Future_Observer<T> *observer, ACE_Future<T> &caller); // Attaches the specified observer to a subject (i.e. the - // ACE_Future_Rep). The update method of the specified subject will - // be invoked with a copy of the written-to ACE_Future as input when + // <ACE_Future_Rep>). The update method of the specified subject will + // be invoked with a copy of the written-to <ACE_Future> as input when // the result gets set. // // Returns 0 if the observer is successfully attached, 1 if the @@ -120,13 +147,13 @@ private: int detach (ACE_Future_Observer<T> *observer); // Detaches the specified observer from a subject (i.e. the - // ACE_Future_Rep). The update method of the specified subject will - // not be invoked when the ACE_Future_Reps result gets set. Returns + // <ACE_Future_Rep>). The update method of the specified subject will + // not be invoked when the <ACE_Future_Rep>s result gets set. Returns // 1 if the specified observer was actually attached to the subject // prior to this call and 0 if was not. // - // Returns 0 if the observer was successfully detached, and -1 if the observer was - // not attached in the first place. + // Returns 0 if the observer was successfully detached, and -1 if the + // observer was not attached in the first place. operator T (); // Type conversion. will block forever until the result is @@ -150,34 +177,6 @@ private: int ready (void); // Is result available? - // = Handle ref counting and object lifetime for ACE_Future_Rep<T>. - - // These methods must go after the others to work around a bug with - // Borland's C++ Builder. - - static ACE_Future_Rep<T> *create (void); - // Create a ACE_Future_Rep<T> and initialize the reference count. - - static ACE_Future_Rep<T> *attach (ACE_Future_Rep<T> *&rep); - // Increase the reference count and return argument. Uses the - // attribute "value_ready_mutex_" to synchronize reference count - // updating. - // - // Precondition(rep != 0). - - static void detach (ACE_Future_Rep<T> *&rep); - // Decreases the reference count and and deletes rep if there are no - // more references to rep. - // - // Precondition(rep != 0) - - static void assign (ACE_Future_Rep<T> *&rep, - ACE_Future_Rep<T> *new_rep); - // Decreases the rep's reference count and and deletes rep if there - // are no more references to rep. Then assigns new_rep to rep. - // - // Precondition(rep != 0 && new_rep != 0) - T *value_; // Pointer to the result. @@ -267,8 +266,8 @@ public: int attach (ACE_Future_Observer<T> *observer); // Attaches the specified observer to a subject (i.e. the - // ACE_Future). The update method of the specified subject will be - // invoked with a copy of the associated ACE_Future as input when + // <ACE_Future>). The update method of the specified subject will be + // invoked with a copy of the associated <ACE_Future> as input when // the result gets set. If the result is already set when this // method gets invoked, then the update method of the specified // subject will be invoked immediately. @@ -278,8 +277,8 @@ public: int detach (ACE_Future_Observer<T> *observer); // Detaches the specified observer from a subject (i.e. the - // ACE_Future_Rep). The update method of the specified subject will - // not be invoked when the ACE_Future_Reps result gets set. Returns + // <ACE_Future_Rep>). The update method of the specified subject will + // not be invoked when the <ACE_Future_Reps> result gets set. Returns // 1 if the specified observer was actually attached to the subject // prior to this call and 0 if was not. // @@ -289,9 +288,9 @@ public: void dump (void) const; // Dump the state of an object. - ACE_Future_Rep<T> *get_rep(); - // Get the underlying ACE_Future_Rep<T>*. Note that this method should - // rarely, if ever, be used and that modifying the undlerlying ACE_Future_Rep<T>* + ACE_Future_Rep<T> *get_rep (); + // Get the underlying <ACE_Future_Rep>*. Note that this method should + // rarely, if ever, be used and that modifying the undlerlying <ACE_Future_Rep>* // should be done with extreme caution. ACE_ALLOC_HOOK_DECLARE; @@ -304,7 +303,7 @@ private: void operator delete (void *); // Do not allow delete operator - void operator &(); + void operator & (); // Do not allow address-of operator. // the ACE_Future_Rep diff --git a/ace/Future_Node.cpp b/ace/Future_Node.cpp deleted file mode 100644 index 79c8706dc7f..00000000000 --- a/ace/Future_Node.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// Future.cpp -// $Id$ - -#define ACE_BUILD_DLL - -#ifndef ACE_FUTURE_NODE_CPP -#define ACE_FUTURE_NODE_CPP - -#include "ace/OS.h" -#include "ace/Future_Node.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -ACE_RCSID(ace, Future_Node, "$Id$") - -#if defined (ACE_HAS_THREADS) - -template <class T> -ACE_DLList_Future_Node<T>::ACE_DLList_Future_Node (void) - : next_ (0), - prev_ (0) -{ -} - -template <class T> -ACE_DLList_Future_Node<T>::ACE_DLList_Future_Node (const ACE_Future<T> &item, - ACE_DLList_Future_Node<T> *n, - ACE_DLList_Future_Node<T> *p) -: item_ (item), - next_ (n), - prev_ (p) -{ -} - -template <class T> -ACE_DLList_Future_Node<T>::~ACE_DLList_Future_Node (void) -{ -} - -#endif /* ACE_HAS_THREADS */ -#endif /* ACE_FUTURE_NODE_CPP */ diff --git a/ace/Future_Node.h b/ace/Future_Node.h deleted file mode 100644 index 8590cbaccca..00000000000 --- a/ace/Future_Node.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// ace -// -// = FILENAME -// Future_Node.h -// -// = AUTHOR -// John Tucker <jtucker@infoglide.com> -// -// ============================================================================ - -#ifndef ACE_FUTURE_NODE_H -#define ACE_FUTURE_NODE_H - -#include "ace/Future.h" -#include "ace/Thread.h" -#include "ace/Containers_T.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if defined (ACE_HAS_THREADS) - -// Forward decl. -template <class T> class ACE_Future_Node; -template <class T> class ACE_DLList_Future_Node; - -template <class T> -class ACE_DLList_Future_Node -{ - // = TITLE - // Implementation of element in a ACE_Future list. - // Needed for ACE_Double_Linked_List. - - friend class ACE_Double_Linked_List<ACE_DLList_Future_Node>; - friend class ACE_Double_Linked_List_Iterator<ACE_DLList_Future_Node>; - -public: - // = Initialization - ACE_DLList_Future_Node (const ACE_Future<T> &future, - ACE_DLList_Future_Node *n = 0, - ACE_DLList_Future_Node *p = 0); - ~ACE_DLList_Future_Node (void); - - ACE_ALLOC_HOOK_DECLARE; - // Declare the dynamic allocation hooks. - - ACE_Future<T> item_; - ACE_DLList_Future_Node *next_; - ACE_DLList_Future_Node *prev_; - -protected: - ACE_DLList_Future_Node (void); -}; - - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "ace/Future_Node.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("Future_Node.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - -#endif /* ACE_HAS_THREADS */ -#endif /* ACE_FUTURE_NODE_H */ diff --git a/ace/Future_Set.cpp b/ace/Future_Set.cpp index 8e6eab8a779..55cdd222632 100644 --- a/ace/Future_Set.cpp +++ b/ace/Future_Set.cpp @@ -6,18 +6,18 @@ #ifndef ACE_FUTURE_SET_CPP #define ACE_FUTURE_SET_CPP -#include "ace/Future_Set.h" +#include /**/ "ace/Future_Set.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -ACE_RCSID(ace, Future_Set, "$Id$") +ACE_RCSID (ace, Future_Set, "$Id$") #if defined (ACE_HAS_THREADS) template <class T> -ACE_Future_Set<T>::ACE_Future_Set (ACE_DEFAULT_MESSAGE_QUEUE_TYPE *new_queue) +ACE_Future_Set<T>::ACE_Future_Set (ACE_Message_Queue<ACE_SYNCH> *new_queue) : delete_queue_ (0) { if (new_queue) @@ -56,7 +56,7 @@ ACE_Future_Set<T>::~ACE_Future_Set (void) template <class T> int ACE_Future_Set<T>::is_empty () const { - return ( ((ACE_Future_Set<T>*)this)->future_map_.current_size () == 0 ); + return (((ACE_Future_Set<T>*)this)->future_map_.current_size () == 0 ); } template <class T> int @@ -71,9 +71,9 @@ ACE_Future_Set<T>::insert (ACE_Future<T> &future) int result = this->future_map_.bind (future_rep, future_holder); - // If a new map entry was created, then attach to the future, otherwise - // we were already attached to the future or some error occurred so just - // delete the future holder. + // If a new map entry was created, then attach to the future, + // otherwise we were already attached to the future or some error + // occurred so just delete the future holder. if ( result == 0 ) // Attach ourself to the ACE_Futures list of observer future.attach (this); @@ -87,7 +87,7 @@ template <class T> void ACE_Future_Set<T>::update (const ACE_Future<T> &future) { ACE_Message_Block *mb; - FUTURE local_future = future; + FUTURE &local_future = ACE_const_cast (ACE_Future<T> &, future); ACE_NEW (mb, ACE_Message_Block ((char *) local_future.get_rep (), 0)); @@ -106,6 +106,11 @@ ACE_Future_Set<T>::next_readable (ACE_Future<T> &future, ACE_Message_Block *mb; FUTURE_REP *future_rep = 0; + int isd = + this->future_notification_queue_->deactivated (); + int ise = + this->future_notification_queue_->is_empty (); + // Wait for a "readable future" signal from the message queue. if (this->future_notification_queue_->dequeue_head (mb, tv) != -1) diff --git a/ace/Future_Set.h b/ace/Future_Set.h index 319ab3242e0..a3187a59312 100644 --- a/ace/Future_Set.h +++ b/ace/Future_Set.h @@ -9,7 +9,7 @@ // = FILENAME // Future_Set.h // -// = AUTHOR +// = AUTHOR (S) // John Tucker <jtucker@infoglide.com> // // ============================================================================ @@ -17,10 +17,10 @@ #ifndef ACE_FUTURE_SET_H #define ACE_FUTURE_SET_H -#include "ace/Thread.h" -#include "ace/Message_Queue.h" -#include "ace/Future.h" -#include "ace/Hash_Map_Manager.h" +#include /**/ "ace/Thread.h" +#include /**/ "ace/Message_Queue.h" +#include /**/ "ace/Future.h" +#include /**/ "ace/Hash_Map_Manager.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once @@ -33,23 +33,23 @@ class ACE_Future_Set : public ACE_Future_Observer<T> { // = TITLE // This class implements a mechanism which allows the values of - // a collections of ACE_Future<T> objects to be accessed by + // a collections of <ACE_Future> objects to be accessed by // reader threads as they become available. public: // = Initialization and termination methods. - ACE_Future_Set (ACE_DEFAULT_MESSAGE_QUEUE_TYPE *new_queue = 0); + ACE_Future_Set (ACE_Message_Queue<ACE_SYNCH> *future_notification_queue_ = 0); // Constructor. ~ACE_Future_Set (void); // Destructor. int is_empty (void) const; - // Return 1 if their are no ACE_Future objects left on its queue and + // Return 1 if their are no <ACE_Future> objects left on its queue and // 0 otherwise int insert (ACE_Future<T> &future); - // Enqueus the given ACE_Future into this objects queue when it is + // Enqueus the given <ACE_Future> into this objects queue when it is // readable. // // Returns 0 if the future is successfully inserted, 1 if the @@ -59,7 +59,7 @@ public: ACE_Time_Value *tv = 0); // Wait up to <tv> time to get the <value>. Note that <tv> must be // specified in absolute time rather than relative time.); get the - // next ACE_Future<T> that is readable. If <tv> = 0, the will block + // next <ACE_Future> that is readable. If <tv> = 0, the will block // forever. // // If a readable future becomes available, then the input result @@ -67,7 +67,7 @@ public: // is empty, then 0 is returned. virtual void update (const ACE_Future<T> &future); - // Called by the ACE_Future<T> subject in which we are subscribed to + // Called by the <ACE_Future> subject in which we are subscribed to // when its value is written to. ACE_ALLOC_HOOK_DECLARE; @@ -92,14 +92,14 @@ private: FUTURE_HOLDER *, FUTURE_REP_HASH, FUTURE_REP_COMPARE, - ACE_Null_Mutex> FUTURE_HASH_MAP; + ACE_Null_Mutex> FUTURE_HASH_MAP; FUTURE_HASH_MAP future_map_; - // Map of ACE_Futures, subjects, which have not been written to by + // Map of <ACE_Futures>, subjects, which have not been written to by // client's writer thread. ACE_Message_Queue<ACE_SYNCH> *future_notification_queue_; - // Message queue for notifying the reader thread of ACE_Futures which + // Message queue for notifying the reader thread of <ACE_Futures> which // have been written to by client's writer thread. int delete_queue_; diff --git a/tests/run_tests.sh b/tests/run_tests.sh index a127575bae0..88532d01b55 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -154,7 +154,7 @@ run Task_Test # tests ACE_Thread_Manager, ACE_Task test $Unicos || run Thread_Manager_Test # tests ACE_Thread_Manager, ACE_Task run Thread_Pool_Test # tests ACE_Thread_Manager, ACE_Task run Future_Test # tests ACE_Thread_Manager, ACE_Task, ACE_Future -# run Future_Set_Test # tests ACE_Thread_Manager, ACE_Task, ACE_Future_Set +run Future_Set_Test # tests ACE_Thread_Manager, ACE_Task, ACE_Future_Set run RB_Tree_Test # tests ACE_RB_Tree, ACE_RB_Tree_Iterator run Reactors_Test # tests ACE_Task, ACE_Mutex, ACE_Reactor run Reactor_Exceptions_Test # tests ACE_Reactor and C++ exceptions |