diff options
author | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-06-30 00:19:39 +0000 |
---|---|---|
committer | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-06-30 00:19:39 +0000 |
commit | 31d33e922ab241e7a8e20978d8a7dc45d5dbb50f (patch) | |
tree | e4adeac635d64faf2b22f588c3d176a7d7037d6b | |
parent | a3433c3c25002c87189ab0915a06972a90d03363 (diff) | |
download | ATCD-31d33e922ab241e7a8e20978d8a7dc45d5dbb50f.tar.gz |
Tue Jun 29 18:48:22 1999 Irfan Pyarali <irfan@cs.wustl.edu>
-rw-r--r-- | ChangeLog-99b | 8 | ||||
-rw-r--r-- | ace/Functor_T.h | 25 | ||||
-rw-r--r-- | ace/Functor_T.i | 7 | ||||
-rw-r--r-- | ace/Future_Set.cpp | 43 | ||||
-rw-r--r-- | ace/Future_Set.h | 29 |
5 files changed, 65 insertions, 47 deletions
diff --git a/ChangeLog-99b b/ChangeLog-99b index 1d933992613..c4789211d35 100644 --- a/ChangeLog-99b +++ b/ChangeLog-99b @@ -1,4 +1,10 @@ -Tue Jun 29 14:45:38 1999 Irfan Pyarali <irfan@cs.wustl.edu> +Tue Jun 29 18:48:22 1999 Irfan Pyarali <irfan@cs.wustl.edu> + + * ace/Functor_T.h (class ACE_Pointer_Hash): Added new class for + hashing pointers on their values. + + * ace/Future_Set: Restored future map to be a + ACE_Hash_Map_Manager_Ex. * tests/run_tests.bat: Removed New_Fail_Test from the run_tests.bat (the script for NT). This tests takes too long to diff --git a/ace/Functor_T.h b/ace/Functor_T.h index 710a2a22218..238cea27650 100644 --- a/ace/Functor_T.h +++ b/ace/Functor_T.h @@ -10,9 +10,9 @@ // Functor_T.h // // = DESCRIPTION -// Templatized classes for implementing function objects that are used in -// various places in ACE. There are currently two major categories of -// function objects in ACE: GOF Command Pattern objects, and STL-style +// Templatized classes for implementing function objects that are used in +// various places in ACE. There are currently two major categories of +// function objects in ACE: GOF Command Pattern objects, and STL-style // functors for comparison of container elements. The command objects // are invoked via an execute () method, while the STL-style functors are // invoked via an operator() () method. @@ -91,21 +91,33 @@ class ACE_Hash // Function object for hashing // public: - u_long operator () (const TYPE &t) const; + u_long operator () (const TYPE &t) const; // Simply calls t.hash () }; template <class TYPE> +class ACE_Pointer_Hash +{ + // = TITLE + // + // Function object for hashing pointers + // +public: + u_long operator () (TYPE t) const; + // Simply returns t. +}; + +template <class TYPE> class ACE_Equal_To { // = TITLE // - // Function object for comparing two objects of + // Function object for comparing two objects of // the given type for equality. // public: int operator () (const TYPE &lhs, - const TYPE &rhs) const; + const TYPE &rhs) const; // Simply calls operator== }; @@ -123,7 +135,6 @@ public: // Simply calls operator< }; - #if defined (__ACE_INLINE__) #include "ace/Functor_T.i" #endif /* __ACE_INLINE__ */ diff --git a/ace/Functor_T.i b/ace/Functor_T.i index 0024cd3fd23..52e38166dac 100644 --- a/ace/Functor_T.i +++ b/ace/Functor_T.i @@ -39,6 +39,12 @@ ACE_Hash<TYPE>::operator () (const TYPE &t) const return t.hash (); } +template <class TYPE> ACE_INLINE u_long +ACE_Pointer_Hash<TYPE>::operator () (TYPE t) const +{ + return u_long (t); +} + template <class TYPE> ACE_INLINE int ACE_Equal_To<TYPE>::operator () (const TYPE &lhs, const TYPE &rhs) const @@ -52,4 +58,3 @@ ACE_Less_Than<TYPE>::operator () (const TYPE &lhs, { return (lhs < rhs) ? 1 : 0; } - diff --git a/ace/Future_Set.cpp b/ace/Future_Set.cpp index 4fd3c5d7a89..6f98b36aede 100644 --- a/ace/Future_Set.cpp +++ b/ace/Future_Set.cpp @@ -16,7 +16,7 @@ ACE_RCSID(ace, Future_Set, "$Id$") #if defined (ACE_HAS_THREADS) -template <class T> + template <class T> ACE_Future_Set<T>::ACE_Future_Set (ACE_Message_Queue<ACE_SYNCH> *new_queue) : delete_queue_ (0) { @@ -38,16 +38,14 @@ ACE_Future_Set<T>::ACE_Future_Set (const ACE_Future_Set<T> &r) template <class T> ACE_Future_Set<T>::~ACE_Future_Set (void) { - FUTURE_ENTRY *map_entry = 0; - - // Detach ourselves from all remaining futures, if any, - // in our map. - - for (FUTURE_ITERATOR map_iterator (this->future_map_); - map_iterator.next (map_entry) != 0; - map_iterator.advance ()) + // Detach ourselves from all remaining futures, if any, in our map. + FUTURE_HASH_MAP::iterator iterator = this->future_map_.begin (); + FUTURE_HASH_MAP::iterator end = this->future_map_.end (); + for (; + iterator != end; + ++iterator) { - FUTURE_HOLDER *future_holder = map_entry->int_id_; + FUTURE_HOLDER *future_holder = (*iterator).int_id_; future_holder->item_.detach (this); delete future_holder; } @@ -59,7 +57,7 @@ ACE_Future_Set<T>::~ACE_Future_Set (void) template <class T> int ACE_Future_Set<T>::is_empty () const { - return this->future_map_.current_size () == 0; + return ( ((ACE_Future_Set<T>*)this)->future_map_.current_size () == 0 ); } template <class T> int @@ -70,13 +68,14 @@ ACE_Future_Set<T>::insert (ACE_Future<T> &future) FUTURE_HOLDER (future), -1); - int result = this->future_map_.bind (future.get_rep (), + FUTURE_REP *future_rep = future.get_rep (); + 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 (result == 0) + // 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); else @@ -89,9 +88,10 @@ template <class T> void ACE_Future_Set<T>::update (const ACE_Future<T> &future) { ACE_Message_Block *mb; - FUTURE localFuture = future; + FUTURE local_future = future; + ACE_NEW (mb, - ACE_Message_Block ((char *) localFuture.get_rep (), 0)); + ACE_Message_Block ((char *) local_future.get_rep (), 0)); // Enqueue in priority order. this->future_notification_queue_->enqueue (mb, 0); @@ -105,7 +105,7 @@ ACE_Future_Set<T>::next_readable (ACE_Future<T> &future, return 0; ACE_Message_Block *mb; - FUTURE_REP *future_rep; + FUTURE_REP *future_rep = 0; // Wait for a "readable future" signal from the message queue. if (this->future_notification_queue_->dequeue_head (mb, @@ -124,9 +124,8 @@ ACE_Future_Set<T>::next_readable (ACE_Future<T> &future, // Remove the hash map entry with the specified future rep from our map. FUTURE_HOLDER *future_holder; - - if (this->future_map_.find (future_rep, - future_holder) != -1) + if ( this->future_map_.find (future_rep, + future_holder) != -1 ) { future = future_holder->item_; this->future_map_.unbind (future_rep); diff --git a/ace/Future_Set.h b/ace/Future_Set.h index 5d44300470a..183b6132725 100644 --- a/ace/Future_Set.h +++ b/ace/Future_Set.h @@ -17,11 +17,10 @@ #ifndef ACE_FUTURE_SET_H #define ACE_FUTURE_SET_H -#include "ace/Map_Manager.h" -#include "ace/Strategies_T.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 @@ -53,7 +52,7 @@ public: // 0 otherwise int insert (ACE_Future<T> &future); - // Enqueues 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 @@ -82,25 +81,23 @@ private: // Copy constructor binds <this> and <r> to the same // <ACE_Future_Set>. An <ACE_Future_Set> is created if necessary. - typedef ACE_Future<T> - FUTURE; + typedef ACE_Future<T> FUTURE; - typedef ACE_Future_Rep<T> - FUTURE_REP; + typedef ACE_Future_Rep<T> FUTURE_REP; - typedef ACE_Future_Holder<T> - FUTURE_HOLDER; + typedef ACE_Future_Holder<T> FUTURE_HOLDER; - typedef ACE_Map_Manager<FUTURE_REP*, FUTURE_HOLDER *, ACE_Null_Mutex> - FUTURE_MAP; + typedef ACE_Pointer_Hash<FUTURE_REP *> FUTURE_REP_HASH; - typedef ACE_Map_Iterator<FUTURE_REP*, FUTURE_HOLDER *, ACE_Null_Mutex> - FUTURE_ITERATOR; + typedef ACE_Equal_To<FUTURE_REP *> FUTURE_REP_COMPARE; - typedef ACE_Map_Entry<FUTURE_REP*, FUTURE_HOLDER *> - FUTURE_ENTRY; + typedef ACE_Hash_Map_Manager_Ex<FUTURE_REP *, + FUTURE_HOLDER *, + FUTURE_REP_HASH, + FUTURE_REP_COMPARE, + ACE_Null_Mutex> FUTURE_HASH_MAP; - FUTURE_MAP future_map_; + FUTURE_HASH_MAP future_map_; // Map of ACE_Futures, subjects, which have not been written to by // client's writer thread. |