diff options
Diffstat (limited to 'ace')
87 files changed, 1694 insertions, 4518 deletions
diff --git a/ace/ACE.cpp b/ace/ACE.cpp index b5f7d325e98..5b96172d8e6 100644 --- a/ace/ACE.cpp +++ b/ace/ACE.cpp @@ -1222,14 +1222,16 @@ ACE::leave_recv_timedwait (ACE_HANDLE handle, int val) { if (timeout != 0 - && ACE_BIT_DISABLED (val, - ACE_NONBLOCK)) + && ACE_BIT_DISABLED (val, ACE_NONBLOCK)) { - // Save/restore errno. - ACE_Errno_Guard error (errno); + // We need to stash errno here because ACE::clr_flags() may + // reset it. + int error = errno; + // Only disable ACE_NONBLOCK if we weren't in non-blocking mode // originally. ACE::clr_flags (handle, ACE_NONBLOCK); + errno = error; } } @@ -1302,11 +1304,14 @@ ACE::leave_send_timedwait (ACE_HANDLE handle, if (timeout != 0 && ACE_BIT_DISABLED (val, ACE_NONBLOCK)) { - // Save/restore errno. - ACE_Errno_Guard error (errno); + // We need to stash errno here because ACE::clr_flags() may + // reset it. + int error = errno; + // Only disable ACE_NONBLOCK if we weren't in non-blocking mode // originally. ACE::clr_flags (handle, ACE_NONBLOCK); + errno = error; } } diff --git a/ace/ATM_Addr.cpp b/ace/ATM_Addr.cpp index dbd94db1acb..dcf40446f37 100644 --- a/ace/ATM_Addr.cpp +++ b/ace/ATM_Addr.cpp @@ -48,12 +48,6 @@ ACE_ATM_Addr::ACE_ATM_Addr (unsigned char selector) ACE_ATM_Addr::ACE_ATM_Addr (const ACE_ATM_Addr &sap, unsigned char selector) -#if defined (ACE_HAS_FORE_ATM_XTI) - : ACE_Addr (AF_ATM, -#else - : ACE_Addr (AF_UNSPEC, -#endif /* ACE_HAS_FORE_ATM_XTI */ - sizeof this->atm_addr_) { ACE_TRACE ("ACE_ATM_Addr::ACE_ATM_Addr"); this->set (sap, selector); @@ -61,12 +55,6 @@ ACE_ATM_Addr::ACE_ATM_Addr (const ACE_ATM_Addr &sap, ACE_ATM_Addr::ACE_ATM_Addr (const ATMSAPAddress *sap, unsigned char selector) -#if defined (ACE_HAS_FORE_ATM_XTI) - : ACE_Addr (AF_ATM, -#else - : ACE_Addr (AF_UNSPEC, -#endif /* ACE_HAS_FORE_ATM_XTI */ - sizeof this->atm_addr_) { ACE_TRACE ("ACE_ATM_Addr::ACE_ATM_Addr"); this->set (sap, selector); @@ -74,12 +62,6 @@ ACE_ATM_Addr::ACE_ATM_Addr (const ATMSAPAddress *sap, ACE_ATM_Addr::ACE_ATM_Addr (const ASYS_TCHAR sap[], unsigned char selector) -#if defined (ACE_HAS_FORE_ATM_XTI) - : ACE_Addr (AF_ATM, -#else - : ACE_Addr (AF_UNSPEC, -#endif /* ACE_HAS_FORE_ATM_XTI */ - sizeof this->atm_addr_) { ACE_TRACE ("ACE_ATM_Addr::ACE_ATM_Addr"); this->set (sap, selector); diff --git a/ace/CDR_Stream.cpp b/ace/CDR_Stream.cpp index aa026c9b1bc..990ccd91323 100644 --- a/ace/CDR_Stream.cpp +++ b/ace/CDR_Stream.cpp @@ -580,12 +580,32 @@ ACE_InputCDR::ACE_InputCDR (size_t bufsiz, ACE_InputCDR::ACE_InputCDR (const ACE_Message_Block *data, int byte_order) - : start_ (), + : start_ (ACE_CDR::total_length (data, 0) + ACE_CDR::MAX_ALIGNMENT), + // @@ We may need allocators for the previous line, and the size may + // be a standard ACE_*CDR size... + do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER), good_bit_ (1), char_translator_ (0), wchar_translator_ (0) { - this->reset (data, byte_order); + // We must copy the contents of <data> into the new buffer, but + // respecting the alignment. + ptr_arith_t curalign = + ptr_arith_t(data->rd_ptr ()) % ACE_CDR::MAX_ALIGNMENT; + ptr_arith_t tmpalign = + ptr_arith_t(this->start_.rd_ptr ()) % ACE_CDR::MAX_ALIGNMENT; + int offset = curalign - tmpalign; + if (offset < 0) + offset += ACE_CDR::MAX_ALIGNMENT; + this->start_.rd_ptr (offset); + this->start_.wr_ptr (offset); + + for (const ACE_Message_Block* i = data; + i != 0; + i = i->cont ()) + { + this->start_.copy (i->rd_ptr (), i->length ()); + } } ACE_InputCDR::ACE_InputCDR (ACE_Data_Block *data, @@ -973,6 +993,8 @@ ACE_InputCDR::skip_bytes (size_t len) return 0; } + + int ACE_InputCDR::grow (size_t newsize) { @@ -983,42 +1005,3 @@ ACE_InputCDR::grow (size_t newsize) this->start_.wr_ptr (newsize); return 0; } - -void -ACE_InputCDR::reset (const ACE_Message_Block* data, - int byte_order) -{ - this->reset_byte_order (byte_order); - this->start_.size (ACE_CDR::total_length (data, 0) - + ACE_CDR::MAX_ALIGNMENT); - - // We must copy the contents of <data> into the new buffer, but - // respecting the alignment. - ptr_arith_t curalign = - ptr_arith_t(data->rd_ptr ()) % ACE_CDR::MAX_ALIGNMENT; - ptr_arith_t tmpalign = - ptr_arith_t(this->start_.rd_ptr ()) % ACE_CDR::MAX_ALIGNMENT; - int offset = curalign - tmpalign; - if (offset < 0) - offset += ACE_CDR::MAX_ALIGNMENT; - this->start_.rd_ptr (offset); - this->start_.wr_ptr (offset); - - for (const ACE_Message_Block* i = data; - i != 0; - i = i->cont ()) - { - this->start_.copy (i->rd_ptr (), i->length ()); - } -} - -ACE_Message_Block* -ACE_InputCDR::steal_contents (void) -{ - ACE_Message_Block* block = - this->start_.clone (); - this->start_.data_block (block->data_block ()->clone ()); - ACE_CDR::mb_align (&this->start_); - - return block; -} diff --git a/ace/CDR_Stream.h b/ace/CDR_Stream.h index cff1f7f38da..aea71014629 100644 --- a/ace/CDR_Stream.h +++ b/ace/CDR_Stream.h @@ -704,7 +704,7 @@ public: // CDR stream from a socket or file. int grow (size_t newsize); - // Grow the internal buffer, reset rd_ptr() to the first byte in the + // Grow the internal buffer, reset rd_ptr() to the first byte in the // new buffer that is properly aligned, and set wr_ptr() to // rd_ptr() + newsize @@ -713,15 +713,6 @@ public: // detect a change in the byte order, this method will let him // change it. - void reset (const ACE_Message_Block *data, - int byte_order); - // Re-initialize the CDR stream, copying the contents of the chain - // of message_blocks starting from <data>. - - ACE_Message_Block * steal_contents (void); - // Re-initialize the CDR stream, copying the contents of the chain - // of message_blocks starting from <data>. - char* rd_ptr (void); // Returns the current position for the rd_ptr.... diff --git a/ace/CORBA_macros.h b/ace/CORBA_macros.h index b6c13abbf2b..c540e5af1f6 100644 --- a/ace/CORBA_macros.h +++ b/ace/CORBA_macros.h @@ -385,7 +385,7 @@ // Print out a TAO exception. This is not CORBA compliant. # define ACE_PRINT_TAO_EXCEPTION(EX,INFO) \ - EX._tao_print_exception (INFO) + EX.print_exception (INFO) // Print out a CORBA exception. There is not portable way to // dump a CORBA exception. If you are using other ORB implementation, diff --git a/ace/Cache_Map_Manager_T.cpp b/ace/Cache_Map_Manager_T.cpp index 0a7cc36ec46..b4b871b47f8 100644 --- a/ace/Cache_Map_Manager_T.cpp +++ b/ace/Cache_Map_Manager_T.cpp @@ -20,19 +20,16 @@ ACE_RCSID(ace, Cache_Map_Manager_T, "$Id$") ACE_ALLOC_HOOK_DEFINE(ACE_Cache_Map_Manager) - + ACE_ALLOC_HOOK_DEFINE(ACE_Cache_Map_Iterator) ACE_ALLOC_HOOK_DEFINE(ACE_Cache_Map_Reverse_Iterator) -#define T_1 class KEY, class VALUE, class MAP, class ITERATOR_IMPL, class REVERSE_ITERATOR_IMPL, class CACHING_STRATEGY, class ATTRIBUTES -#define T_2 KEY, VALUE, MAP, ITERATOR_IMPL, REVERSE_ITERATOR_IMPL, CACHING_STRATEGY, ATTRIBUTES - -template <T_1> -ACE_Cache_Map_Manager<T_2>::ACE_Cache_Map_Manager (size_t size, - ACE_Allocator *alloc, - CACHING_STRATEGY *caching_s, - int delete_caching_strategy) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class MAP, class CACHING_STRATEGY, class ATTRIBUTES> +ACE_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, MAP, CACHING_STRATEGY, ATTRIBUTES>::ACE_Cache_Map_Manager (size_t size, + ACE_Allocator *alloc, + CACHING_STRATEGY *caching_s, + int delete_caching_strategy) : caching_strategy_ (0) { if (this->open (size, alloc, caching_s, delete_caching_strategy) == -1) @@ -42,16 +39,16 @@ ACE_Cache_Map_Manager<T_2>::ACE_Cache_Map_Manager (size_t size, } -template <T_1> -ACE_Cache_Map_Manager<T_2>::~ACE_Cache_Map_Manager (void) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class MAP, class CACHING_STRATEGY, class ATTRIBUTES> +ACE_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, MAP, CACHING_STRATEGY, ATTRIBUTES>::~ACE_Cache_Map_Manager (void) { } -template <T_1> int -ACE_Cache_Map_Manager<T_2>::open (size_t length, - ACE_Allocator *alloc, - CACHING_STRATEGY *caching_s, - int delete_caching_strategy) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class MAP, class CACHING_STRATEGY, class ATTRIBUTES> int +ACE_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, MAP, CACHING_STRATEGY, ATTRIBUTES>::open (size_t length, + ACE_Allocator *alloc, + CACHING_STRATEGY *caching_s, + int delete_caching_strategy) { // Create the map. if (this->map_.open (length, @@ -90,8 +87,8 @@ ACE_Cache_Map_Manager<T_2>::open (size_t length, return 0; } -template <T_1> int -ACE_Cache_Map_Manager<T_2>::close (void) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class MAP, class CACHING_STRATEGY, class ATTRIBUTES> int +ACE_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, MAP, CACHING_STRATEGY, ATTRIBUTES>::close (void) { if (this->delete_caching_strategy_ == 1) delete this->caching_strategy_; @@ -103,9 +100,9 @@ ACE_Cache_Map_Manager<T_2>::close (void) return this->map_.close (); } -template <T_1> int -ACE_Cache_Map_Manager<T_2>::bind (const KEY &key, - const VALUE &value) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class MAP, class CACHING_STRATEGY, class ATTRIBUTES> int +ACE_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, MAP, CACHING_STRATEGY, ATTRIBUTES>::bind (const KEY &key, + const VALUE &value) { // Insert an entry which has the <key> and the <cache_value> which // is the combination of the <value> and the attributes of the @@ -139,9 +136,9 @@ ACE_Cache_Map_Manager<T_2>::bind (const KEY &key, } -template <T_1> int -ACE_Cache_Map_Manager<T_2>::rebind (const KEY &key, - const VALUE &value) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class MAP, class CACHING_STRATEGY, class ATTRIBUTES> int +ACE_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, MAP, CACHING_STRATEGY, ATTRIBUTES>::rebind (const KEY &key, + const VALUE &value) { CACHE_VALUE cache_value (value, this->caching_strategy_->attributes ()); @@ -176,10 +173,10 @@ ACE_Cache_Map_Manager<T_2>::rebind (const KEY &key, } -template <T_1> int -ACE_Cache_Map_Manager<T_2>::rebind (const KEY &key, - const VALUE &value, - VALUE &old_value) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class MAP, class CACHING_STRATEGY, class ATTRIBUTES> int +ACE_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, MAP, CACHING_STRATEGY, ATTRIBUTES>::rebind (const KEY &key, + const VALUE &value, + VALUE &old_value) { CACHE_VALUE cache_value (value, this->caching_strategy_->attributes ()); @@ -223,11 +220,11 @@ ACE_Cache_Map_Manager<T_2>::rebind (const KEY &key, return rebind_result; } -template <T_1> int -ACE_Cache_Map_Manager<T_2>::rebind (const KEY &key, - const VALUE &value, - KEY &old_key, - VALUE &old_value) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class MAP, class CACHING_STRATEGY, class ATTRIBUTES> int +ACE_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, MAP, CACHING_STRATEGY, ATTRIBUTES>::rebind (const KEY &key, + const VALUE &value, + KEY &old_key, + VALUE &old_value) { CACHE_VALUE cache_value (value, this->caching_strategy_->attributes ()); @@ -272,9 +269,9 @@ ACE_Cache_Map_Manager<T_2>::rebind (const KEY &key, return rebind_result; } -template <T_1> int -ACE_Cache_Map_Manager<T_2>::trybind (const KEY &key, - VALUE &value) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class MAP, class CACHING_STRATEGY, class ATTRIBUTES> int +ACE_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, MAP, CACHING_STRATEGY, ATTRIBUTES>::trybind (const KEY &key, + VALUE &value) { CACHE_VALUE cache_value (value, this->caching_strategy_->attributes ()); @@ -314,9 +311,9 @@ ACE_Cache_Map_Manager<T_2>::trybind (const KEY &key, return trybind_result; } -template <T_1> int -ACE_Cache_Map_Manager<T_2>::find (const KEY &key, - VALUE &value) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class MAP, class CACHING_STRATEGY, class ATTRIBUTES> int +ACE_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, MAP, CACHING_STRATEGY, ATTRIBUTES>::find (const KEY &key, + VALUE &value) { // Lookup the key and populate the <value>. CACHE_VALUE cache_value; @@ -353,8 +350,8 @@ ACE_Cache_Map_Manager<T_2>::find (const KEY &key, return find_result; } -template <T_1> int -ACE_Cache_Map_Manager<T_2>::find (const KEY &key) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class MAP, class CACHING_STRATEGY, class ATTRIBUTES> int +ACE_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, MAP, CACHING_STRATEGY, ATTRIBUTES>::find (const KEY &key) { // Lookup the key and populate the <value>. CACHE_VALUE cache_value; @@ -391,8 +388,8 @@ ACE_Cache_Map_Manager<T_2>::find (const KEY &key) } -template <T_1> int -ACE_Cache_Map_Manager<T_2>::unbind (const KEY &key) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class MAP, class CACHING_STRATEGY, class ATTRIBUTES> int +ACE_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, MAP, CACHING_STRATEGY, ATTRIBUTES>::unbind (const KEY &key) { // Remove the entry from the cache. CACHE_VALUE cache_value; @@ -414,9 +411,9 @@ ACE_Cache_Map_Manager<T_2>::unbind (const KEY &key) return unbind_result; } -template <T_1> int -ACE_Cache_Map_Manager<T_2>::unbind (const KEY &key, - VALUE &value) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class MAP, class CACHING_STRATEGY, class ATTRIBUTES> int +ACE_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, MAP, CACHING_STRATEGY, ATTRIBUTES>::unbind (const KEY &key, + VALUE &value) { // Remove the entry from the cache. CACHE_VALUE cache_value; @@ -441,15 +438,12 @@ ACE_Cache_Map_Manager<T_2>::unbind (const KEY &key, } -template <T_1> void -ACE_Cache_Map_Manager<T_2>::dump (void) const +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class MAP, class CACHING_STRATEGY, class ATTRIBUTES> void +ACE_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, MAP, CACHING_STRATEGY, ATTRIBUTES>::dump (void) const { this->map_.dump (); this->caching_strategy_->dump (); } -#undef T_1 -#undef T_2 - #endif /* ACE_CACHE_MAP_MANAGER_T_C */ diff --git a/ace/Cache_Map_Manager_T.h b/ace/Cache_Map_Manager_T.h index 2afdf7d326c..c83e61cf031 100644 --- a/ace/Cache_Map_Manager_T.h +++ b/ace/Cache_Map_Manager_T.h @@ -28,60 +28,54 @@ // Forward declaration. class ACE_Allocator; -template <class KEY, class VALUE, class IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES> +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES> class ACE_Cache_Map_Iterator; -template <class KEY, class VALUE, class REVERSE_IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES> +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class REVERSE_IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES> class ACE_Cache_Map_Reverse_Iterator; -template <class KEY, class VALUE, class MAP, class ITERATOR_IMPL, class REVERSE_ITERATOR_IMPL, class CACHING_STRATEGY, class ATTRIBUTES> +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class MAP, class CACHING_STRATEGY, class ATTRIBUTES> class ACE_Cache_Map_Manager { // = TITLE - // Defines a abstraction that will purge entries from a map. - // + // Defines a abstraction which will purge entries from a map. + // // = DESCRIPTION - // The <ACE_Cache_Map_Manager> will manage the map it contains + // The Cache_Map_Manager will manage the map it contains // and provide purging on demand from the map. The strategy for // caching is decided by the user and provided to the Cache // Manager. The Cache Manager acts as a agent and communicates // between the Map and the Strategy for purging entries from the - // map. + // map. // // No locking mechanism provided since locking at this level - // isn't efficient. Locking has to be provided by the + // isnt efficient. Locking has to be provided by the // application. public: // = Traits. typedef KEY key_type; typedef VALUE mapped_type; - typedef MAP map_type; - typedef CACHING_STRATEGY caching_strategy_type; - typedef ITERATOR_IMPL ITERATOR_IMPLEMENTATION; - typedef REVERSE_ITERATOR_IMPL REVERSE_ITERATOR_IMPLEMENTATION; + typedef ACE_TYPENAME MAP::ITERATOR IMPLEMENTATION; + typedef ACE_TYPENAME MAP::REVERSE_ITERATOR REVERSE_IMPLEMENTATION; typedef ACE_Pair<VALUE, ATTRIBUTES> CACHE_VALUE; // The actual value mapped to the key in the map. The <attributes> // are used by the strategy and is transparent to the user of this // class. - friend class ACE_Cache_Map_Iterator<KEY, VALUE, ITERATOR_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES>; - friend class ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, REVERSE_ITERATOR_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES>; + friend class ACE_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES>; + friend class ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES>; // = ACE-style iterator typedefs. - typedef ACE_Cache_Map_Iterator<KEY, VALUE, ITERATOR_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> - ITERATOR; - typedef ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, REVERSE_ITERATOR_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> - REVERSE_ITERATOR; + typedef ACE_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> ITERATOR; + typedef ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> REVERSE_ITERATOR; // = STL-style iterator typedefs. - typedef ITERATOR - iterator; - typedef REVERSE_ITERATOR - reverse_iterator; + typedef ITERATOR iterator; + typedef REVERSE_ITERATOR reverse_iterator; // = Initialization and termination methods. - + ACE_Cache_Map_Manager (size_t size = ACE_DEFAULT_MAP_SIZE, ACE_Allocator *alloc = 0, CACHING_STRATEGY *caching_s = 0, @@ -101,16 +95,16 @@ public: CACHING_STRATEGY *caching_s = 0, int delete_caching_strategy = 1); // Initialise a cache with size <length> and set the caching_strategy. - + int close (void); // Close down a cache and release dynamically allocated resources. int bind (const KEY &key, const VALUE &value); - // Associate <key> with <value>. If <key> is already in the MAP - // then the ENTRY is not changed. Returns 0 if a new entry is bound - // successfully, returns 1 if an attempt is made to bind an existing - // entry, and returns -1 if failures occur. + // Associate <key> with <value>. If <key> is already in the + // MAP then the ENTRY is not changed. Returns 0 if a new entry is + // bound successfully, returns 1 if an attempt is made to bind an + // existing entry, and returns -1 if failures occur. int find (const KEY &key, VALUE &value); @@ -140,19 +134,19 @@ public: VALUE &old_value); // Reassociate <key> with <value>, storing the old key and value // into the "out" parameters <old_key> and <old_value>. The - // function fails if <key> is not in the cache for caches that do - // not allow user specified keys. However, for caches that allow - // user specified keys, if the key is not in the cache, a new - // <key>/<value> association is created. + // function fails if <key> is not in the cache for caches that do not + // allow user specified keys. However, for caches that allow user + // specified keys, if the key is not in the cache, a new <key>/<value> + // association is created. int trybind (const KEY &key, VALUE &value); // Associate <key> with <value> if and only if <key> is not in the - // cache. If <key> is already in the cache, then the <value> - // parameter is overwritten with the existing value in the - // cache. Returns 0 if a new <key>/<value> association is created. - // Returns 1 if an attempt is made to bind an existing entry. This - // function fails for maps that do not allow user specified keys. + // cache. If <key> is already in the cache, then the <value> parameter + // is overwritten with the existing value in the cache. Returns 0 if a + // new <key>/<value> association is created. Returns 1 if an + // attempt is made to bind an existing entry. This function fails + // for maps that do not allow user specified keys. int unbind (const KEY &key); // Remove <key> from the cache. @@ -162,7 +156,7 @@ public: // Remove <key> from the cache, and return the <value> associated with // <key>. - int purge (void); + int purge (MAP &map); // Remove entries from the cache depending upon the strategy. size_t current_size (void); @@ -203,7 +197,8 @@ protected: // class or not. Is yes, then it deletes the strategy. }; -template <class KEY, class VALUE, class IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES> +//////////////////////////////////////////////////////////////////////////////// +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES> class ACE_Cache_Map_Iterator { // = TITLE @@ -216,29 +211,27 @@ class ACE_Cache_Map_Iterator public: // = Traits. - typedef ACE_Reference_Pair<KEY, VALUE> - value_type; - typedef ACE_Pair <VALUE, ATTRIBUTES> - CACHE_VALUE; + typedef ACE_Reference_Pair<KEY, VALUE> value_type; + typedef ACE_Pair <VALUE, ATTRIBUTES> CACHE_VALUE; // The actual value mapped to the key in the cache. The <attributes> // are used by the strategy and is transperant to the cache user. - + // = Initialisation and termination methods. ACE_Cache_Map_Iterator (const IMPLEMENTATION &iterator_impl); - ACE_Cache_Map_Iterator (const ACE_Cache_Map_Iterator<KEY, VALUE, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &rhs); + ACE_Cache_Map_Iterator (const ACE_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &rhs); // Copy constructor. virtual ~ACE_Cache_Map_Iterator (void); // = Iteration methods. - ACE_Cache_Map_Iterator &operator= (const ACE_Cache_Map_Iterator<KEY, VALUE, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &rhs); + ACE_Cache_Map_Iterator &operator= (const ACE_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &rhs); // assignment operator. - int operator== (const ACE_Cache_Map_Iterator<KEY, VALUE, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &rhs) const; - int operator!= (const ACE_Cache_Map_Iterator<KEY, VALUE, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &rhs) const; + int operator== (const ACE_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &rhs) const; + int operator!= (const ACE_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &rhs) const; // Comparision operators. ACE_Reference_Pair<KEY, VALUE> operator* (void) const; @@ -247,16 +240,16 @@ public: // = STL styled iteration, compare, and reference functions. - ACE_Cache_Map_Iterator<KEY, VALUE, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &operator++ (void); + ACE_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &operator++ (void); // Prefix advance - ACE_Cache_Map_Iterator<KEY, VALUE, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> operator++ (int); + ACE_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> operator++ (int); // Postfix advance. - ACE_Cache_Map_Iterator<KEY, VALUE, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &operator-- (void); + ACE_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &operator-- (void); // Prefix reverse. - ACE_Cache_Map_Iterator<KEY, VALUE, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> operator-- (int); + ACE_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> operator-- (int); // Postfix reverse. IMPLEMENTATION &iterator_implementation (void); @@ -275,7 +268,8 @@ protected: // belonging to the Cache_Map_Manager. }; -template <class KEY, class VALUE, class REVERSE_IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES> +//////////////////////////////////////////////////////////////////////////////// +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class REVERSE_IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES> class ACE_Cache_Map_Reverse_Iterator { // = TITLE @@ -284,6 +278,7 @@ class ACE_Cache_Map_Reverse_Iterator // = DESCRIPTION // Implementation to be provided by the reverse iterator of the map // managed by thr Cache_Map_manager. + public: // = Traits. @@ -296,18 +291,18 @@ public: ACE_Cache_Map_Reverse_Iterator (const REVERSE_IMPLEMENTATION &iterator_impl); - ACE_Cache_Map_Reverse_Iterator (const ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &rhs); + ACE_Cache_Map_Reverse_Iterator (const ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &rhs); // Copy constructor. ~ACE_Cache_Map_Reverse_Iterator (void); // = Iteration methods. - ACE_Cache_Map_Reverse_Iterator &operator= (const ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &rhs); + ACE_Cache_Map_Reverse_Iterator &operator= (const ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &rhs); // Assignment operator. - int operator== (const ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &rhs) const; - int operator!= (const ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &rhs) const; + int operator== (const ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &rhs) const; + int operator!= (const ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &rhs) const; // Comparision operators. ACE_Reference_Pair<KEY, VALUE> operator* (void) const; @@ -316,19 +311,19 @@ public: // = STL styled iteration, compare, and reference functions. - ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &operator++ (void); + ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &operator++ (void); // Prefix advance - ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> operator++ (int); + ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> operator++ (int); // Postfix advance. - ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &operator-- (void); + ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &operator-- (void); // Prefix reverse. - ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> operator-- (int); + ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> operator-- (int); // Postfix reverse. - REVERSE_IMPLEMENTATION &iterator_implementation (void); + REVERSE_IMPLEMENTATION &iterator_implementation (void); // Returns the iterator of the internal map in the custody of the // Cache_Map_Manager. diff --git a/ace/Cache_Map_Manager_T.i b/ace/Cache_Map_Manager_T.i index 421aa8d1c73..92dced59904 100644 --- a/ace/Cache_Map_Manager_T.i +++ b/ace/Cache_Map_Manager_T.i @@ -1,259 +1,239 @@ /* -*- C++ -*- */ //$Id$ -#define T_1 class KEY, class VALUE, class MAP, class ITERATOR_IMPL, class REVERSE_ITERATOR_IMPL, class CACHING_STRATEGY, class ATTRIBUTES -#define T_2 KEY, VALUE, MAP, ITERATOR_IMPL, REVERSE_ITERATOR_IMPL, CACHING_STRATEGY, ATTRIBUTES - -template <T_1> ACE_INLINE int -ACE_Cache_Map_Manager<T_2>::purge (MAP &map) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class MAP, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE int +ACE_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, MAP, CACHING_STRATEGY, ATTRIBUTES>::purge (MAP &map) { return this->caching_strategy ()->clear_cache (map); } -template <T_1> ACE_INLINE size_t -ACE_Cache_Map_Manager<T_2>::current_size (void) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class MAP, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE size_t +ACE_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, MAP, CACHING_STRATEGY, ATTRIBUTES>::current_size (void) { return this->map_.current_size (); } -template <T_1> ACE_INLINE size_t -ACE_Cache_Map_Manager<T_2>::total_size (void) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class MAP, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE size_t +ACE_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, MAP, CACHING_STRATEGY, ATTRIBUTES>::total_size (void) { return this->map_.total_size (); } -template <T_1> ACE_INLINE MAP & -ACE_Cache_Map_Manager<T_2>::map (void) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class MAP, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE MAP & +ACE_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, MAP, CACHING_STRATEGY, ATTRIBUTES>::map (void) { return this->map_; } -template <T_1> ACE_INLINE CACHING_STRATEGY * -ACE_Cache_Map_Manager<T_2>::caching_strategy (void) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class MAP, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE CACHING_STRATEGY * +ACE_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, MAP, CACHING_STRATEGY, ATTRIBUTES>::caching_strategy (void) { return this->caching_strategy_; } -template <T_1> ACE_INLINE ACE_Cache_Map_Iterator<KEY, VALUE, ITERATOR_IMPL, CACHING_STRATEGY, ATTRIBUTES> -ACE_Cache_Map_Manager<T_2>::begin (void) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class MAP, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE ACE_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, MAP, CACHING_STRATEGY, ATTRIBUTES>::ITERATOR +ACE_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, MAP, CACHING_STRATEGY, ATTRIBUTES>::begin (void) { - return ITERATOR (this->map_.begin ()); + return ACE_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, MAP, CACHING_STRATEGY, ATTRIBUTES>::ITERATOR (this->map_.begin ()); } -template <T_1> ACE_INLINE ACE_Cache_Map_Iterator<KEY, VALUE, ITERATOR_IMPL, CACHING_STRATEGY, ATTRIBUTES> -ACE_Cache_Map_Manager<T_2>::end (void) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class MAP, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE ACE_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, MAP, CACHING_STRATEGY, ATTRIBUTES>::ITERATOR +ACE_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, MAP, CACHING_STRATEGY, ATTRIBUTES>::end (void) { - return ITERATOR (this->map_.end ()); + return ACE_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, MAP, CACHING_STRATEGY, ATTRIBUTES>::ITERATOR (this->map_.end ()); } -template <T_1> ACE_INLINE ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, REVERSE_ITERATOR_IMPL, CACHING_STRATEGY, ATTRIBUTES> -ACE_Cache_Map_Manager<T_2>::rbegin (void) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class MAP, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE ACE_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, MAP, CACHING_STRATEGY, ATTRIBUTES>::REVERSE_ITERATOR +ACE_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, MAP, CACHING_STRATEGY, ATTRIBUTES>::rbegin (void) { - return REVERSE_ITERATOR (this->map_.rbegin ()); + return ACE_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, MAP, CACHING_STRATEGY, ATTRIBUTES>::REVERSE_ITERATOR (this->map_.rbegin ()); } -template <T_1> ACE_INLINE ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, REVERSE_ITERATOR_IMPL, CACHING_STRATEGY, ATTRIBUTES> -ACE_Cache_Map_Manager<T_2>::rend (void) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class MAP, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE ACE_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, MAP, CACHING_STRATEGY, ATTRIBUTES>::REVERSE_ITERATOR +ACE_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, MAP, CACHING_STRATEGY, ATTRIBUTES>::rend (void) { - return REVERSE_ITERATOR (this->map_.rend ()); + return ACE_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, MAP, CACHING_STRATEGY, ATTRIBUTES>::REVERSE_ITERATOR (this->map_.rend ()); } -#undef T_1 -#undef T_2 - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#define T_1 class KEY, class VALUE, class IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES -#define T_2 KEY, VALUE, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES - -template <T_1> ACE_INLINE -ACE_Cache_Map_Iterator<T_2>::ACE_Cache_Map_Iterator (const ACE_Cache_Map_Iterator <T_2> &rhs) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE +ACE_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES>::ACE_Cache_Map_Iterator (const ACE_Cache_Map_Iterator <KEY, VALUE, HASH_KEY, COMPARE_KEYS, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &rhs) : iterator_implementation_ (rhs.iterator_implementation_) { } -template <T_1> ACE_INLINE -ACE_Cache_Map_Iterator<T_2>::~ACE_Cache_Map_Iterator (void) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE +ACE_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES>::~ACE_Cache_Map_Iterator (void) { } -template <T_1> ACE_INLINE ACE_Cache_Map_Iterator<T_2> & -ACE_Cache_Map_Iterator<T_2>::operator= (const ACE_Cache_Map_Iterator<T_2> &rhs) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE ACE_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> & +ACE_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES>::operator= (const ACE_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &rhs) { this->iterator_implementation_ = rhs.iterator_implementation_; return *this; } -template <T_1> ACE_INLINE int -ACE_Cache_Map_Iterator<T_2>::operator== (const ACE_Cache_Map_Iterator<T_2> &rhs) const +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE int +ACE_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES>::operator== (const ACE_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &rhs) const { return this->iterator_implementation_ == rhs.iterator_implementation_; } -template <T_1> ACE_INLINE int -ACE_Cache_Map_Iterator<T_2>::operator!= (const ACE_Cache_Map_Iterator<T_2> &rhs) const +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE int +ACE_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES>::operator!= (const ACE_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &rhs) const { return this->iterator_implementation_ != rhs.iterator_implementation_; } -template <T_1> ACE_INLINE ACE_Reference_Pair<KEY, VALUE> -ACE_Cache_Map_Iterator<T_2>::operator* (void) const +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE ACE_Reference_Pair<KEY, VALUE> +ACE_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES>::operator* (void) const { - value_type retn ((*this->iterator_implementation_).ext_id_, - (*this->iterator_implementation_).int_id_.first ()); + value_type retn ((*this->iterator_implementation_).ext_id_, (*this->iterator_implementation_).int_id_.first ()); return retn; } -template <T_1> ACE_INLINE -ACE_Cache_Map_Iterator<T_2> & -ACE_Cache_Map_Iterator<T_2>::operator++ (void) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE +ACE_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> & +ACE_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES>::operator++ (void) { ++this->iterator_implementation_; return *this; } -template <T_1> ACE_INLINE -ACE_Cache_Map_Iterator<T_2> -ACE_Cache_Map_Iterator<T_2>::operator++ (int) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE +ACE_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> +ACE_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES>::operator++ (int) { - ACE_Cache_Map_Iterator<T_2> retn = *this; + ACE_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> retn = *this; ++this->iterator_implementation_; return retn; } -template <T_1> ACE_INLINE -ACE_Cache_Map_Iterator<T_2> & -ACE_Cache_Map_Iterator<T_2>::operator-- (void) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE +ACE_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> & +ACE_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES>::operator-- (void) { --this->iterator_implementation_; return *this; } -template <T_1> ACE_INLINE -ACE_Cache_Map_Iterator<T_2> -ACE_Cache_Map_Iterator<T_2>::operator-- (int) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE +ACE_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> +ACE_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES>::operator-- (int) { - ACE_Cache_Map_Iterator<T_2> retn = *this; + ACE_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> retn = *this; --this->iterator_implementation_; return retn; } -template <T_1> ACE_INLINE void -ACE_Cache_Map_Iterator<T_2>::dump (void) const +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE void +ACE_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES>::dump (void) const { - this->iterator_implementation_.dump (); + return this->iterator_implementation_.dump (); } -template <T_1> ACE_INLINE -ACE_Cache_Map_Iterator<T_2>::ACE_Cache_Map_Iterator (const IMPLEMENTATION &iterator_impl) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE +ACE_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES>::ACE_Cache_Map_Iterator (const IMPLEMENTATION &iterator_impl) : iterator_implementation_ (iterator_impl) { } -template <T_1> ACE_INLINE IMPLEMENTATION & -ACE_Cache_Map_Iterator<T_2>::iterator_implementation (void) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE IMPLEMENTATION & +ACE_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES>::iterator_implementation (void) { return this->iterator_implementation_; } -#undef T_1 -#undef T_2 - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#define T_1 class KEY, class VALUE, class REVERSE_IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES -#define T_2 KEY, VALUE, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES - -template <T_1> ACE_INLINE -ACE_Cache_Map_Reverse_Iterator<T_2>::ACE_Cache_Map_Reverse_Iterator (const ACE_Cache_Map_Reverse_Iterator <T_2> &rhs) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class REVERSE_IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE +ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES>::ACE_Cache_Map_Reverse_Iterator (const ACE_Cache_Map_Reverse_Iterator <KEY, VALUE, HASH_KEY, COMPARE_KEYS, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &rhs) : reverse_iterator_implementation_ (rhs.reverse_iterator_implementation_) { } -template <T_1> ACE_INLINE -ACE_Cache_Map_Reverse_Iterator<T_2>::~ACE_Cache_Map_Reverse_Iterator (void) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class REVERSE_IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE +ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES>::~ACE_Cache_Map_Reverse_Iterator (void) { } -template <T_1> ACE_INLINE ACE_Cache_Map_Reverse_Iterator<T_2> & -ACE_Cache_Map_Reverse_Iterator<T_2>::operator= (const ACE_Cache_Map_Reverse_Iterator<T_2> &rhs) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class REVERSE_IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> & +ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES>::operator= (const ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &rhs) { this->reverse_iterator_implementation_ = rhs.reverse_iterator_implementation_; return *this; } -template <T_1> ACE_INLINE int -ACE_Cache_Map_Reverse_Iterator<T_2>::operator== (const ACE_Cache_Map_Reverse_Iterator<T_2> &rhs) const +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class REVERSE_IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE int +ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES>::operator== (const ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &rhs) const { return this->reverse_iterator_implementation_ == rhs.reverse_iterator_implementation_; } -template <T_1> ACE_INLINE int -ACE_Cache_Map_Reverse_Iterator<T_2>::operator!= (const ACE_Cache_Map_Reverse_Iterator<T_2> &rhs) const +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class REVERSE_IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE int +ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES>::operator!= (const ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &rhs) const { return this->reverse_iterator_implementation_ != rhs.reverse_iterator_implementation_; } -template <T_1> ACE_INLINE ACE_Reference_Pair<KEY, VALUE> -ACE_Cache_Map_Reverse_Iterator<T_2>::operator* (void) const +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class REVERSE_IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE ACE_Reference_Pair<KEY, VALUE> +ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES>::operator* (void) const { - value_type retv ((*this->reverse_iterator_implementation_).ext_id_, - (*this->reverse_iterator_implementation_).int_id_.first ()); + value_type retv ((*this->reverse_iterator_implementation_).ext_id_, (*this->reverse_iterator_implementation_).int_id_.first ()); return retv; } -template <T_1> ACE_INLINE -ACE_Cache_Map_Reverse_Iterator<T_2> & -ACE_Cache_Map_Reverse_Iterator<T_2>::operator++ (void) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class REVERSE_IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE +ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> & +ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES>::operator++ (void) { ++this->reverse_iterator_implementation_; return *this; } -template <T_1> ACE_INLINE -ACE_Cache_Map_Reverse_Iterator<T_2> -ACE_Cache_Map_Reverse_Iterator<T_2>::operator++ (int) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class REVERSE_IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE +ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> +ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES>::operator++ (int) { - ACE_Cache_Map_Reverse_Iterator<T_2> retn = *this; + ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> retn = *this; ++this->reverse_iterator_implementation_; return retn; } -template <T_1> ACE_INLINE -ACE_Cache_Map_Reverse_Iterator<T_2> & -ACE_Cache_Map_Reverse_Iterator<T_2>::operator-- (void) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class REVERSE_IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE +ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> & +ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES>::operator-- (void) { --this->reverse_iterator_implementation_; return *this; } -template <T_1> ACE_INLINE -ACE_Cache_Map_Reverse_Iterator<T_2> -ACE_Cache_Map_Reverse_Iterator<T_2>::operator-- (int) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class REVERSE_IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE +ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> +ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES>::operator-- (int) { - ACE_Cache_Map_Reverse_Iterator<T_2> retn = *this; + ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> retn = *this; --this->reverse_iterator_implementation_; return retn; } -template <T_1> ACE_INLINE void -ACE_Cache_Map_Reverse_Iterator<T_2>::dump (void) const +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class REVERSE_IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE void +ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES>::dump (void) const { - this->reverse_iterator_implementation_.dump (); + return this->reverse_iterator_implementation_.dump (); } -template <T_1> ACE_INLINE -ACE_Cache_Map_Reverse_Iterator<T_2>::ACE_Cache_Map_Reverse_Iterator (const REVERSE_IMPLEMENTATION &iterator_impl) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class REVERSE_IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE +ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES>::ACE_Cache_Map_Reverse_Iterator (const REVERSE_IMPLEMENTATION &iterator_impl) : reverse_iterator_implementation_(iterator_impl) { } -template <T_1> ACE_INLINE REVERSE_IMPLEMENTATION & -ACE_Cache_Map_Reverse_Iterator<T_2>::iterator_implementation (void) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class REVERSE_IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE REVERSE_IMPLEMENTATION & +ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES>::iterator_implementation (void) { return this->reverse_iterator_implementation_; } - -#undef T_1 -#undef T_2 diff --git a/ace/Cached_Connect_Strategy_T.h b/ace/Cached_Connect_Strategy_T.h index db42f9258b2..4a6263faed7 100644 --- a/ace/Cached_Connect_Strategy_T.h +++ b/ace/Cached_Connect_Strategy_T.h @@ -79,7 +79,7 @@ public: // = Typedefs for managing the map typedef ACE_Refcounted_Hash_Recyclable<ACE_PEER_CONNECTOR_ADDR> REFCOUNTED_HASH_RECYCLABLE_ADDRESS; - typedef ACE_TYPENAME CACHING_STRATEGY::CACHING_ATTRIBUTES ATTRIBUTES; + typedef ACE_TYPENAME CACHING_STRATEGY::ATTRIBUTES ATTRIBUTES; typedef ACE_Hash_Cache_Map_Manager<REFCOUNTED_HASH_RECYCLABLE_ADDRESS, SVC_HANDLER *, ACE_Hash<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>,ACE_Equal_To<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>, CACHING_STRATEGY, ATTRIBUTES> CONNECTION_CACHE; typedef ACE_TYPENAME CONNECTION_CACHE::CACHE_ENTRY @@ -92,7 +92,7 @@ public: CONNECTION_CACHE_ITERATOR; // = Cleanup of the svc_handler. - typedef ACE_Svc_Cleanup_Strategy<REFCOUNTED_HASH_RECYCLABLE_ADDRESS, ACE_Pair<SVC_HANDLER *, ATTRIBUTES>,ACE_Hash_Map_Manager_Ex<REFCOUNTED_HASH_RECYCLABLE_ADDRESS, ACE_Pair<SVC_HANDLER *, ATTRIBUTES>, ACE_Hash<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>, ACE_Equal_To<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>, MUTEX> > + typedef ACE_Svc_Cleanup_Strategy<ACE_Hash_Map_Manager_Ex<REFCOUNTED_HASH_RECYCLABLE_ADDRESS, ACE_Pair<SVC_HANDLER *, ATTRIBUTES>, ACE_Hash<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>, ACE_Equal_To<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>, MUTEX> > SVC_CLEANUP_STRATEGY; protected: @@ -110,7 +110,6 @@ protected: // Cleanup hint. // = Helpers - int check_hint_i (SVC_HANDLER *&sh, const ACE_PEER_CONNECTOR_ADDR &remote_addr, ACE_Time_Value *timeout, @@ -121,7 +120,15 @@ protected: ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::CONNECTION_CACHE_ENTRY *&entry, int &found); - + int connect_svc_handler_i (SVC_HANDLER *&sh, + const ACE_PEER_CONNECTOR_ADDR &remote_addr, + ACE_Time_Value *timeout, + const ACE_PEER_CONNECTOR_ADDR &local_addr, + int reuse_addr, + int flags, + int perms, + int &found); + int find_or_create_svc_handler_i (SVC_HANDLER *&sh, const ACE_PEER_CONNECTOR_ADDR &remote_addr, ACE_Time_Value *timeout, @@ -132,15 +139,6 @@ protected: ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::CONNECTION_CACHE_ENTRY *&entry, int &found); - int connect_svc_handler_i (SVC_HANDLER *&sh, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - ACE_Time_Value *timeout, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms, - int &found); - CONNECTION_CACHE connection_cache_; // Table that maintains the cache of connected <SVC_HANDLER>s. diff --git a/ace/Caching_Strategies_T.cpp b/ace/Caching_Strategies_T.cpp index 72d5e1ab953..ad5821b81d0 100644 --- a/ace/Caching_Strategies_T.cpp +++ b/ace/Caching_Strategies_T.cpp @@ -15,44 +15,30 @@ ACE_RCSID(ace, Caching_Strategies_T, "$Id$") -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> -ACE_LRU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::ACE_LRU_Caching_Strategy (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s, - int delete_cleanup_strategy, - CACHING_STRATEGY_UTILITY *utility_s, - int delete_caching_strategy_utility) +template<class CONTAINER> +ACE_LRU_Caching_Strategy<CONTAINER>::ACE_LRU_Caching_Strategy (ACE_Cleanup_Strategy<CONTAINER> *cleanup_s, + int delete_cleanup_strategy) : timer_ (0), purge_percent_ (10), entries_ (0), cleanup_strategy_ (0), - delete_cleanup_strategy_ (1), - caching_strategy_utility_ (0), - delete_caching_strategy_utility_ (1) + delete_cleanup_strategy_ (1) { - if (this->open (cleanup_s, - delete_cleanup_strategy, - utility_s, - delete_caching_strategy_utility) == -1) + if (this->open (cleanup_s, delete_cleanup_strategy) == -1) ACE_ERROR ((LM_ERROR, ASYS_TEXT ("%p\n"), ASYS_TEXT ("ACE_LRU_Caching_Strategy::ACE_LRU_Caching_Strategy"))); - + } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> -ACE_LRU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::~ACE_LRU_Caching_Strategy (void) +template<class CONTAINER> +ACE_LRU_Caching_Strategy<CONTAINER>::~ACE_LRU_Caching_Strategy (void) { - if (this->delete_cleanup_strategy_ == 1) - delete this->cleanup_strategy_; - - if (this->delete_caching_strategy_utility_ == 1) - delete this->caching_strategy_utility_; } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> int -ACE_LRU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::open (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s, - int delete_cleanup_strategy, - CACHING_STRATEGY_UTILITY *utility_s, - int delete_caching_strategy_utility) +template<class CONTAINER> int +ACE_LRU_Caching_Strategy<CONTAINER>::open (ACE_Cleanup_Strategy<CONTAINER> *cleanup_s, + int delete_cleanup_strategy) { // Initialise the cleanup strategy. @@ -60,103 +46,67 @@ ACE_LRU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTI if (this->cleanup_strategy_ != 0 && this->delete_cleanup_strategy_ == 1 && cleanup_s != 0) + { + delete this->cleanup_strategy_; + this->cleanup_strategy_ = 0; + this->delete_cleanup_strategy_ = delete_cleanup_strategy; + } if (cleanup_s != 0) this->cleanup_strategy_ = cleanup_s; else if (this->cleanup_strategy_ == 0) { + ACE_NEW_RETURN (this->cleanup_strategy_, CLEANUP_STRATEGY, -1); this->delete_cleanup_strategy_ = delete_cleanup_strategy; - } - // Initialise the caching strategy utility. - - // First we decide whether we need to clean up. - if (this->caching_strategy_utility_ != 0 && - this->delete_caching_strategy_utility_ == 1 && - utility_s != 0) - { - delete this->caching_strategy_utility_; - this->caching_strategy_utility_ = 0; - this->delete_caching_strategy_utility_ = delete_caching_strategy_utility; } - - if (utility_s != 0) - this->caching_strategy_utility_ = utility_s; - else if (this->caching_strategy_utility_ == 0) - { - ACE_NEW_RETURN (this->caching_strategy_utility_, - CACHING_STRATEGY_UTILITY, - -1); - - this->delete_caching_strategy_utility_ = delete_caching_strategy_utility; - } - - return 0; + + return 0; } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> int -ACE_LRU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::clear_cache (CONTAINER &container) +template<class CONTAINER> int +ACE_LRU_Caching_Strategy<CONTAINER>::clear_cache (CONTAINER &container) { - return this->caching_strategy_utility_->clear_cache (container, - this->cleanup_strategy_, - this->purge_percent_, - this->entries_); -} - -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> int -ACE_LRU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::clear_cache (CONTAINER &container, - unsigned int &total_container_entries) -{ - - return this->caching_strategy_utility_->clear_cache (container, - this->cleanup_strategy_, - this->purge_percent_, - total_container_entries); + return this->caching_strategy_utility_.clear_cache (container, + this->cleanup_strategy_, + this->purge_percent_, + this->entries_); } - + //////////////////////////////////////////////////////////////////////////////////////////////// -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> -ACE_LFU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::ACE_LFU_Caching_Strategy (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s, - int delete_cleanup_strategy, - CACHING_STRATEGY_UTILITY *utility_s, - int delete_caching_strategy_utility) +template<class CONTAINER> +ACE_LFU_Caching_Strategy<CONTAINER>::ACE_LFU_Caching_Strategy (ACE_Cleanup_Strategy<CONTAINER> *cleanup_s, + int delete_cleanup_strategy) : purge_percent_ (10), entries_ (0), cleanup_strategy_ (0), - delete_cleanup_strategy_ (1), - caching_strategy_utility_ (0), - delete_caching_strategy_utility_ (1) + delete_cleanup_strategy_ (1) { - if (this->open (cleanup_s, - delete_cleanup_strategy, - utility_s, - delete_caching_strategy_utility) == -1) + if (this->open (cleanup_s, delete_cleanup_strategy) == -1) ACE_ERROR ((LM_ERROR, ASYS_TEXT ("%p\n"), ASYS_TEXT ("ACE_LFU_Caching_Strategy::ACE_LFU_Caching_Strategy"))); - + } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> -ACE_LFU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::~ACE_LFU_Caching_Strategy (void) +template<class CONTAINER> +ACE_LFU_Caching_Strategy<CONTAINER>::~ACE_LFU_Caching_Strategy (void) { } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> int -ACE_LFU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::open (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s, - int delete_cleanup_strategy, - CACHING_STRATEGY_UTILITY *utility_s, - int delete_caching_strategy_utility) +template<class CONTAINER> int +ACE_LFU_Caching_Strategy<CONTAINER>::open (ACE_Cleanup_Strategy<CONTAINER> *cleanup_s, + int delete_cleanup_strategy) { // Initialise the cleanup strategy. @@ -165,102 +115,67 @@ ACE_LFU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTI this->delete_cleanup_strategy_ == 1 && cleanup_s != 0) { + delete this->cleanup_strategy_; + this->cleanup_strategy_ = 0; + this->delete_cleanup_strategy_ = delete_cleanup_strategy; + } if (cleanup_s != 0) this->cleanup_strategy_ = cleanup_s; else if (this->cleanup_strategy_ == 0) { + ACE_NEW_RETURN (this->cleanup_strategy_, CLEANUP_STRATEGY, -1); this->delete_cleanup_strategy_ = delete_cleanup_strategy; - } - - // Initialise the caching strategy utility. - - // First we decide whether we need to clean up. - if (this->caching_strategy_utility_ != 0 && - this->delete_caching_strategy_utility_ == 1 && - utility_s != 0) - { - delete this->caching_strategy_utility_; - this->caching_strategy_utility_ = 0; - this->delete_caching_strategy_utility_ = delete_caching_strategy_utility; - } - if (utility_s != 0) - this->caching_strategy_utility_ = utility_s; - else if (this->caching_strategy_utility_ == 0) - { - ACE_NEW_RETURN (this->caching_strategy_utility_, - CACHING_STRATEGY_UTILITY, - -1); - - this->delete_caching_strategy_utility_ = delete_caching_strategy_utility; } - + return 0; } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> int -ACE_LFU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::clear_cache (CONTAINER &container) +template<class CONTAINER> int +ACE_LFU_Caching_Strategy<CONTAINER>::clear_cache (CONTAINER &container) { - return this->caching_strategy_utility_->clear_cache (container, - this->cleanup_strategy_, - this->purge_percent_, - this->entries_); -} -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> int -ACE_LFU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::clear_cache (CONTAINER &container, - unsigned int &total_container_entries) -{ - return this->caching_strategy_utility_->clear_cache (container, - this->cleanup_strategy_, - this->purge_percent_, - total_container_entries); + return this->caching_strategy_utility_.clear_cache (container, + this->cleanup_strategy_, + this->purge_percent_, + this->entries_); } //////////////////////////////////////////////////////////////////////////////////////////////// -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> -ACE_FIFO_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::ACE_FIFO_Caching_Strategy (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s, - int delete_cleanup_strategy, - CACHING_STRATEGY_UTILITY *utility_s, - int delete_caching_strategy_utility) +template<class CONTAINER> +ACE_FIFO_Caching_Strategy<CONTAINER>::ACE_FIFO_Caching_Strategy (ACE_Cleanup_Strategy<CONTAINER> *cleanup_s, + int delete_cleanup_strategy) : order_ (0), purge_percent_ (10), entries_ (0), cleanup_strategy_ (0), - delete_cleanup_strategy_ (1), - caching_strategy_utility_ (0), - delete_caching_strategy_utility_ (1) + delete_cleanup_strategy_ (1) { - if (this->open (cleanup_s, - delete_cleanup_strategy, - utility_s, - delete_caching_strategy_utility) == -1) + if (this->open (cleanup_s, delete_cleanup_strategy) == -1) ACE_ERROR ((LM_ERROR, ASYS_TEXT ("%p\n"), ASYS_TEXT ("ACE_FIFO_Caching_Strategy::ACE_FIFO_Caching_Strategy"))); } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> -ACE_FIFO_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::~ACE_FIFO_Caching_Strategy (void) +template<class CONTAINER> +ACE_FIFO_Caching_Strategy<CONTAINER>::~ACE_FIFO_Caching_Strategy (void) { } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> int -ACE_FIFO_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::open (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s, - int delete_cleanup_strategy, - CACHING_STRATEGY_UTILITY *utility_s, - int delete_caching_strategy_utility) +template<class CONTAINER> int +ACE_FIFO_Caching_Strategy<CONTAINER>::open (ACE_Cleanup_Strategy<CONTAINER> *cleanup_s, + int delete_cleanup_strategy) { // Initialise the cleanup strategy. @@ -269,116 +184,68 @@ ACE_FIFO_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UT this->delete_cleanup_strategy_ == 1 && cleanup_s != 0) { + delete this->cleanup_strategy_; + this->cleanup_strategy_ = 0; + this->delete_cleanup_strategy_ = delete_cleanup_strategy; + } if (cleanup_s != 0) this->cleanup_strategy_ = cleanup_s; else if (this->cleanup_strategy_ == 0) { + ACE_NEW_RETURN (this->cleanup_strategy_, - CLEANUP_STRATEGY, + CLEANUP_STRATEGY, -1); this->delete_cleanup_strategy_ = delete_cleanup_strategy; - } - - // Initialise the caching strategy utility. - // First we decide whether we need to clean up. - if (this->caching_strategy_utility_ != 0 && - this->delete_caching_strategy_utility_ == 1 && - utility_s != 0) - { - delete this->caching_strategy_utility_; - this->caching_strategy_utility_ = 0; - this->delete_caching_strategy_utility_ = delete_caching_strategy_utility; } + + return 0; +} - if (utility_s != 0) - this->caching_strategy_utility_ = utility_s; - else if (this->caching_strategy_utility_ == 0) - { - ACE_NEW_RETURN (this->caching_strategy_utility_, - CACHING_STRATEGY_UTILITY, - -1); - this->delete_caching_strategy_utility_ = delete_caching_strategy_utility; - } - return 0; -} -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> int -ACE_FIFO_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::clear_cache (CONTAINER &container) +template<class CONTAINER> int +ACE_FIFO_Caching_Strategy<CONTAINER>::clear_cache (CONTAINER &container) { - return this->caching_strategy_utility_->clear_cache (container, - this->cleanup_strategy_, - this->purge_percent_, - this->entries_); -} -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> int -ACE_FIFO_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::clear_cache (CONTAINER &container, - unsigned int &total_container_entries) -{ - return this->caching_strategy_utility_->clear_cache (container, - this->cleanup_strategy_, - this->purge_percent_, - total_container_entries); + return this->caching_strategy_utility_.clear_cache (container, + this->cleanup_strategy_, + this->purge_percent_, + this->entries_); } + //////////////////////////////////////////////////////////////////////////////////////////////// -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> -ACE_Null_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::ACE_Null_Caching_Strategy (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s, - int delete_cleanup_strategy, - CACHING_STRATEGY_UTILITY *utility_s, - int delete_caching_strategy_utility) +template<class CONTAINER> +ACE_Null_Caching_Strategy<CONTAINER>::ACE_Null_Caching_Strategy (ACE_Cleanup_Strategy<CONTAINER> *cleanup_s, + int delete_cleanup_strategy) { - ACE_UNUSED_ARG (cleanup_s); - ACE_UNUSED_ARG (delete_cleanup_strategy); - ACE_UNUSED_ARG (utility_s); - ACE_UNUSED_ARG (delete_caching_strategy_utility); } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> int -ACE_Null_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::open (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s, - int delete_cleanup_strategy, - CACHING_STRATEGY_UTILITY *utility_s, - int delete_caching_strategy_utility) +template<class CONTAINER> int +ACE_Null_Caching_Strategy<CONTAINER>::open (ACE_Cleanup_Strategy<CONTAINER> *cleanup_s, + int delete_cleanup_strategy) { - ACE_UNUSED_ARG (cleanup_s); - ACE_UNUSED_ARG (delete_cleanup_strategy); - ACE_UNUSED_ARG (utility_s); - ACE_UNUSED_ARG (delete_caching_strategy_utility); - - return 0; } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> -ACE_Null_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::~ACE_Null_Caching_Strategy (void) +template<class CONTAINER> +ACE_Null_Caching_Strategy<CONTAINER>::~ACE_Null_Caching_Strategy (void) { } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> int -ACE_Null_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::clear_cache (CONTAINER &container) +template<class CONTAINER> int +ACE_Null_Caching_Strategy<CONTAINER>::clear_cache (CONTAINER &container) { - ACE_UNUSED_ARG (container); - - return 0; -} - -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> int -ACE_Null_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::clear_cache (CONTAINER &container, - unsigned int &total_container_entries) -{ - ACE_UNUSED_ARG (container); - ACE_UNUSED_ARG (total_container_entries); - return 0; } @@ -388,5 +255,7 @@ ACE_ALLOC_HOOK_DEFINE(ACE_LRU_Caching_Strategy) ACE_ALLOC_HOOK_DEFINE(ACE_LFU_Caching_Strategy) ACE_ALLOC_HOOK_DEFINE(ACE_FIFO_Caching_Strategy) ACE_ALLOC_HOOK_DEFINE(ACE_Null_Caching_Strategy) - #endif /* CACHING_STRATEGIES_T_C */ + + + diff --git a/ace/Caching_Strategies_T.h b/ace/Caching_Strategies_T.h index 8e7db943ba7..686c5331d9e 100644 --- a/ace/Caching_Strategies_T.h +++ b/ace/Caching_Strategies_T.h @@ -27,7 +27,7 @@ #include "ace/Cleanup_Strategies_T.h" -template <class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> +template <class CONTAINER> class ACE_LRU_Caching_Strategy { // = TITLE @@ -39,28 +39,17 @@ class ACE_LRU_Caching_Strategy // is updated whenever an item is inserted or looked up in the // container. When the need of purging entries arises, the items // with the lowest timer values are removed. - // - // Explanation of the template parameter list: - // CONTAINER is any map with entries of type <KEY, VALUE>. - // The ATTRIBUTES are the deciding factor for purging of entries - // and should logically be included with the VALUE. Some ways of - // doing this are: As being a member of the VALUE or VALUE being - // ACE_Pair<x, ATTRIBUTES>. The CACHING_STRATEGY_UTILITY is the - // class which can be plugged in and which decides the entries - // to purge. public: // Traits. - typedef ATTRIBUTES CACHING_ATTRIBUTES; + typedef int ATTRIBUTES; typedef CONTAINER CACHE; // = Initialisation and termination. - ACE_LRU_Caching_Strategy (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s = 0, - int delete_cleanup_strategy = 1, - CACHING_STRATEGY_UTILITY *utility_s = 0, - int delete_caching_strategy_utility = 1); + ACE_LRU_Caching_Strategy (ACE_Cleanup_Strategy<CONTAINER> *cleanup_s = 0, + int delete_cleanup_strategy = 1); // The <container> is the map in which the entries reside. // The Cleanup_Strategy is the callback class to which the entries // to be cleaned up will be delegated. The <delete_cleanup_strategy> @@ -68,29 +57,23 @@ public: // Also, the timer attribute is initialed to zero in this constructor. // And the <purge_percent> field denotes the percentage of the entries // in the cache which can be purged automagically and by default is - // set to 10%. The ultility which helps the caching strategy in the - // purging of entries needs to be specified. By default a new one - // will be created of type CACHING_STRATEGY_UTILITY and - // <delete_caching_strategy_utility> decides whether to destroy the - // utility object or not. + // set to 10%. ~ACE_LRU_Caching_Strategy (void); // = Operations of the strategy. - int open (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s = 0, - int delete_cleanup_strategy = 1, - CACHING_STRATEGY_UTILITY *utility_s = 0, - int delete_caching_strategy_utility = 1); + int open (ACE_Cleanup_Strategy<CONTAINER> *cleanup_s = 0, + int delete_cleanup_strategy = 1); // This method which does the actual initialisation. ATTRIBUTES attributes (void); // Accessor method for the timer attributes. // = Accessor methods for the percentage of entries to purge. - unsigned int purge_percent (void); + int purge_percent (void); - void purge_percent (unsigned int percentage); + void purge_percent (int percentage); // = Strategy related Operations @@ -124,20 +107,12 @@ public: // This is the method which looks at each ITEM's attributes and // then decides on the one to remove. - int clear_cache (CONTAINER &container, - unsigned int &total_container_entries); - // This is the method which looks at each ITEM's attributes and - // then decides on the one to remove. The <total_container_entries> - // can be specified explicitly and facilitates use of the caching - // strategy even when the <entries_> is not maintained by the - // strategy itself. - void dump (void) const; // Dumps the state of the object. private: - typedef ACE_Default_Cleanup_Strategy<KEY, VALUE, CONTAINER> CLEANUP_STRATEGY; + typedef ACE_Default_Cleanup_Strategy<CONTAINER> CLEANUP_STRATEGY; ATTRIBUTES timer_; // This element is the one which is the deciding factor for purging @@ -149,7 +124,7 @@ private: unsigned int entries_; // The no of entries bound in the cache. - ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_strategy_; + ACE_Cleanup_Strategy<CONTAINER> *cleanup_strategy_; // The cleanup strategy which can be used to destroy the entries of // the container. @@ -157,20 +132,15 @@ private: // The flag which denotes the ownership of the cleanup strategy. // If 1 then this class itself will destroy the strategy. - CACHING_STRATEGY_UTILITY *caching_strategy_utility_; + ACE_Caching_Strategy_Utility<CONTAINER, ATTRIBUTES> caching_strategy_utility_; // This is the helper class which will decide and expunge entries // from the cache. - - int delete_caching_strategy_utility_; - // The flag which denotes the ownership of the - // caching_strategy_utility. If 1 then this class itself will - // destroy the strategy utility object. }; ////////////////////////////////////////////////////////////////////////// -template <class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> +template <class CONTAINER> class ACE_LFU_Caching_Strategy { // = TITLE @@ -182,28 +152,15 @@ class ACE_LFU_Caching_Strategy // the item is bound or looked up in the cache. Thus it denotes // the frequency of use. According to the value of the attribute // the item is removed from the CONTAINER i.e cache. - // - // Explanation of the template parameter list: - // CONTAINER is any map with entries of type <KEY, VALUE>. - // The ATTRIBUTES are the deciding factor for purging of entries - // and should logically be included with the VALUE. Some ways of - // doing this are: As being a member of the VALUE or VALUE being - // ACE_Pair<x, ATTRIBUTES>. The CACHING_STRATEGY_UTILITY is the - // class which can be plugged in and which decides the entries - // to purge. - public: // Traits. - typedef ATTRIBUTES CACHING_ATTRIBUTES; - typedef CONTAINER CACHE; + typedef int ATTRIBUTES; // = Initialisation and termination methods. - ACE_LFU_Caching_Strategy (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s = 0, - int delete_cleanup_strategy = 1, - CACHING_STRATEGY_UTILITY *utility_s = 0, - int delete_caching_strategy_utility = 1); + ACE_LFU_Caching_Strategy (ACE_Cleanup_Strategy<CONTAINER> *cleanup_s = 0, + int delete_cleanup_strategy = 1); // The <container> is the map in which the entries reside. // The Cleanup_Strategy is the callback class to which the entries // to be cleaned up will be delegated. The <delete_cleanup_strategy> @@ -211,18 +168,12 @@ public: // Also, the timer attribute is initialed to zero in this constructor. // And the <purge_percent> field denotes the percentage of the entries // in the cache which can be purged automagically and by default is - // set to 10%.The ultility which helps the caching strategy in the - // purging of entries will be default be the - // ACE_Caching_Strategy_Utility and the - // <delete_caching_strategy_utility> decides whether to destroy the - // utility or not. + // set to 10%. ~ACE_LFU_Caching_Strategy (void); - int open (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s = 0, - int delete_cleanup_strategy = 1, - CACHING_STRATEGY_UTILITY *utility_s = 0, - int delete_caching_strategy_utility = 1); + int open (ACE_Cleanup_Strategy<CONTAINER> *cleanup_s = 0, + int delete_cleanup_strategy = 1); // This method which does the actual initialisation. // = Strategy methods. @@ -231,9 +182,9 @@ public: // Access the attributes. // = Accessor methods for the percentage of entries to purge. - unsigned int purge_percent (void); + int purge_percent (void); - void purge_percent (unsigned int percentage); + void purge_percent (int percentage); // = Strategy related Operations @@ -266,28 +217,20 @@ public: // This is the method which looks at each ITEM's attributes and // then decides on the one to remove. - int clear_cache (CONTAINER &container, - unsigned int &total_container_entries); - // This is the method which looks at each ITEM's attributes and - // then decides on the one to remove. The <total_container_entries> - // can be specified explicitly and facilitates use of the caching - // strategy even when the <entries_> is not maintained by the - // strategy itself. - void dump (void) const; // Dumps the state of the object. private: - typedef ACE_Default_Cleanup_Strategy<KEY, VALUE, CONTAINER> CLEANUP_STRATEGY; - + typedef ACE_Default_Cleanup_Strategy<CONTAINER> CLEANUP_STRATEGY; + unsigned int purge_percent_; // The level about which the purging will happen automagically. unsigned int entries_; // The no of entries bound in the cache. - ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_strategy_; + ACE_Cleanup_Strategy<CONTAINER> *cleanup_strategy_; // The cleanup strategy which can be used to destroy the entries of // the container. @@ -295,49 +238,32 @@ private: // The flag which denotes the ownership of the cleanup strategy. // If 1 then this class itself will destroy the strategy. - CACHING_STRATEGY_UTILITY *caching_strategy_utility_; + ACE_Caching_Strategy_Utility<CONTAINER, ATTRIBUTES> caching_strategy_utility_; // This is the helper class which will decide and expunge entries // from the cache. - int delete_caching_strategy_utility_; - // The flag which denotes the ownership of the - // caching_strategy_utility. If 1 then this class itself will - // destroy the strategy utility object. }; ///////////////////////////////////////////////////////////// -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> +template<class CONTAINER> class ACE_FIFO_Caching_Strategy { // = TITLE - // The First In First Out strategy is implemented wherein each - // item is ordered. + // The First In First Out strategy is implemented wherein each + // item is ordered. // // = DESCRIPTION - // The order tag of each item is used to decide the item to be - // removed from the cache. The items with least order are removed. - // - // Explanation of the template parameter list: - // CONTAINER is any map with entries of type <KEY, VALUE>. - // The ATTRIBUTES are the deciding factor for purging of entries - // and should logically be included with the VALUE. Some ways of - // doing this are: As being a member of the VALUE or VALUE being - // ACE_Pair<x, ATTRIBUTES>. The CACHING_STRATEGY_UTILITY is the - // class which can be plugged in and which decides the entries - // to purge. - + // The order tag of each item is used to decide the item to be + // removed from the cache. The items with least order are removed. public: - typedef ATTRIBUTES CACHING_ATTRIBUTES; - typedef CONTAINER CACHE; + typedef int ATTRIBUTES; // = Initialisation and termination. - ACE_FIFO_Caching_Strategy (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s = 0, - int delete_cleanup_strategy = 1, - CACHING_STRATEGY_UTILITY *utility_s = 0, - int delete_caching_strategy_utility = 1); + ACE_FIFO_Caching_Strategy (ACE_Cleanup_Strategy<CONTAINER> *cleanup_s = 0, + int delete_cleanup_strategy = 1); // The <container> is the map in which the entries reside. // The Cleanup_Strategy is the callback class to which the entries // to be cleaned up will be delegated. The <delete_cleanup_strategy> @@ -345,18 +271,12 @@ public: // Also, the timer attribute is initialed to zero in this constructor. // And the <purge_percent> field denotes the percentage of the entries // in the cache which can be purged automagically and by default is - // set to 10%.The ultility which helps the caching strategy in the - // purging of entries will be default be the - // ACE_Caching_Strategy_Utility and the - // <delete_caching_strategy_utility> decides whether to destroy the - // utility or not. + // set to 10%. ~ACE_FIFO_Caching_Strategy (void); - int open (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s = 0, - int delete_cleanup_strategy = 1, - CACHING_STRATEGY_UTILITY *utility_s = 0, - int delete_caching_strategy_utility = 1); + int open (ACE_Cleanup_Strategy<CONTAINER> *cleanup_s = 0, + int delete_cleanup_strategy = 1); // This method which does the actual initialisation. // = Strategy methods. @@ -365,9 +285,9 @@ public: // Accessor method. // = Accessor methods for the percentage of entries to purge. - unsigned int purge_percent (void); + int purge_percent (void); - void purge_percent (unsigned int percentage); + void purge_percent (int percentage); // = Strategy related Operations @@ -398,21 +318,13 @@ public: // This is the method which looks at each ITEM's attributes and // then decides on the one to remove. - int clear_cache (CONTAINER &container, - unsigned int &total_container_entries); - // This is the method which looks at each ITEM's attributes and - // then decides on the one to remove. The <total_container_entries> - // can be specified explicitly and facilitates use of the caching - // strategy even when the <entries_> is not maintained by the - // strategy itself. - void dump (void) const; // Dumps the state of the object. private: - typedef ACE_Default_Cleanup_Strategy<KEY, VALUE, CONTAINER> CLEANUP_STRATEGY; - + typedef ACE_Default_Cleanup_Strategy<CONTAINER> CLEANUP_STRATEGY; + ATTRIBUTES order_; // The order is the deciding factor for the item to be removed from // the cache. @@ -423,7 +335,7 @@ private: unsigned int entries_; // The no of entries bound in the cache. - ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_strategy_; + ACE_Cleanup_Strategy<CONTAINER> *cleanup_strategy_; // The cleanup strategy which can be used to destroy the entries of // the container. @@ -431,18 +343,12 @@ private: // The flag which denotes the ownership of the cleanup strategy. // If 1 then this class itself will destroy the strategy. - CACHING_STRATEGY_UTILITY *caching_strategy_utility_; + ACE_Caching_Strategy_Utility<CONTAINER, ATTRIBUTES> caching_strategy_utility_; // This is the helper class which will decide and expunge entries // from the cache. - - int delete_caching_strategy_utility_; - // The flag which denotes the ownership of the - // caching_strategy_utility. If 1 then this class itself will - // destroy the strategy utility object. - }; -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> +template<class CONTAINER> class ACE_Null_Caching_Strategy { // = TITLE @@ -455,24 +361,18 @@ class ACE_Null_Caching_Strategy public: - // = Traits. - typedef ATTRIBUTES CACHING_ATTRIBUTES; - typedef CONTAINER CACHE; + typedef int ATTRIBUTES; // = Initialisation and termination. - ACE_Null_Caching_Strategy (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s = 0, - int delete_cleanup_strategy = 1, - CACHING_STRATEGY_UTILITY *utility_s = 0, - int delete_caching_strategy_utility = 1); + ACE_Null_Caching_Strategy (ACE_Cleanup_Strategy<CONTAINER> *cleanup_s = 0, + int delete_cleanup_strategy = 1); ~ACE_Null_Caching_Strategy (void); - int open (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s = 0, - int delete_cleanup_strategy = 1, - CACHING_STRATEGY_UTILITY *utility_s = 0, - int delete_caching_strategy_utility = 1); + int open (ACE_Cleanup_Strategy<CONTAINER> *cleanup_s = 0, + int delete_cleanup_strategy = 1); // This method which does the actual initialisation. // = Strategy methods. All are NO_OP methods!!! @@ -481,9 +381,9 @@ public: // Accessor method. // = Accessor methods for the percentage of entries to purge. - unsigned int purge_percent (void); + int purge_percent (void); - void purge_percent (unsigned int percentage); + void purge_percent (int percentage); // = Strategy related Operations @@ -514,14 +414,6 @@ public: // This is the method which looks at each ITEM's attributes and // then decides on the one to remove. - int clear_cache (CONTAINER &container, - unsigned int &total_container_entries); - // This is the method which looks at each ITEM's attributes and - // then decides on the one to remove. The <total_container_entries> - // can be specified explicitly and facilitates use of the caching - // strategy even when the <entries_> is not maintained by the - // strategy itself. - void dump (void) const; // Dumps the state of the object. diff --git a/ace/Caching_Strategies_T.i b/ace/Caching_Strategies_T.i index eacd2bfcf59..1b9bcf2264f 100644 --- a/ace/Caching_Strategies_T.i +++ b/ace/Caching_Strategies_T.i @@ -1,30 +1,28 @@ /* -*-C++-*- */ //$Id$ -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> ACE_INLINE ATTRIBUTES -ACE_LRU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::attributes (void) +template<class CONTAINER> ACE_INLINE ACE_LRU_Caching_Strategy<CONTAINER>::ATTRIBUTES +ACE_LRU_Caching_Strategy<CONTAINER>::attributes (void) { return this->timer_; } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> ACE_INLINE unsigned int -ACE_LRU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::purge_percent (void) +template<class CONTAINER> ACE_INLINE int +ACE_LRU_Caching_Strategy<CONTAINER>::purge_percent (void) { return this->purge_percent_; } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> ACE_INLINE void -ACE_LRU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::purge_percent (unsigned int percentage) +template<class CONTAINER> ACE_INLINE void +ACE_LRU_Caching_Strategy<CONTAINER>::purge_percent (int percentage) { this->purge_percent_ = percentage; } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> ACE_INLINE int -ACE_LRU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::notify_bind (int result, - const ATTRIBUTES &attr) +template<class CONTAINER> ACE_INLINE int +ACE_LRU_Caching_Strategy<CONTAINER>::notify_bind (int result, + const ATTRIBUTES &attributes) { - ACE_UNUSED_ARG (attr); - if (result == 0) { ++this->timer_; @@ -34,9 +32,9 @@ ACE_LRU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTI return result; } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> ACE_INLINE int -ACE_LRU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::notify_find (int result, - ATTRIBUTES &attr) +template<class CONTAINER> ACE_INLINE int +ACE_LRU_Caching_Strategy<CONTAINER>::notify_find (int result, + ATTRIBUTES &attr) { if (result == 0) { @@ -47,37 +45,32 @@ ACE_LRU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTI return result; } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> ACE_INLINE int -ACE_LRU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::notify_unbind (int result, - const ATTRIBUTES &attr) +template<class CONTAINER> ACE_INLINE int +ACE_LRU_Caching_Strategy<CONTAINER>::notify_unbind (int result, + const ATTRIBUTES &attr) { - ACE_UNUSED_ARG (attr); return result; } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> ACE_INLINE int -ACE_LRU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::notify_trybind (int result, - ATTRIBUTES &attr) +template<class CONTAINER> ACE_INLINE int +ACE_LRU_Caching_Strategy<CONTAINER>::notify_trybind (int result, + ATTRIBUTES &attr) { - ACE_UNUSED_ARG (attr); - return result; } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> ACE_INLINE int -ACE_LRU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::notify_rebind (int result, - const ATTRIBUTES &attr) +template<class CONTAINER> ACE_INLINE int +ACE_LRU_Caching_Strategy<CONTAINER>::notify_rebind (int result, + const ATTRIBUTES &attr) { - ACE_UNUSED_ARG (attr); - if (result == 0) ++this->timer_; return result; } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> ACE_INLINE void -ACE_LRU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::dump (void) const +template<class CONTAINER> ACE_INLINE void +ACE_LRU_Caching_Strategy<CONTAINER>::dump (void) const { ACE_TRACE ("ACE_LRU_Caching_Strategy::dump"); @@ -88,79 +81,69 @@ ACE_LRU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTI ////////////////////////////////////////////////////////////////////////////////// -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> ACE_INLINE ATTRIBUTES -ACE_LFU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::attributes (void) +template<class CONTAINER> ACE_INLINE ACE_LFU_Caching_Strategy<CONTAINER>::ATTRIBUTES +ACE_LFU_Caching_Strategy<CONTAINER>::attributes (void) { return 0; } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> ACE_INLINE unsigned int -ACE_LFU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::purge_percent (void) +template<class CONTAINER> ACE_INLINE int +ACE_LFU_Caching_Strategy<CONTAINER>::purge_percent (void) { return this->purge_percent_; } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> ACE_INLINE void -ACE_LFU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::purge_percent (unsigned int percentage) +template<class CONTAINER> ACE_INLINE void +ACE_LFU_Caching_Strategy<CONTAINER>::purge_percent (int percentage) { this->purge_percent_ = percentage; } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> ACE_INLINE int -ACE_LFU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::notify_bind (int result, - const ATTRIBUTES &attr) +template<class CONTAINER> ACE_INLINE int +ACE_LFU_Caching_Strategy<CONTAINER>::notify_bind (int result, + const ATTRIBUTES &attr) { - ACE_UNUSED_ARG (attr); - if (result == 0) ++this->entries_; return result; } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> ACE_INLINE int -ACE_LFU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::notify_find (int result, - ATTRIBUTES &attr) +template<class CONTAINER> ACE_INLINE int +ACE_LFU_Caching_Strategy<CONTAINER>::notify_find (int result, + ATTRIBUTES &attr) { - ACE_UNUSED_ARG (attr); - if (result == 0) ++attr; return result; } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> ACE_INLINE int -ACE_LFU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::notify_trybind (int result, - ATTRIBUTES &attr) +template<class CONTAINER> ACE_INLINE int +ACE_LFU_Caching_Strategy<CONTAINER>::notify_trybind (int result, + ATTRIBUTES &attr) { - ACE_UNUSED_ARG (attr); - return result; } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> ACE_INLINE int -ACE_LFU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::notify_rebind (int result, - const ATTRIBUTES &attr) +template<class CONTAINER> ACE_INLINE int +ACE_LFU_Caching_Strategy<CONTAINER>::notify_rebind (int result, + const ATTRIBUTES &attr) { - ACE_UNUSED_ARG (attr); - if (result == 0) ++this->entries_; return result; } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> ACE_INLINE int -ACE_LFU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::notify_unbind (int result, - const ATTRIBUTES &attr) +template<class CONTAINER> ACE_INLINE int +ACE_LFU_Caching_Strategy<CONTAINER>::notify_unbind (int result, + const ATTRIBUTES &attr) { - ACE_UNUSED_ARG (attr); - return result; } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> ACE_INLINE void -ACE_LFU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::dump (void) const +template<class CONTAINER> ACE_INLINE void +ACE_LFU_Caching_Strategy<CONTAINER>::dump (void) const { ACE_TRACE ("ACE_LFU_Caching_Strategy::dump"); @@ -170,29 +153,27 @@ ACE_LFU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTI ////////////////////////////////////////////////////////////////////////////////////// -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> ACE_INLINE ATTRIBUTES -ACE_FIFO_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::attributes (void) +template<class CONTAINER> ACE_INLINE ACE_FIFO_Caching_Strategy<CONTAINER>::ATTRIBUTES +ACE_FIFO_Caching_Strategy<CONTAINER>::attributes (void) { return this->order_; } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> ACE_INLINE unsigned int -ACE_FIFO_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::purge_percent (void) +template<class CONTAINER> ACE_INLINE int +ACE_FIFO_Caching_Strategy<CONTAINER>::purge_percent (void) { return this->purge_percent_; } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> ACE_INLINE void -ACE_FIFO_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::purge_percent (unsigned int percentage) +template<class CONTAINER> ACE_INLINE void +ACE_FIFO_Caching_Strategy<CONTAINER>::purge_percent (int percentage) { this->purge_percent_ = percentage; } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> ACE_INLINE int -ACE_FIFO_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::notify_bind (int result, - const ATTRIBUTES &attr) +template<class CONTAINER> ACE_INLINE int +ACE_FIFO_Caching_Strategy<CONTAINER>::notify_bind (int result, + const ATTRIBUTES &attr) { - ACE_UNUSED_ARG (attr); - if (result == 0) { ++this->order_; @@ -203,39 +184,31 @@ ACE_FIFO_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UT } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> ACE_INLINE int -ACE_FIFO_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::notify_find (int result, - ATTRIBUTES &attr) +template<class CONTAINER> ACE_INLINE int +ACE_FIFO_Caching_Strategy<CONTAINER>::notify_find (int result, + ATTRIBUTES &attr) { - ACE_UNUSED_ARG (attr); - return result; } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> ACE_INLINE int -ACE_FIFO_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::notify_unbind (int result, - const ATTRIBUTES &attr) +template<class CONTAINER> ACE_INLINE int +ACE_FIFO_Caching_Strategy<CONTAINER>::notify_unbind (int result, + const ATTRIBUTES &attr) { - ACE_UNUSED_ARG (attr); - return result; } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> ACE_INLINE int -ACE_FIFO_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::notify_trybind (int result, - ATTRIBUTES &attr) +template<class CONTAINER> ACE_INLINE int +ACE_FIFO_Caching_Strategy<CONTAINER>::notify_trybind (int result, + ATTRIBUTES &attr) { - ACE_UNUSED_ARG (attr); - return result; } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> ACE_INLINE int -ACE_FIFO_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::notify_rebind (int result, - const ATTRIBUTES &attr) +template<class CONTAINER> ACE_INLINE int +ACE_FIFO_Caching_Strategy<CONTAINER>::notify_rebind (int result, + const ATTRIBUTES &attr) { - ACE_UNUSED_ARG (attr); - if (result == 0) { ++this->order_; @@ -246,8 +219,8 @@ ACE_FIFO_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UT } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> ACE_INLINE void -ACE_FIFO_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::dump (void) const +template<class CONTAINER> ACE_INLINE void +ACE_FIFO_Caching_Strategy<CONTAINER>::dump (void) const { ACE_TRACE ("ACE_FIFO_Caching_Strategy::dump"); @@ -258,71 +231,60 @@ ACE_FIFO_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UT ////////////////////////////////////////////////////////////////////////////////// -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> ACE_INLINE ATTRIBUTES -ACE_Null_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::attributes (void) +template<class CONTAINER> ACE_INLINE ACE_Null_Caching_Strategy<CONTAINER>::ATTRIBUTES +ACE_Null_Caching_Strategy<CONTAINER>::attributes (void) { return 0; } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> ACE_INLINE unsigned int -ACE_Null_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::purge_percent (void) +template<class CONTAINER> ACE_INLINE int +ACE_Null_Caching_Strategy<CONTAINER>::purge_percent (void) { return 0; } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> ACE_INLINE void -ACE_Null_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::purge_percent (unsigned int percentage) +template<class CONTAINER> ACE_INLINE void +ACE_Null_Caching_Strategy<CONTAINER>::purge_percent (int percentage) { - ACE_UNUSED_ARG (percentage); } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> ACE_INLINE int -ACE_Null_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::notify_bind (int result, - const ATTRIBUTES &attr) +template<class CONTAINER> ACE_INLINE int +ACE_Null_Caching_Strategy<CONTAINER>::notify_bind (int result, + const ATTRIBUTES &attr) { - ACE_UNUSED_ARG (attr); - return result; } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> ACE_INLINE int -ACE_Null_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::notify_find (int result, - ATTRIBUTES &attr) +template<class CONTAINER> ACE_INLINE int +ACE_Null_Caching_Strategy<CONTAINER>::notify_find (int result, + ATTRIBUTES &attr) { - ACE_UNUSED_ARG (attr); - return result; } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> ACE_INLINE int -ACE_Null_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::notify_unbind (int result, - const ATTRIBUTES &attr) +template<class CONTAINER> ACE_INLINE int +ACE_Null_Caching_Strategy<CONTAINER>::notify_unbind (int result, + const ATTRIBUTES &attr) { - ACE_UNUSED_ARG (attr); - return result; } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> ACE_INLINE int -ACE_Null_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::notify_trybind (int result, - ATTRIBUTES &attr) +template<class CONTAINER> ACE_INLINE int +ACE_Null_Caching_Strategy<CONTAINER>::notify_trybind (int result, + ATTRIBUTES &attr) { - ACE_UNUSED_ARG (attr); - return result; } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> ACE_INLINE int -ACE_Null_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::notify_rebind (int result, - const ATTRIBUTES &attr) +template<class CONTAINER> ACE_INLINE int +ACE_Null_Caching_Strategy<CONTAINER>::notify_rebind (int result, + const ATTRIBUTES &attr) { - ACE_UNUSED_ARG (attr); - return result; } -template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> ACE_INLINE void -ACE_Null_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::dump (void) const +template<class CONTAINER> ACE_INLINE void +ACE_Null_Caching_Strategy<CONTAINER>::dump (void) const { ACE_TRACE ("ACE_Null_Caching_Strategy::dump"); diff --git a/ace/Caching_Strategy_Utility_T.cpp b/ace/Caching_Strategy_Utility_T.cpp index 7acbcad8c0a..98a7b842a5e 100644 --- a/ace/Caching_Strategy_Utility_T.cpp +++ b/ace/Caching_Strategy_Utility_T.cpp @@ -17,18 +17,11 @@ ACE_RCSID(ace, Caching_Strategy_Utility_T, "$Id$") -template <class KEY, class VALUE, class CONTAINER, class ATTRIBUTES> -ACE_Caching_Strategy_Utility<KEY, VALUE, CONTAINER, ATTRIBUTES>::~ACE_Caching_Strategy_Utility (void) -{ -} - -///////////////////////////////////////////////////////////////////////////////////////////////////// - -template <class KEY, class VALUE, class CONTAINER, class ATTRIBUTES> int -ACE_Svc_Caching_Strategy_Utility<KEY, VALUE, CONTAINER, ATTRIBUTES>::clear_cache (CONTAINER &container, - ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s, - const unsigned int purge_percent, - unsigned int &entries) +template <class CONTAINER, class ATTRIBUTES> int +ACE_Caching_Strategy_Utility<CONTAINER, ATTRIBUTES>::clear_cache (CONTAINER &container, + ACE_Cleanup_Strategy<CONTAINER> *cleanup_s, + const unsigned int purge_percent, + unsigned int &entries) { // Check that the purge_percent is non-zero. if (purge_percent == 0) @@ -38,45 +31,45 @@ ACE_Svc_Caching_Strategy_Utility<KEY, VALUE, CONTAINER, ATTRIBUTES>::clear_cache // Oops! then thers no way out but exiting. So return an error. if (entries == 1) return -1; - + // Calculate the no of entries to remove from the cache depending // upon the <purge_percent>. double val = (double) purge_percent / 100; - int no_of_entries = (int) (val * entries + 0.5); - + int no_of_entries = (int) ceil (val * entries); + KEY *key_to_remove = 0; VALUE *value_to_remove = 0; - + for (int i = 0; i < no_of_entries ; ++i) - { - this->minimum (container, - key_to_remove, - value_to_remove); - - if (cleanup_s->cleanup (container, key_to_remove, value_to_remove) == -1) - return -1; - - --entries; - - } - + { + this->minimum (container, + key_to_remove, + value_to_remove); + + if (cleanup_s->cleanup (container, key_to_remove, value_to_remove) == -1) + return -1; + + --entries; + + } + return 0; } -template <class KEY, class VALUE, class CONTAINER, class ATTRIBUTES> void -ACE_Svc_Caching_Strategy_Utility<KEY, VALUE, CONTAINER, ATTRIBUTES>::minimum (CONTAINER &container, - KEY *&key, - VALUE *&value) +template <class CONTAINER, class ATTRIBUTES> void +ACE_Caching_Strategy_Utility<CONTAINER, ATTRIBUTES>::minimum (CONTAINER &container, + KEY *&key, + VALUE *&value) { typedef ACE_TYPENAME CONTAINER::ITERATOR ITERATOR; typedef ACE_TYPENAME CONTAINER::ENTRY ITEM; - + ITERATOR iter (container); ATTRIBUTES min = 0; - ITEM *item = 0; + ITEM *item = 0; // The iterator moves thru the container searching for the entry with the - // lowest ATTRIBUTES. + // lowest ATTRIBUTES. for (min = (*iter).int_id_.second (), key = &(*iter).ext_id_, value = &(*iter).int_id_; iter.next (item) != 0; ++iter) @@ -92,99 +85,4 @@ ACE_Svc_Caching_Strategy_Utility<KEY, VALUE, CONTAINER, ATTRIBUTES>::minimum (CO } } -//////////////////////////////////////////////////////////////////////////////////////////////////////// - -template <class KEY, class VALUE, class CONTAINER, class ATTRIBUTES> int -ACE_Handler_Caching_Strategy_Utility<KEY, VALUE, CONTAINER, ATTRIBUTES>::clear_cache (CONTAINER &container, - ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s, - const unsigned int purge_percent, - unsigned int &entries) -{ - // Check that the purge_percent is non-zero. - if (purge_percent == 0) - return 0; - - // Also whether the number of entries in the cache is just one! - // Oops! then thers no way out but exiting. So return an error. - if (entries == 1) - return -1; - - // Calculate the no of entries to remove from the cache depending - // upon the <purge_percent>. - double val = (double) purge_percent / 100; - int no_of_entries = (int) (val * entries + 0.5); - - KEY *key_to_remove = 0; - VALUE *value_to_remove = 0; - - for (int i = 0; i < no_of_entries ; ++i) - { - this->minimum (container, - key_to_remove, - value_to_remove); - - if (cleanup_s->cleanup (container, key_to_remove, value_to_remove) == -1) - return -1; - - --entries; - } - - return 0; -} - -template <class KEY, class VALUE, class CONTAINER, class ATTRIBUTES> void -ACE_Handler_Caching_Strategy_Utility<KEY, VALUE, CONTAINER, ATTRIBUTES>::minimum (CONTAINER &container, - KEY *&key, - VALUE *&value) -{ - typedef ACE_TYPENAME CONTAINER::ITERATOR ITERATOR; - typedef ACE_TYPENAME CONTAINER::ENTRY ITEM; - - ITERATOR iter (container); - ATTRIBUTES min = 0; - ITEM *item = 0; - - for (min = (*iter).int_id_->caching_attributes (), key = &(*iter).ext_id_, value = &(*iter).int_id_; - iter.next (item) != 0; - ++iter) - { - // Ah! an item with lower ATTTRIBUTES... - if ((min.attributes () > (*iter).int_id_->caching_attributes ().attributes ()) && ((*iter).int_id_->active () != 1)) - { - min = (*iter).int_id_->caching_attributes (); - - key = &(*iter).ext_id_; - - value = &(*iter).int_id_; - } - } - -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////// - -template <class KEY, class VALUE, class CONTAINER, class ATTRIBUTES> int -ACE_Null_Caching_Strategy_Utility<KEY, VALUE, CONTAINER, ATTRIBUTES>::clear_cache (CONTAINER &container, - ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s, - const unsigned int purge_percent, - unsigned int &entries) -{ - ACE_UNUSED_ARG (container); - ACE_UNUSED_ARG (cleanup_s); - ACE_UNUSED_ARG (purge_percent); - ACE_UNUSED_ARG (entries); - - return 0; -} - -template <class KEY, class VALUE, class CONTAINER, class ATTRIBUTES> void -ACE_Null_Caching_Strategy_Utility<KEY, VALUE, CONTAINER, ATTRIBUTES>::minimum (CONTAINER &container, - KEY *&key, - VALUE *&value) -{ - ACE_UNUSED_ARG (container); - ACE_UNUSED_ARG (key); - ACE_UNUSED_ARG (value); -} - #endif /* CACHING_STRATEGY_UTILITY_T_C */ diff --git a/ace/Caching_Strategy_Utility_T.h b/ace/Caching_Strategy_Utility_T.h index 4375fcf3048..df9673498c1 100644 --- a/ace/Caching_Strategy_Utility_T.h +++ b/ace/Caching_Strategy_Utility_T.h @@ -18,48 +18,18 @@ #define CACHING_STRATEGY_UTILITY_H #include "ace/OS.h" +#include <math.h> #if !defined (ACE_LACKS_PRAGMA_ONCE) #define ACE_LACKS_PRAGMA_ONCE #endif /* ACE_LACKS_PRAGMA_ONCE */ // Forward declaration -template <class KEY, class VALUE, class CONTAINER> +template <class CONTAINER> class ACE_Cleanup_Strategy; -template <class KEY, class VALUE, class CONTAINER, class ATTRIBUTES> -class ACE_Caching_Strategy_Utility -{ - // = TITLE - // Defines a abstract helper class for the Caching Strategies. - // - // = DESCRIPTION - // This class defines the methods commonly used by the - // different caching strategies. For instance: clear_cache () - // method which decides and purges the entry from the container. - - public: - - virtual ~ACE_Caching_Strategy_Utility (void); - // Destructor. - - virtual int clear_cache (CONTAINER &container, - ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s, - const unsigned int purge_percent, - unsigned int &entries) = 0; - // This method will remove the entries from the cache. - - virtual void minimum (CONTAINER &container, - KEY *&key, - VALUE *&value) = 0; - // Find the entry with minimum caching attributes. - -}; - -//////////////////////////////////////////////////////////////////////////////////// - -template <class KEY, class VALUE, class CONTAINER, class ATTRIBUTES> -class ACE_Svc_Caching_Strategy_Utility : public ACE_Caching_Strategy_Utility<KEY, VALUE, CONTAINER, ATTRIBUTES> +template <class CONTAINER, class ATTRIBUTES> +class ACE_Caching_Strategy_Utility { // = TITLE // Defines a helper class for the Caching Strategies. @@ -68,102 +38,27 @@ class ACE_Svc_Caching_Strategy_Utility : public ACE_Caching_Strategy_Utility<KEY // This class defines the methods commonly used by the // different caching strategies. For instance: clear_cache () // method which decides and purges the entry from the container. - // Note: This class helps in the caching_strategies using a - // container containing entries of <KEY, ACE_Pair<VALUE, - // attributes>> kind. The attributes helps in deciding the - // entries to be purged. public: - virtual int clear_cache (CONTAINER &container, - ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s, - const unsigned int purge_percent, - unsigned int &entries); - // Purge entries from the <container>. The Cleanup_Strategy will do - // the actual job of cleanup once the entries to be cleaned up are - // decided. - - virtual void minimum (CONTAINER &container, - KEY *&key, - VALUE *&value); - // Find the entry with minimum caching attributes. - -}; - - -//////////////////////////////////////////////////////////////////////////////////////// - -template <class KEY, class VALUE, class CONTAINER, class ATTRIBUTES> -class ACE_Handler_Caching_Strategy_Utility : public ACE_Caching_Strategy_Utility <KEY, VALUE, CONTAINER, ATTRIBUTES> -{ - // = TITLE - // Defines a helper class for the Caching Strategies. - // - // = DESCRIPTION - // This class defines the methods commonly used by the - // different caching strategies. For instance: clear_cache () - // method which decides and purges the entry from the container. - // Note: This class helps in the caching_strategies using a - // container containing entries of <KEY, HANDLER> kind where the - // HANDLER contains the caching attributes which help in deciding - // the entries to be purged. - -public: - - virtual int clear_cache (CONTAINER &container, - ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s, - const unsigned int purge_percent, - unsigned int &entries); - // Purge entries from the <container>. The Cleanup_Strategy will do - // the actual job of cleanup once the entries to be cleaned up are - // decided. - - virtual void minimum (CONTAINER &container, - KEY *&key, - VALUE *&value); - // Find the entry with minimum caching attributes. - // This is handler specific since this utility is to be used very - // specifically for handler who have caching_attributes for server - // side acched connection management. - -}; - -/////////////////////////////////////////////////////////////////////////// - -template <class KEY, class VALUE, class CONTAINER, class ATTRIBUTES> -class ACE_Null_Caching_Strategy_Utility : public ACE_Caching_Strategy_Utility <KEY, VALUE, CONTAINER, ATTRIBUTES> -{ - // = TITLE - // Defines a dummy helper class for the Caching Strategies. - // - // = DESCRIPTION - // This class defines the methods commonly used by the - // different caching strategies. For instance: clear_cache () - // method which decides and purges the entry from the container. - // Note: This class is be used with the Null_Caching_Strategy. - -public: - - virtual int clear_cache (CONTAINER &container, - ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s, - const unsigned int purge_percent, - unsigned int &entries); - // Purge entries from the <container>. The Cleanup_Strategy will do - // the actual job of cleanup once the entries to be cleaned up are - // decided. NOte: Here it is a no-op. + // = Traits. + typedef ACE_TYPENAME CONTAINER::KEY KEY; + typedef ACE_TYPENAME CONTAINER::VALUE VALUE; + + int clear_cache (CONTAINER &container, + ACE_Cleanup_Strategy<CONTAINER> *cleanup_s, + const unsigned int purge_percent, + unsigned int &entries); + // Purge entries from the <container>. The <entries> had to be + // passed by refernce as it wuold reduce on cleanup. - virtual void minimum (CONTAINER &container, - KEY *&key, - VALUE *&value); + void minimum (CONTAINER &container, + KEY *&key, + VALUE *&value); // Find the entry with minimum caching attributes. - // This is handler specific since this utility is to be used very - // specifically for handler who have caching_attributes for server - // side acched connection management.Note: Here it is a no-op. }; -/////////////////////////////////////////////////////////////////////////// - #if defined (__ACE_INLINE__) #include "ace/Caching_Strategy_Utility_T.i" #endif /* __ACE_INLINE__ */ diff --git a/ace/Cleanup_Strategies_T.cpp b/ace/Cleanup_Strategies_T.cpp index b54db63adf3..4afa343e84a 100644 --- a/ace/Cleanup_Strategies_T.cpp +++ b/ace/Cleanup_Strategies_T.cpp @@ -12,34 +12,32 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ #if defined (ACE_LACKS_INLINE_FUNCTIONS) -#include "ace/Cleanup_Strategies_T.i" +#include "ace/Cached_Connect_Strategy_T.i" #endif /* ACE_LACKS_INLINE_FUNCTIONS */ ACE_RCSID(ace, Cleanup_Strategies_T, "$Id$") -template <class KEY, class VALUE, class CONTAINER> -ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER>::~ACE_Cleanup_Strategy (void) +template <class CONTAINER> +ACE_Cleanup_Strategy<CONTAINER>::~ACE_Cleanup_Strategy (void) { } //////////////////////////////////////////////////////////////////////////// -template <class KEY, class VALUE, class CONTAINER> int -ACE_Default_Cleanup_Strategy<KEY, VALUE, CONTAINER>::cleanup (CONTAINER &container, - KEY *key, - VALUE *value) +template <class CONTAINER> int +ACE_Default_Cleanup_Strategy<CONTAINER>::cleanup (CONTAINER &container, + KEY *key, + VALUE *value) { - ACE_UNUSED_ARG (value); - return container.unbind (*key); } //////////////////////////////////////////////////////////////////////////// -template <class KEY, class VALUE, class CONTAINER> int -ACE_Svc_Cleanup_Strategy<KEY, VALUE, CONTAINER>::cleanup (CONTAINER &container, - KEY *key, - VALUE *value) +template <class CONTAINER> int +ACE_Svc_Cleanup_Strategy<CONTAINER>::cleanup (CONTAINER &container, + KEY *key, + VALUE *value) { (value->first ())->recycler (0, 0); @@ -52,36 +50,12 @@ ACE_Svc_Cleanup_Strategy<KEY, VALUE, CONTAINER>::cleanup (CONTAINER &container, } ///////////////////////////////////////////////////////////////////////////// -template <class KEY, class VALUE, class CONTAINER> int -ACE_Handler_Cleanup_Strategy<KEY, VALUE, CONTAINER>::cleanup (CONTAINER &container, - KEY *key, - VALUE *value) -{ - // Remove the item from cache only if the handler isnt in use. - if ((*value)->active () == 0) - { - (*value)->close (); - - if (container.unbind (*key) == -1) - return -1; - - } - - return 0; -} - -//////////////////////////////////////////////////////////////////////////// -template <class KEY, class VALUE, class CONTAINER> int -ACE_Null_Cleanup_Strategy<KEY, VALUE, CONTAINER>::cleanup (CONTAINER &container, - KEY *key, - VALUE *value) +template <class CONTAINER> int +ACE_Null_Cleanup_Strategy<CONTAINER>::cleanup (CONTAINER &container, + KEY *key, + VALUE *value) { - - ACE_UNUSED_ARG (container); - ACE_UNUSED_ARG (key); - ACE_UNUSED_ARG (value); - return 0; } diff --git a/ace/Cleanup_Strategies_T.h b/ace/Cleanup_Strategies_T.h index 05e51ce29de..4cdeec27b24 100644 --- a/ace/Cleanup_Strategies_T.h +++ b/ace/Cleanup_Strategies_T.h @@ -23,7 +23,7 @@ #define ACE_LACKS_PRAGMA_ONCE #endif /* ACE_LACKS_PRAGMA_ONCE */ -template <class KEY, class VALUE, class CONTAINER> +template <class CONTAINER> class ACE_Cleanup_Strategy { // = TITLE @@ -35,7 +35,11 @@ class ACE_Cleanup_Strategy // can be decoupled from other strategies which need to do it. // The cleanup method provided needs to be implemented as needed. - public: + public: + + // Traits. + typedef ACE_TYPENAME CONTAINER::KEY KEY; + typedef ACE_TYPENAME CONTAINER::VALUE VALUE; // = Termination. @@ -51,8 +55,8 @@ class ACE_Cleanup_Strategy ////////////////////////////////////////////////////////////////////////// -template <class KEY, class VALUE, class CONTAINER> -class ACE_Default_Cleanup_Strategy : public ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> +template <class CONTAINER> +class ACE_Default_Cleanup_Strategy : public ACE_Cleanup_Strategy<CONTAINER> { // = TITLE // Defines a default strategy to be followed for cleaning up @@ -63,15 +67,15 @@ class ACE_Default_Cleanup_Strategy : public ACE_Cleanup_Strategy<KEY, VALUE, CON // container. public: - + virtual int cleanup (CONTAINER &container, KEY *key, VALUE *value); // The method which will do the cleanup of the entry in the container. }; ////////////////////////////////////////////////////////////////////// -template <class KEY, class VALUE, class CONTAINER> -class ACE_Svc_Cleanup_Strategy : public ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> +template <class CONTAINER> +class ACE_Svc_Cleanup_Strategy : public ACE_Cleanup_Strategy<CONTAINER> { // = TITLE // Defines a strategy to be followed for cleaning up @@ -80,33 +84,10 @@ class ACE_Svc_Cleanup_Strategy : public ACE_Cleanup_Strategy<KEY, VALUE, CONTAIN // = DESCRIPTION // The entry to be cleaned up is removed from the container. // Here, since we are dealing with svc_handlers specifically, we - // perform a couple of extra operations. Note: To be used when - // the handler is recyclable. + // perform a couple of extra operations. public: - - virtual int cleanup (CONTAINER &container, KEY *key, VALUE *value); - // The method which will do the cleanup of the entry in the container. - -}; -////////////////////////////////////////////////////////////////////// -template <class KEY, class VALUE, class CONTAINER> -class ACE_Handler_Cleanup_Strategy : public ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> -{ - // = TITLE - // Defines a strategy to be followed for cleaning up - // entries which are svc_handlers from a container. - // - // = DESCRIPTION - // The entry to be cleaned up is removed from the container. - // Here, since we are dealing with svc_handlers specifically, we - // perform a couple of extra operations. Note: This cleanup strategy - // should be used in the case when the handler has the caching - // attributes. - -public: - virtual int cleanup (CONTAINER &container, KEY *key, VALUE *value); // The method which will do the cleanup of the entry in the container. @@ -114,9 +95,8 @@ public: ////////////////////////////////////////////////////////////////////// - -template <class KEY, class VALUE, class CONTAINER> -class ACE_Null_Cleanup_Strategy : public ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> +template <class CONTAINER> +class ACE_Null_Cleanup_Strategy : public ACE_Cleanup_Strategy<CONTAINER> { // = TITLE // Defines a do-nothing implementation of the cleanup strategy. @@ -126,9 +106,9 @@ class ACE_Null_Cleanup_Strategy : public ACE_Cleanup_Strategy<KEY, VALUE, CONTAI // the effect of the Cleanup Strategy. public: - + virtual int cleanup (CONTAINER &container, KEY *key, VALUE *value); - // The dummy cleanup method. + // the dummy cleanup method. }; diff --git a/ace/Connector.cpp b/ace/Connector.cpp index 9761a204c1e..a0e12e99768 100644 --- a/ace/Connector.cpp +++ b/ace/Connector.cpp @@ -457,11 +457,14 @@ ACE_Connector<SH, PR_CO_2>::connect_i (SH *&sh, } else { - // Save/restore errno. - ACE_Errno_Guard error (errno); + // Make sure to save/restore the errno since <close> may + // change it. + + int error = errno; // Make sure to close down the Channel to avoid descriptor // leaks. new_sh->close (0); + errno = error; } return -1; } @@ -532,8 +535,7 @@ template <class SH, PR_CO_1> int ACE_Connector<SH, PR_CO_2>::create_AST (SH *sh, const ACE_Synch_Options &synch_options) { - // Save/restore errno. - ACE_Errno_Guard error (errno); + int error = errno; ACE_TRACE ("ACE_Connector<SH, PR_CO_2>::create_AST"); AST *ast; @@ -567,10 +569,18 @@ ACE_Connector<SH, PR_CO_2>::create_AST (SH *sh, goto fail3; ast->cancellation_id (cancellation_id); + // Reset this because something might have gone wrong + // elsewhere... + errno = error; return 0; } else - return 0; // Ok, everything worked just fine... + { + // Reset this because something might have gone wrong + // elsewhere... + errno = error; // EWOULDBLOCK + return 0; // Ok, everything worked just fine... + } } // Undo previous actions using the ol' "goto label and fallthru" diff --git a/ace/Connector.h b/ace/Connector.h index d01dc24d1e2..4f1f93a00b8 100644 --- a/ace/Connector.h +++ b/ace/Connector.h @@ -148,9 +148,7 @@ public: // <local_addr> be reused by passing a value <reuse_addr> == // 1). <flags> and <perms> can be used to pass any flags that are // needed to perform specific operations such as opening a file - // within connect with certain permissions. If the connection fails - // the <close> hook on the <svc_handler> will be called - // automatically to prevent resource leaks. + // within connect with certain permissions. virtual int connect (SVC_HANDLER *&svc_handler_hint, SVC_HANDLER *&svc_handler, @@ -161,21 +159,18 @@ public: int reuse_addr = 0, int flags = O_RDWR, int perms = 0); - // This is a variation on the previous <connect> method. On cached - // connectors the <svc_handler_hint> variable can be used as a hint - // for future lookups. Since this variable is modified in the - // context of the internal cache its use is thread-safe. But the - // actual svc_handler for the current connection is returned in the - // second parameter <svc_handler>. If the connection fails the - // <close> hook on the <svc_handler> will be called automatically to - // prevent resource leaks. + // A variation on the previous connect(), on cached connectors the + // <svc_handler_hint> variable can be used as a hint for future + // lookups. Since this variable is modified in the context of the + // internal cache its use is thread-safe. But the actual + // svc_handler for the current connection is returned in the second + // parameter <svc_handler>. virtual int connect_n (size_t n, SVC_HANDLER *svc_handlers[], ACE_PEER_CONNECTOR_ADDR remote_addrs[], ASYS_TCHAR *failed_svc_handlers = 0, - const ACE_Synch_Options &synch_options = - ACE_Synch_Options::defaults); + const ACE_Synch_Options &synch_options = ACE_Synch_Options::defaults); // Initiate connection of <n> <svc_handlers> to peers at // <remote_addrs> using <synch_options>. Returns -1 if failure // occurs and 0 otherwise. If <failed_svc_handlers> is non-NULL, a diff --git a/ace/Containers.cpp b/ace/Containers.cpp index 36730dd1b70..cdbaa32f4f9 100644 --- a/ace/Containers.cpp +++ b/ace/Containers.cpp @@ -12,13 +12,9 @@ ACE_RCSID(ace, Containers, "$Id$") #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Double_Linked_List<ACE_DLList_Node>; -template class ACE_Double_Linked_List_Iterator_Base<ACE_DLList_Node>; template class ACE_Double_Linked_List_Iterator<ACE_DLList_Node>; -template class ACE_Double_Linked_List_Reverse_Iterator<ACE_DLList_Node>; #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) #pragma instantiate ACE_Double_Linked_List<ACE_DLList_Node> -#pragma instantiate ACE_Double_Linked_List_Iterator_Base<ACE_DLList_Node> #pragma instantiate ACE_Double_Linked_List_Iterator<ACE_DLList_Node> -#pragma instantiate ACE_Double_Linked_List_Reverse_Iterator<ACE_DLList_Node> #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/ace/Containers.h b/ace/Containers.h index 7ac2230b761..eb9b107b74f 100644 --- a/ace/Containers.h +++ b/ace/Containers.h @@ -28,11 +28,7 @@ template <class T> class ACE_Double_Linked_List; template <class T> -class ACE_Double_Linked_List_Iterator_Base; -template <class T> class ACE_Double_Linked_List_Iterator; -template <class T> -class ACE_Double_Linked_List_Reverse_Iterator; class ACE_Export ACE_DLList_Node { @@ -41,9 +37,7 @@ class ACE_Export ACE_DLList_Node // ACE_Double_Linked_List. public: friend class ACE_Double_Linked_List<ACE_DLList_Node>; - friend class ACE_Double_Linked_List_Iterator_Base<ACE_DLList_Node>; friend class ACE_Double_Linked_List_Iterator<ACE_DLList_Node>; - friend class ACE_Double_Linked_List_Reverse_Iterator<ACE_DLList_Node>; ACE_DLList_Node (void *&i, ACE_DLList_Node *n = 0, diff --git a/ace/Containers_T.cpp b/ace/Containers_T.cpp index 773b7750467..15d6dda2c4b 100644 --- a/ace/Containers_T.cpp +++ b/ace/Containers_T.cpp @@ -17,10 +17,10 @@ #include "ace/Containers_T.i" #endif /* __ACE_INLINE__ */ -ACE_RCSID(ace, Containers_T, "$Id$") +ACE_RCSID(ace, Containers_T, "$Id$") ACE_ALLOC_HOOK_DEFINE(ACE_Bounded_Stack) - + template <class T> void ACE_Bounded_Stack<T>::dump (void) const { @@ -33,6 +33,7 @@ ACE_Bounded_Stack<T>::ACE_Bounded_Stack (size_t size) size_ (size) { ACE_NEW (this->stack_, T[size]); + ACE_TRACE ("ACE_Bounded_Stack<T>::ACE_Bounded_Stack"); } @@ -275,7 +276,7 @@ ACE_Unbounded_Stack<T>::pop (T &item) template <class T> int ACE_Unbounded_Stack<T>::find (const T &item) const { - // ACE_TRACE ("ACE_Unbounded_Stack<T>::find"); +// ACE_TRACE ("ACE_Unbounded_Stack<T>::find"); // Set <item> into the dummy node. this->head_->item_ = item; @@ -293,7 +294,7 @@ ACE_Unbounded_Stack<T>::find (const T &item) const template <class T> int ACE_Unbounded_Stack<T>::insert (const T &item) { - // ACE_TRACE ("ACE_Unbounded_Stack<T>::insert"); +// ACE_TRACE ("ACE_Unbounded_Stack<T>::insert"); if (this->find (item) == 0) return 1; @@ -304,7 +305,7 @@ ACE_Unbounded_Stack<T>::insert (const T &item) template <class T> int ACE_Unbounded_Stack<T>::remove (const T &item) { - // ACE_TRACE ("ACE_Unbounded_Stack<T>::remove"); +// ACE_TRACE ("ACE_Unbounded_Stack<T>::remove"); // Insert the item to be founded into the dummy node. this->head_->item_ = item; @@ -336,7 +337,7 @@ ACE_Unbounded_Queue<T>::ACE_Unbounded_Queue (ACE_Allocator *alloc) cur_size_ (0), allocator_ (alloc) { - // ACE_TRACE ("ACE_Unbounded_Queue<T>::ACE_Unbounded_Queue (void)"); +// ACE_TRACE ("ACE_Unbounded_Queue<T>::ACE_Unbounded_Queue (void)"); if (this->allocator_ == 0) this->allocator_ = ACE_Allocator::instance (); @@ -355,7 +356,7 @@ ACE_Unbounded_Queue<T>::ACE_Unbounded_Queue (const ACE_Unbounded_Queue<T> &us) cur_size_ (0), allocator_ (us.allocator_) { - // ACE_TRACE ("ACE_Unbounded_Queue<T>::ACE_Unbounded_Queue"); +// ACE_TRACE ("ACE_Unbounded_Queue<T>::ACE_Unbounded_Queue"); if (this->allocator_ == 0) this->allocator_ = ACE_Allocator::instance (); @@ -370,7 +371,7 @@ ACE_Unbounded_Queue<T>::ACE_Unbounded_Queue (const ACE_Unbounded_Queue<T> &us) template <class T> void ACE_Unbounded_Queue<T>::operator= (const ACE_Unbounded_Queue<T> &us) { - // ACE_TRACE ("ACE_Unbounded_Queue<T>::operator="); +// ACE_TRACE ("ACE_Unbounded_Queue<T>::operator="); if (this != &us) { @@ -399,7 +400,7 @@ ACE_ALLOC_HOOK_DEFINE(ACE_Unbounded_Queue) template <class T> void ACE_Unbounded_Queue<T>::dump (void) const { - // ACE_TRACE ("ACE_Unbounded_Queue<T>::dump"); +// ACE_TRACE ("ACE_Unbounded_Queue<T>::dump"); ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("\nhead_ = %u"), this->head_)); @@ -456,7 +457,7 @@ ACE_Unbounded_Queue<T>::delete_nodes (void) template <class T> ACE_Unbounded_Queue<T>::~ACE_Unbounded_Queue (void) { - // ACE_TRACE ("ACE_Unbounded_Queue<T>::~ACE_Unbounded_Queue (void)"); +// ACE_TRACE ("ACE_Unbounded_Queue<T>::~ACE_Unbounded_Queue (void)"); this->delete_nodes (); ACE_DES_FREE_TEMPLATE (head_, @@ -469,7 +470,7 @@ ACE_Unbounded_Queue<T>::~ACE_Unbounded_Queue (void) template <class T> int ACE_Unbounded_Queue<T>::enqueue_head (const T &new_item) { - // ACE_TRACE ("ACE_Unbounded_Queue<T>::enqueue_tail"); +// ACE_TRACE ("ACE_Unbounded_Queue<T>::enqueue_tail"); ACE_Node<T> *temp; @@ -489,7 +490,7 @@ ACE_Unbounded_Queue<T>::enqueue_head (const T &new_item) template <class T> int ACE_Unbounded_Queue<T>::enqueue_tail (const T &new_item) { - // ACE_TRACE ("ACE_Unbounded_Queue<T>::enqueue_head"); +// ACE_TRACE ("ACE_Unbounded_Queue<T>::enqueue_head"); ACE_Node<T> *temp; @@ -514,7 +515,7 @@ ACE_Unbounded_Queue<T>::enqueue_tail (const T &new_item) template <class T> int ACE_Unbounded_Queue<T>::dequeue_head (T &item) { - // ACE_TRACE ("ACE_Unbounded_Queue<T>::dequeue_head"); +// ACE_TRACE ("ACE_Unbounded_Queue<T>::dequeue_head"); // Check for empty queue. if (this->is_empty ()) @@ -543,7 +544,7 @@ ACE_Unbounded_Queue<T>::reset (void) template <class T> int ACE_Unbounded_Queue<T>::get (T *&item, size_t slot) const { - // ACE_TRACE ("ACE_Unbounded_Queue<T>::get"); +// ACE_TRACE ("ACE_Unbounded_Queue<T>::get"); ACE_Node<T> *curr = this->head_->next_; @@ -570,7 +571,7 @@ template <class T> int ACE_Unbounded_Queue<T>::set (const T &item, size_t slot) { - // ACE_TRACE ("ACE_Unbounded_Queue<T>::set"); +// ACE_TRACE ("ACE_Unbounded_Queue<T>::set"); ACE_Node<T> *curr = this->head_->next_; @@ -628,21 +629,21 @@ ACE_Unbounded_Queue<T>::set (const T &item, template <class T> void ACE_Unbounded_Queue_Iterator<T>::dump (void) const { - // ACE_TRACE ("ACE_Unbounded_Queue_Iterator<T>::dump"); +// ACE_TRACE ("ACE_Unbounded_Queue_Iterator<T>::dump"); } template <class T> ACE_Unbounded_Queue_Iterator<T>::ACE_Unbounded_Queue_Iterator (ACE_Unbounded_Queue<T> &q, int end) - : current_ (end == 0 ? q.head_->next_ : q.head_ ), - queue_ (q) + : current_ (end == 0 ? q.head_->next_ : q.head_ ), + queue_ (q) { - // ACE_TRACE ("ACE_Unbounded_Queue_Iterator<T>::ACE_Unbounded_Queue_Iterator"); +// ACE_TRACE ("ACE_Unbounded_Queue_Iterator<T>::ACE_Unbounded_Queue_Iterator"); } template <class T> int ACE_Unbounded_Queue_Iterator<T>::advance (void) { - // ACE_TRACE ("ACE_Unbounded_Queue_Iterator<T>::advance"); +// ACE_TRACE ("ACE_Unbounded_Queue_Iterator<T>::advance"); this->current_ = this->current_->next_; return this->current_ != this->queue_.head_; } @@ -650,7 +651,7 @@ ACE_Unbounded_Queue_Iterator<T>::advance (void) template <class T> int ACE_Unbounded_Queue_Iterator<T>::first (void) { - // ACE_TRACE ("ACE_Unbounded_Queue_Iterator<T>::first"); +// ACE_TRACE ("ACE_Unbounded_Queue_Iterator<T>::first"); this->current_ = this->queue_.head_->next_; return this->current_ != this->queue_.head_; } @@ -666,7 +667,7 @@ ACE_Unbounded_Queue_Iterator<T>::done (void) const template <class T> int ACE_Unbounded_Queue_Iterator<T>::next (T *&item) { - // ACE_TRACE ("ACE_Unbounded_Queue_Iterator<T>::next"); +// ACE_TRACE ("ACE_Unbounded_Queue_Iterator<T>::next"); if (this->current_ == this->queue_.head_) return 0; else @@ -677,84 +678,26 @@ ACE_Unbounded_Queue_Iterator<T>::next (T *&item) } //-------------------------------------------------- -ACE_ALLOC_HOOK_DEFINE(ACE_Double_Linked_List_Iterator_Base) - -template <class T> -ACE_Double_Linked_List_Iterator_Base<T>::ACE_Double_Linked_List_Iterator_Base (ACE_Double_Linked_List<T> &dll) - : current_ (0), dllist_ (&dll) -{ - // Do nothing -} +ACE_ALLOC_HOOK_DEFINE(ACE_Double_Linked_List_Iterator) template <class T> -ACE_Double_Linked_List_Iterator_Base<T>::ACE_Double_Linked_List_Iterator_Base (const ACE_Double_Linked_List_Iterator_Base<T> &iter) - : current_ (iter.current_), - dllist_ (iter.dllist_) -{ - // Do nothing -} - - -template <class T> T * -ACE_Double_Linked_List_Iterator_Base<T>::next (void) const -{ - return this->not_done (); -} - -template <class T> int -ACE_Double_Linked_List_Iterator_Base<T>::next (T *&ptr) const -{ - ptr = this->not_done (); - return ptr ? 1 : 0; -} - - -template <class T> int -ACE_Double_Linked_List_Iterator_Base<T>::done (void) const -{ - return this->not_done () ? 0 : 1; -} - -template <class T> T & -ACE_Double_Linked_List_Iterator_Base<T>::operator* (void) const -{ - return *(this->not_done ()); -} - -// @@ Is this a valid retasking? Make sure to check with Purify and -// whatnot that we're not leaking memory or doing any other screwing things. -template <class T> void -ACE_Double_Linked_List_Iterator_Base<T>::reset (ACE_Double_Linked_List<T> &dll) -{ - current_ = 0; - dllist_ = &dll; -} - - template <class T> int -ACE_Double_Linked_List_Iterator_Base<T>::go_head (void) -{ - this->current_ = ACE_static_cast (T*, dllist_->head_->next_); - return this->current_ ? 1 : 0; -} - -template <class T> int -ACE_Double_Linked_List_Iterator_Base<T>::go_tail (void) +ACE_Double_Linked_List_Iterator<T>::ACE_Double_Linked_List_Iterator (ACE_Double_Linked_List<T> &dll) + : dllist_ (dll) { - this->current_ = ACE_static_cast (T*, dllist_->head_->prev_); - return this->current_ ? 1 : 0; + this->current_ = ACE_static_cast (T*, dll.head_->next_); // Initialize head ptr. } template <class T> T * -ACE_Double_Linked_List_Iterator_Base<T>::not_done (void) const +ACE_Double_Linked_List_Iterator<T>::not_done (void) const { - if (this->current_ != this->dllist_->head_) + if (this->current_ != this->dllist_.head_) return this->current_; else return 0; } template <class T> T * -ACE_Double_Linked_List_Iterator_Base<T>::do_advance (void) +ACE_Double_Linked_List_Iterator<T>::do_advance (void) { if (this->not_done ()) { @@ -766,41 +709,9 @@ ACE_Double_Linked_List_Iterator_Base<T>::do_advance (void) } template <class T> T * -ACE_Double_Linked_List_Iterator_Base<T>::do_retreat (void) -{ - if (this->not_done ()) - { - this->current_ = ACE_static_cast (T*, this->current_->prev_); - return this->not_done (); - } - else - return 0; -} - -template <class T> void -ACE_Double_Linked_List_Iterator_Base<T>::dump_i (void) const +ACE_Double_Linked_List_Iterator<T>::next (void) const { - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("current_ = %x"), this->current_)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -} - -//-------------------------------------------------- -ACE_ALLOC_HOOK_DEFINE(ACE_Double_Linked_List_Iterator) - -template <class T> -ACE_Double_Linked_List_Iterator<T>::ACE_Double_Linked_List_Iterator (ACE_Double_Linked_List<T> &dll) - : ACE_Double_Linked_List_Iterator_Base <T> (dll) -{ - this->current_ = ACE_static_cast (T*, dll.head_->next_); - // Advance current_ out of the null area and onto the first item in - // the list -} - -template <class T> int -ACE_Double_Linked_List_Iterator<T>::first (void) -{ - return this->go_head (); + return this->not_done (); } template <class T> int @@ -809,167 +720,28 @@ ACE_Double_Linked_List_Iterator<T>::advance (void) return this->do_advance () ? 1 : 0; } -template <class T> T* -ACE_Double_Linked_List_Iterator<T>::advance_and_remove (int dont_remove) -{ - T* item = 0; - if (dont_remove) - this->do_advance (); - else - { - item = this->next (); - this->do_advance (); - dllist_->remove (item); - } - return item; -} - -template <class T> void -ACE_Double_Linked_List_Iterator<T>::dump (void) const -{ - this->dump_i (); -} - -// Prefix advance. - -template <class T> -ACE_Double_Linked_List_Iterator<T> & -ACE_Double_Linked_List_Iterator<T>::operator++ (void) -{ - this->do_advance (); - return *this; -} - - -// Postfix advance. - -template <class T> -ACE_Double_Linked_List_Iterator<T> -ACE_Double_Linked_List_Iterator<T>::operator++ (int) -{ - ACE_Double_Linked_List_Iterator<T> retv (*this); - this->do_advance (); - return retv; -} - - -// Prefix reverse. - -template <class T> -ACE_Double_Linked_List_Iterator<T> & -ACE_Double_Linked_List_Iterator<T>::operator-- (void) -{ - this->do_retreat (); - return *this; -} - - -// Postfix reverse. - -template <class T> -ACE_Double_Linked_List_Iterator<T> -ACE_Double_Linked_List_Iterator<T>::operator-- (int) -{ - ACE_Double_Linked_List_Iterator<T> retv (*this); - this->do_retreat (); - return retv; -} - - -//-------------------------------------------------- -ACE_ALLOC_HOOK_DEFINE(ACE_Double_Linked_List_Reverse_Iterator) - - template <class T> -ACE_Double_Linked_List_Reverse_Iterator<T>::ACE_Double_Linked_List_Reverse_Iterator (ACE_Double_Linked_List<T> &dll) - : ACE_Double_Linked_List_Iterator_Base <T> (dll) -{ - this->current_ = ACE_static_cast (T*, dll.head_->prev_); - // Advance current_ out of the null area and onto the last item in - // the list -} - template <class T> int -ACE_Double_Linked_List_Reverse_Iterator<T>::first (void) +ACE_Double_Linked_List_Iterator<T>::first (void) { - return this->go_tail (); + this->current_ = ACE_static_cast (T*, dllist_.head_->next_); + return this->not_done () ? 1 : 0; } template <class T> int -ACE_Double_Linked_List_Reverse_Iterator<T>::advance (void) -{ - return this->do_retreat () ? 1 : 0; -} - -template <class T> T* -ACE_Double_Linked_List_Reverse_Iterator<T>::advance_and_remove (int dont_remove) +ACE_Double_Linked_List_Iterator<T>::done (void) const { - T* item = 0; - if (dont_remove) - this->do_retreat (); - else - { - item = this->next (); - this->do_retreat (); - dllist_->remove (item); - } - return item; + return this->not_done () ? 0 : 1; } template <class T> void -ACE_Double_Linked_List_Reverse_Iterator<T>::dump (void) const -{ - this->dump_i (); -} - -// Prefix advance. - -template <class T> -ACE_Double_Linked_List_Reverse_Iterator<T> & -ACE_Double_Linked_List_Reverse_Iterator<T>::operator++ (void) -{ - this->do_retreat (); - return *this; -} - - -// Postfix advance. - -template <class T> -ACE_Double_Linked_List_Reverse_Iterator<T> -ACE_Double_Linked_List_Reverse_Iterator<T>::operator++ (int) -{ - ACE_Double_Linked_List_Reverse_Iterator<T> retv (*this); - this->do_retreat (); - return retv; -} - - -// Prefix reverse. - -template <class T> -ACE_Double_Linked_List_Reverse_Iterator<T> & -ACE_Double_Linked_List_Reverse_Iterator<T>::operator-- (void) +ACE_Double_Linked_List_Iterator<T>::dump (void) const { - this->do_advance (); - return *this; + // Dump the state of an object. } - -// Postfix reverse. +ACE_ALLOC_HOOK_DEFINE(ACE_Double_Linked_List) template <class T> -ACE_Double_Linked_List_Reverse_Iterator<T> -ACE_Double_Linked_List_Reverse_Iterator<T>::operator-- (int) -{ - ACE_Double_Linked_List_Reverse_Iterator<T> retv (*this); - this->do_advance (); - return retv; -} - - -ACE_ALLOC_HOOK_DEFINE(ACE_Double_Linked_List) - - template <class T> ACE_Double_Linked_List<T>:: ACE_Double_Linked_List (ACE_Allocator *alloc) : size_ (0), allocator_ (alloc) { @@ -1131,7 +903,7 @@ ACE_Double_Linked_List<T>::remove (const T &item) T *temp = this->find (item); if (temp != 0) - return this->remove (temp); + return this->remove (temp); else return -1; } @@ -1210,7 +982,7 @@ ACE_Double_Linked_List<T>::remove_element (T *item) ACE_ALLOC_HOOK_DEFINE(ACE_Fixed_Set) - template <class T, size_t ACE_SIZE> size_t +template <class T, size_t ACE_SIZE> size_t ACE_Fixed_Set<T, ACE_SIZE>::size (void) const { return this->cur_size_; @@ -1307,7 +1079,7 @@ ACE_Fixed_Set<T, ACE_SIZE>::insert (const T &item) this->search_structure_[first_free].is_free_ = 0; return 0; } - // Insert at the end of the active portion. + // Insert at the end of the active portion. else if (i < this->max_size_) { this->search_structure_[i].item_ = item; @@ -1355,7 +1127,7 @@ ACE_Fixed_Set<T, ACE_SIZE>::remove (const T &item) ACE_ALLOC_HOOK_DEFINE(ACE_Fixed_Set_Iterator) - template <class T, size_t ACE_SIZE> void +template <class T, size_t ACE_SIZE> void ACE_Fixed_Set_Iterator<T, ACE_SIZE>::dump (void) const { ACE_TRACE ("ACE_Fixed_Set_Iterator<T, ACE_SIZE>::dump"); @@ -1377,7 +1149,7 @@ ACE_Fixed_Set_Iterator<T, ACE_SIZE>::advance (void) for (++this->next_; ACE_static_cast(size_t, this->next_) < this->s_.cur_size_ - && this->s_.search_structure_[this->next_].is_free_; + && this->s_.search_structure_[this->next_].is_free_; ++this->next_) continue; @@ -1417,7 +1189,7 @@ ACE_Fixed_Set_Iterator<T, ACE_SIZE>::next (T *&item) ACE_ALLOC_HOOK_DEFINE(ACE_Bounded_Set) - template <class T> void +template <class T> void ACE_Bounded_Set<T>::dump (void) const { ACE_TRACE ("ACE_Bounded_Set<T>::dump"); @@ -1438,7 +1210,7 @@ ACE_Bounded_Set<T>::ACE_Bounded_Set (void) ACE_TRACE ("ACE_Bounded_Set<T>::ACE_Bounded_Set"); ACE_NEW (this->search_structure_, - ACE_TYPENAME ACE_Bounded_Set<T>::Search_Structure[this->max_size_]); + ACE_Bounded_Set<T>::Search_Structure[this->max_size_]); for (size_t i = 0; i < this->max_size_; i++) this->search_structure_[i].is_free_ = 1; @@ -1452,7 +1224,7 @@ ACE_Bounded_Set<T>::ACE_Bounded_Set (const ACE_Bounded_Set<T> &bs) ACE_TRACE ("ACE_Bounded_Set<T>::ACE_Bounded_Set"); ACE_NEW (this->search_structure_, - ACE_TYPENAME ACE_Bounded_Set<T>::Search_Structure[this->max_size_]); + ACE_Bounded_Set<T>::Search_Structure[this->max_size_]); for (size_t i = 0; i < this->cur_size_; i++) this->search_structure_[i] = bs.search_structure_[i]; @@ -1468,7 +1240,7 @@ ACE_Bounded_Set<T>::operator= (const ACE_Bounded_Set<T> &bs) if (this->max_size_ < bs.cur_size_) { delete [] this->search_structure_; - ACE_NEW (this->search_structure_, ACE_TYPENAME + ACE_NEW (this->search_structure_, ACE_Bounded_Set<T>::Search_Structure[bs.cur_size_]); this->max_size_ = bs.cur_size_; } @@ -1487,7 +1259,7 @@ ACE_Bounded_Set<T>::ACE_Bounded_Set (size_t size) { ACE_TRACE ("ACE_Bounded_Set<T>::ACE_Bounded_Set"); ACE_NEW (this->search_structure_, - ACE_TYPENAME ACE_Bounded_Set<T>::Search_Structure[size]); + ACE_Bounded_Set<T>::Search_Structure[size]); for (size_t i = 0; i < this->max_size_; i++) this->search_structure_[i].is_free_ = 1; @@ -1571,7 +1343,7 @@ ACE_Bounded_Set<T>::remove (const T &item) } #if defined (__Lynx__) -// LynxOS 3.0.0 native g++ compiler raises internal error with this inline. + // LynxOS 3.0.0 native g++ compiler raises internal error with this inline. template <class T> int ACE_Bounded_Set<T>::is_full (void) const { @@ -1582,7 +1354,7 @@ ACE_Bounded_Set<T>::is_full (void) const ACE_ALLOC_HOOK_DEFINE(ACE_Bounded_Set_Iterator) - template <class T> void +template <class T> void ACE_Bounded_Set_Iterator<T>::dump (void) const { ACE_TRACE ("ACE_Bounded_Set_Iterator<T>::dump"); @@ -1604,13 +1376,28 @@ ACE_Bounded_Set_Iterator<T>::advance (void) for (++this->next_; ACE_static_cast(size_t, this->next_) < this->s_.cur_size_ - && this->s_.search_structure_[this->next_].is_free_; + && this->s_.search_structure_[this->next_].is_free_; ++this->next_) continue; return ACE_static_cast(size_t, this->next_) < this->s_.cur_size_; } +template <class T> T* +ACE_Double_Linked_List_Iterator<T>::advance_and_remove (int dont_remove) +{ + T* item = 0; + if (dont_remove) + this->do_advance (); + else + { + item = this->next (); + this->do_advance (); + this->dllist_.remove_element (item); + } + return item; +} + template <class T> int ACE_Bounded_Set_Iterator<T>::first (void) { @@ -1645,7 +1432,7 @@ ACE_Bounded_Set_Iterator<T>::next (T *&item) ACE_ALLOC_HOOK_DEFINE(ACE_Node) # if ! defined (ACE_HAS_BROKEN_NOOP_DTORS) - template <class T> +template <class T> ACE_Node<T>::~ACE_Node (void) { } @@ -1656,14 +1443,14 @@ ACE_Node<T>::ACE_Node (const T &i, ACE_Node<T> *n) : next_ (n), item_ (i) { - // ACE_TRACE ("ACE_Node<T>::ACE_Node"); +// ACE_TRACE ("ACE_Node<T>::ACE_Node"); } template <class T> ACE_Node<T>::ACE_Node (ACE_Node<T> *n, int) : next_ (n) { - // ACE_TRACE ("ACE_Node<T>::ACE_Node"); +// ACE_TRACE ("ACE_Node<T>::ACE_Node"); } template <class T> @@ -1671,12 +1458,12 @@ ACE_Node<T>::ACE_Node (const ACE_Node<T> &s) : next_ (s.next_), item_ (s.item_) { - // ACE_TRACE ("ACE_Node<T>::ACE_Node"); +// ACE_TRACE ("ACE_Node<T>::ACE_Node"); } ACE_ALLOC_HOOK_DEFINE(ACE_DNode) - template <class T> +template <class T> ACE_DNode<T>::ACE_DNode (const T &i, ACE_DNode<T> *n, ACE_DNode<T> *p) : next_ (n), prev_ (p), item_ (i) { @@ -1691,17 +1478,17 @@ ACE_DNode<T>::~ACE_DNode (void) ACE_ALLOC_HOOK_DEFINE(ACE_Unbounded_Set) - template <class T> size_t +template <class T> size_t ACE_Unbounded_Set<T>::size (void) const { - // ACE_TRACE ("ACE_Unbounded_Set<T>::size"); +// ACE_TRACE ("ACE_Unbounded_Set<T>::size"); return this->cur_size_; } template <class T> int ACE_Unbounded_Set<T>::insert_tail (const T &item) { - // ACE_TRACE ("ACE_Unbounded_Queue<T>::insert_tail"); +// ACE_TRACE ("ACE_Unbounded_Queue<T>::insert_tail"); ACE_Node<T> *temp; // Insert <item> into the old dummy node location. @@ -1788,7 +1575,7 @@ ACE_Unbounded_Set<T>::delete_nodes (void) template <class T> ACE_Unbounded_Set<T>::~ACE_Unbounded_Set (void) { - // ACE_TRACE ("ACE_Unbounded_Set<T>::~ACE_Unbounded_Set"); +// ACE_TRACE ("ACE_Unbounded_Set<T>::~ACE_Unbounded_Set"); this->delete_nodes (); @@ -1806,7 +1593,7 @@ ACE_Unbounded_Set<T>::ACE_Unbounded_Set (ACE_Allocator *alloc) cur_size_ (0), allocator_ (alloc) { - // ACE_TRACE ("ACE_Unbounded_Set<T>::ACE_Unbounded_Set"); +// ACE_TRACE ("ACE_Unbounded_Set<T>::ACE_Unbounded_Set"); if (this->allocator_ == 0) this->allocator_ = ACE_Allocator::instance (); @@ -1852,7 +1639,7 @@ ACE_Unbounded_Set<T>::operator= (const ACE_Unbounded_Set<T> &us) template <class T> int ACE_Unbounded_Set<T>::find (const T &item) const { - // ACE_TRACE ("ACE_Unbounded_Stack<T>::find"); +// ACE_TRACE ("ACE_Unbounded_Stack<T>::find"); // Set <item> into the dummy node. this->head_->item_ = item; @@ -1870,7 +1657,7 @@ ACE_Unbounded_Set<T>::find (const T &item) const template <class T> int ACE_Unbounded_Set<T>::insert (const T &item) { - // ACE_TRACE ("ACE_Unbounded_Set<T>::insert"); +// ACE_TRACE ("ACE_Unbounded_Set<T>::insert"); if (this->find (item) == 0) return 1; else @@ -1880,7 +1667,7 @@ ACE_Unbounded_Set<T>::insert (const T &item) template <class T> int ACE_Unbounded_Set<T>::remove (const T &item) { - // ACE_TRACE ("ACE_Unbounded_Set<T>::remove"); +// ACE_TRACE ("ACE_Unbounded_Set<T>::remove"); // Insert the item to be founded into the dummy node. this->head_->item_ = item; @@ -1923,24 +1710,24 @@ ACE_Unbounded_Set<T>::end (void) ACE_ALLOC_HOOK_DEFINE(ACE_Unbounded_Set_Iterator) - template <class T> void +template <class T> void ACE_Unbounded_Set_Iterator<T>::dump (void) const { - // ACE_TRACE ("ACE_Unbounded_Set_Iterator<T>::dump"); +// ACE_TRACE ("ACE_Unbounded_Set_Iterator<T>::dump"); } template <class T> ACE_Unbounded_Set_Iterator<T>::ACE_Unbounded_Set_Iterator (ACE_Unbounded_Set<T> &s, int end) - : current_ (end == 0 ? s.head_->next_ : s.head_ ), - set_ (&s) + : current_ (end == 0 ? s.head_->next_ : s.head_ ), + set_ (&s) { - // ACE_TRACE ("ACE_Unbounded_Set_Iterator<T>::ACE_Unbounded_Set_Iterator"); +// ACE_TRACE ("ACE_Unbounded_Set_Iterator<T>::ACE_Unbounded_Set_Iterator"); } template <class T> int ACE_Unbounded_Set_Iterator<T>::advance (void) { - // ACE_TRACE ("ACE_Unbounded_Set_Iterator<T>::advance"); +// ACE_TRACE ("ACE_Unbounded_Set_Iterator<T>::advance"); this->current_ = this->current_->next_; return this->current_ != this->set_->head_; } @@ -1948,7 +1735,7 @@ ACE_Unbounded_Set_Iterator<T>::advance (void) template <class T> int ACE_Unbounded_Set_Iterator<T>::first (void) { - // ACE_TRACE ("ACE_Unbounded_Set_Iterator<T>::first"); +// ACE_TRACE ("ACE_Unbounded_Set_Iterator<T>::first"); this->current_ = this->set_->head_->next_; return this->current_ != this->set_->head_; } @@ -1964,7 +1751,7 @@ ACE_Unbounded_Set_Iterator<T>::done (void) const template <class T> int ACE_Unbounded_Set_Iterator<T>::next (T *&item) { - // ACE_TRACE ("ACE_Unbounded_Set_Iterator<T>::next"); +// ACE_TRACE ("ACE_Unbounded_Set_Iterator<T>::next"); if (this->current_ == this->set_->head_) return 0; else @@ -2027,21 +1814,21 @@ ACE_Unbounded_Set_Iterator<T>::operator!= (const ACE_Unbounded_Set_Iterator<T> & template <class T> void ACE_Unbounded_Stack_Iterator<T>::dump (void) const { - // ACE_TRACE ("ACE_Unbounded_Stack_Iterator<T>::dump"); +// ACE_TRACE ("ACE_Unbounded_Stack_Iterator<T>::dump"); } template <class T> ACE_Unbounded_Stack_Iterator<T>::ACE_Unbounded_Stack_Iterator (ACE_Unbounded_Stack<T> &q) - : current_ (q.head_->next_), - stack_ (q) + : current_ (q.head_->next_), + stack_ (q) { - // ACE_TRACE ("ACE_Unbounded_Stack_Iterator<T>::ACE_Unbounded_Stack_Iterator"); +// ACE_TRACE ("ACE_Unbounded_Stack_Iterator<T>::ACE_Unbounded_Stack_Iterator"); } template <class T> int ACE_Unbounded_Stack_Iterator<T>::advance (void) { - // ACE_TRACE ("ACE_Unbounded_Stack_Iterator<T>::advance"); +// ACE_TRACE ("ACE_Unbounded_Stack_Iterator<T>::advance"); this->current_ = this->current_->next_; return this->current_ != this->stack_.head_; } @@ -2049,7 +1836,7 @@ ACE_Unbounded_Stack_Iterator<T>::advance (void) template <class T> int ACE_Unbounded_Stack_Iterator<T>::first (void) { - // ACE_TRACE ("ACE_Unbounded_Stack_Iterator<T>::first"); +// ACE_TRACE ("ACE_Unbounded_Stack_Iterator<T>::first"); this->current_ = this->stack_.head_->next_; return this->current_ != this->stack_.head_; } @@ -2065,7 +1852,7 @@ ACE_Unbounded_Stack_Iterator<T>::done (void) const template <class T> int ACE_Unbounded_Stack_Iterator<T>::next (T *&item) { - // ACE_TRACE ("ACE_Unbounded_Stack_Iterator<T>::next"); +// ACE_TRACE ("ACE_Unbounded_Stack_Iterator<T>::next"); if (this->current_ == this->stack_.head_) return 0; else @@ -2079,14 +1866,14 @@ ACE_Unbounded_Stack_Iterator<T>::next (T *&item) ACE_ALLOC_HOOK_DEFINE(ACE_Ordered_MultiSet) - template <class T> +template <class T> ACE_Ordered_MultiSet<T>::ACE_Ordered_MultiSet (ACE_Allocator *alloc) : head_ (0) , tail_ (0) , cur_size_ (0) , allocator_ (alloc) { - // ACE_TRACE ("ACE_Ordered_MultiSet<T>::ACE_Ordered_MultiSet"); +// ACE_TRACE ("ACE_Ordered_MultiSet<T>::ACE_Ordered_MultiSet"); if (this->allocator_ == 0) this->allocator_ = ACE_Allocator::instance (); @@ -2110,7 +1897,7 @@ ACE_Ordered_MultiSet<T>::ACE_Ordered_MultiSet (const ACE_Ordered_MultiSet<T> &us template <class T> ACE_Ordered_MultiSet<T>::~ACE_Ordered_MultiSet (void) { - // ACE_TRACE ("ACE_Ordered_MultiSet<T>::~ACE_Ordered_MultiSet"); +// ACE_TRACE ("ACE_Ordered_MultiSet<T>::~ACE_Ordered_MultiSet"); this->delete_nodes (); } @@ -2132,7 +1919,7 @@ ACE_Ordered_MultiSet<T>::operator= (const ACE_Ordered_MultiSet<T> &us) template <class T> int ACE_Ordered_MultiSet<T>::insert (const T &item) { - // ACE_TRACE ("ACE_Ordered_MultiSet<T>::insert"); +// ACE_TRACE ("ACE_Ordered_MultiSet<T>::insert"); return this->insert_from (item, this->head_, 0); } @@ -2141,7 +1928,7 @@ template <class T> int ACE_Ordered_MultiSet<T>::insert (const T &item, ACE_Ordered_MultiSet_Iterator<T> &iter) { - // ACE_TRACE ("ACE_Ordered_MultiSet<T>::insert using iterator"); +// ACE_TRACE ("ACE_Ordered_MultiSet<T>::insert using iterator"); return this->insert_from (item, iter.current_, &iter.current_); } @@ -2149,7 +1936,7 @@ ACE_Ordered_MultiSet<T>::insert (const T &item, template <class T> int ACE_Ordered_MultiSet<T>::remove (const T &item) { - // ACE_TRACE ("ACE_Ordered_MultiSet<T>::remove"); +// ACE_TRACE ("ACE_Ordered_MultiSet<T>::remove"); ACE_DNode<T> *node = 0; @@ -2157,33 +1944,33 @@ ACE_Ordered_MultiSet<T>::remove (const T &item) // if we found the node, remove from list and free it if (node && (result == 0)) + { + if (node->prev_) { - if (node->prev_) - { - node->prev_->next_ = node->next_; - } - else - { - head_ = node->next_; - } + node->prev_->next_ = node->next_; + } + else + { + head_ = node->next_; + } - if (node->next_) - { - node->next_->prev_ = node->prev_; - } - else - { - tail_ = node->prev_; - } + if (node->next_) + { + node->next_->prev_ = node->prev_; + } + else + { + tail_ = node->prev_; + } - this->cur_size_--; + this->cur_size_--; - ACE_DES_FREE_TEMPLATE (node, - this->allocator_->free, - ACE_DNode, - <T>); - return 0; - } + ACE_DES_FREE_TEMPLATE (node, + this->allocator_->free, + ACE_DNode, + <T>); + return 0; + } return -1; } @@ -2198,10 +1985,10 @@ ACE_Ordered_MultiSet<T>::find (const T &item, // if we found the node, update the iterator and indicate success if (node && (result == 0)) - { - iter.current_ = node; - return 0; - } + { + iter.current_ = node; + return 0; + } return -1; } @@ -2219,31 +2006,31 @@ ACE_Ordered_MultiSet<T>::reset (void) template <class T> void ACE_Ordered_MultiSet<T>::dump (void) const { - // ACE_TRACE ("ACE_Ordered_MultiSet<T>::dump"); - // - // ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - // ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("\nhead_ = %u"), this->head_)); - // ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("\nhead_->next_ = %u"), this->head_->next_)); - // ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("\ncur_size_ = %d\n"), this->cur_size_)); - // - // T *item = 0; - // size_t count = 1; - // - // for (ACE_Ordered_MultiSet_Iterator<T> iter (*(ACE_Ordered_MultiSet<T> *) this); - // iter.next (item) != 0; - // iter.advance ()) - // ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("count = %d\n"), count++)); - // - // ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +// ACE_TRACE ("ACE_Ordered_MultiSet<T>::dump"); +// +// ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); +// ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("\nhead_ = %u"), this->head_)); +// ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("\nhead_->next_ = %u"), this->head_->next_)); +// ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("\ncur_size_ = %d\n"), this->cur_size_)); +// +// T *item = 0; +// size_t count = 1; +// +// for (ACE_Ordered_MultiSet_Iterator<T> iter (*(ACE_Ordered_MultiSet<T> *) this); +// iter.next (item) != 0; +// iter.advance ()) +// ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("count = %d\n"), count++)); +// +// ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } template <class T> int ACE_Ordered_MultiSet<T>::insert_from (const T &item, ACE_DNode<T> *position, ACE_DNode<T> **new_position) { - // ACE_TRACE ("ACE_Unbounded_Queue<T>::insert_tail"); +// ACE_TRACE ("ACE_Unbounded_Queue<T>::insert_tail"); - // create a new node + // create a new node ACE_DNode<T> *temp; ACE_NEW_MALLOC_RETURN (temp, (ACE_DNode<T>*) this->allocator_->malloc (sizeof (ACE_DNode<T>)), @@ -2255,70 +2042,70 @@ ACE_Ordered_MultiSet<T>::insert_from (const T &item, ACE_DNode<T> *position, // if there are nodes in the multiset if (position) + { + switch (result) { - switch (result) - { - // insert after the approximate position - case -1: + // insert after the approximate position + case -1: - // if there is a following node - if (position->next_) - { - // link up with the following node - position->next_->prev_ = temp; - temp->next_ = position->next_; - } - else - { - // appending to the end of the set - tail_ = temp; - } - - // link up with the preceeding node - temp->prev_ = position; - position->next_ = temp; + // if there is a following node + if (position->next_) + { + // link up with the following node + position->next_->prev_ = temp; + temp->next_ = position->next_; + } + else + { + // appending to the end of the set + tail_ = temp; + } - break; + // link up with the preceeding node + temp->prev_ = position; + position->next_ = temp; - // insert before the position - case 0: - case 1: + break; - // if there is a preceeding node - if (position->prev_) - { - // link up with the preceeding node - position->prev_->next_ = temp; - temp->prev_ = position->prev_; - } - else - { - // prepending to the start of the set - head_ = temp; - } + // insert before the position + case 0: + case 1: + // if there is a preceeding node + if (position->prev_) + { // link up with the preceeding node - temp->next_ = position; - position->prev_ = temp; + position->prev_->next_ = temp; + temp->prev_ = position->prev_; + } + else + { + // prepending to the start of the set + head_ = temp; + } - break; + // link up with the preceeding node + temp->next_ = position; + position->prev_ = temp; - default: - return -1; - } + break; + + default: + return -1; } + } else - { - // point the head and tail to the new node. - this->head_ = temp; - this->tail_ = temp; - } + { + // point the head and tail to the new node. + this->head_ = temp; + this->tail_ = temp; + } this->cur_size_++; if (new_position) - { - *new_position = temp; - } + { + *new_position = temp; + } return 0; } @@ -2328,56 +2115,56 @@ ACE_Ordered_MultiSet<T>::locate (const T &item, ACE_DNode<T> *start_position, ACE_DNode<T> *&new_position) const { if (! start_position) - { - start_position = this->head_; - } + { + start_position = this->head_; + } // if starting before the item, move forward // until at or just before item while (start_position && start_position->item_ < item && start_position->next_) - { - start_position = start_position->next_; - } + { + start_position = start_position->next_; + } // if starting after the item, move back // until at or just after item while (start_position && item < start_position->item_ && start_position->prev_) - { - start_position = start_position->prev_; - } + { + start_position = start_position->prev_; + } // save the (approximate) location in the passed pointer new_position = start_position; // show the location is after (1), before (-1) , or at (0) the item if (! new_position ) - { - return 1; - } + { + return 1; + } else if (item < new_position->item_) - { - return 1; - } + { + return 1; + } else if (new_position->item_ < item) - { - return -1; - } + { + return -1; + } else - { - return 0; - } -} -// looks for first occurance of <item> in the ordered set, using the -// passed starting position as a hint: if there is such an instance, it -// updates the new_position pointer to point to one such node and returns 0; -// if there is no such node, then if there is a node before where the -// item would have been, it updates the new_position pointer to point -// to this node and returns -1; if there is no such node, then if there -// is a node after where the item would have been, it updates the -// new_position pointer to point to this node (or 0 if there is no such -// node) and returns 1; + { + return 0; + } +} + // looks for first occurance of <item> in the ordered set, using the + // passed starting position as a hint: if there is such an instance, it + // updates the new_position pointer to point to one such node and returns 0; + // if there is no such node, then if there is a node before where the + // item would have been, it updates the new_position pointer to point + // to this node and returns -1; if there is no such node, then if there + // is a node after where the item would have been, it updates the + // new_position pointer to point to this node (or 0 if there is no such + // node) and returns 1; template <class T> void ACE_Ordered_MultiSet<T>::copy_nodes (const ACE_Ordered_MultiSet<T> &us) @@ -2387,9 +2174,9 @@ ACE_Ordered_MultiSet<T>::copy_nodes (const ACE_Ordered_MultiSet<T> &us) for (ACE_DNode<T> *curr = us.head_; curr; curr = curr->next_) - { - this->insert_from (curr->item_, insertion_point, &insertion_point); - } + { + this->insert_from (curr->item_, insertion_point, &insertion_point); + } } template <class T> void @@ -2415,30 +2202,30 @@ ACE_Ordered_MultiSet<T>::delete_nodes (void) ACE_ALLOC_HOOK_DEFINE(ACE_Ordered_MultiSet_Iterator) - template <class T> +template <class T> ACE_Ordered_MultiSet_Iterator<T>::ACE_Ordered_MultiSet_Iterator (ACE_Ordered_MultiSet<T> &s) - : current_ (s.head_), - set_ (s) + : current_ (s.head_), + set_ (s) { - // ACE_TRACE ("ACE_Ordered_MultiSet_Iterator<T>::ACE_Ordered_MultiSet_Iterator"); +// ACE_TRACE ("ACE_Ordered_MultiSet_Iterator<T>::ACE_Ordered_MultiSet_Iterator"); } -template <class T> int + template <class T> int ACE_Ordered_MultiSet_Iterator<T>::next (T *&item) const { - // ACE_TRACE ("ACE_Ordered_MultiSet_Iterator<T>::next"); +// ACE_TRACE ("ACE_Ordered_MultiSet_Iterator<T>::next"); if (this->current_) - { - item = &this->current_->item_; - return 1; - } + { + item = &this->current_->item_; + return 1; + } return 0; } ACE_ALLOC_HOOK_DEFINE (ACE_DLList_Node) - template <class T> T * +template <class T> T * ACE_DLList<T>::insert_tail (T *new_item) { ACE_DLList_Node *temp1, *temp2; @@ -2456,9 +2243,9 @@ ACE_DLList<T>::insert_head (T *new_item) { ACE_DLList_Node *temp1, *temp2; ACE_NEW_MALLOC_RETURN ( - temp1, - (ACE_DLList_Node *) this->allocator_->malloc (sizeof (ACE_DLList_Node)), - ACE_DLList_Node ((void *&)new_item), 0); + temp1, + (ACE_DLList_Node *) this->allocator_->malloc (sizeof (ACE_DLList_Node)), + ACE_DLList_Node ((void *&)new_item), 0); temp2 = ACE_DLList_Base::insert_head (temp1); return (T *) (temp2 ? temp2->item_ : 0); @@ -2541,9 +2328,9 @@ ACE_Array_Base<T>::ACE_Array_Base (size_t size, template <class T> ACE_Array_Base<T>::ACE_Array_Base (const ACE_Array_Base<T> &s) - : max_size_ (s.size ()), - cur_size_ (s.size ()), - allocator_ (s.allocator_) + : max_size_ (s.size ()), + cur_size_ (s.size ()), + allocator_ (s.allocator_) { if (this->allocator_ == 0) this->allocator_ = ACE_Allocator::instance (); @@ -2604,15 +2391,15 @@ ACE_Array_Base<T>::set (const T &new_item, size_t slot) template <class T> int ACE_Array_Base<T>::get (T &item, size_t slot) const { - if (this->in_range (slot)) - { - // Copies the item. If you don't want to copy, use operator [] - // instead (but then you'll be responsible for range checking). - item = this->array_[slot]; - return 0; - } - else - return -1; + if (this->in_range (slot)) + { + // Copies the item. If you don't want to copy, use operator [] + // instead (but then you'll be responsible for range checking). + item = this->array_[slot]; + return 0; + } + else + return -1; } template<class T> int @@ -2628,7 +2415,7 @@ ACE_Array_Base<T>::max_size (size_t new_size) -1); for (size_t i = 0; i < this->cur_size_; ++i) - new (&tmp[i]) T (this->array_[i]); + new (&tmp[i]) T (this->array_[i]); // Initialize the new portion of the array that exceeds the // previously allocated section. diff --git a/ace/Containers_T.h b/ace/Containers_T.h index eca8af5e6df..f03482c4daa 100644 --- a/ace/Containers_T.h +++ b/ace/Containers_T.h @@ -42,6 +42,7 @@ public: ACE_Bounded_Stack (size_t size); // Initialize a new stack so that it is empty. + ACE_Bounded_Stack (const ACE_Bounded_Stack<T> &s); // The copy constructor (performs initialization). @@ -49,7 +50,7 @@ public: // Assignment operator (performs assignment). ~ACE_Bounded_Stack (void); - // Perform actions needed when stack goes out of scope. + // Perform actions needed when stack goes out of scope. // = Classic Stack operations. @@ -328,7 +329,7 @@ private: // Copy all nodes from <s> to <this>. ACE_Node<T> *head_; - // Head of the linked list of Nodes. + // Head of the linked list of Nodes. size_t cur_size_; // Current size of the stack. @@ -436,7 +437,7 @@ public: // Trait definition. typedef ACE_Unbounded_Queue_Iterator<T> ITERATOR; - // = Initialization and termination methods. + // = Initialization and termination methods. ACE_Unbounded_Queue (ACE_Allocator *alloc = 0); // construction. Use user specified allocation strategy // if specified. @@ -521,108 +522,28 @@ template <class T> class ACE_Double_Linked_List; template <class T> -class ACE_Double_Linked_List_Iterator_Base -{ - // = TITLE - // Implements a common base class for iterators for a double - // linked list ADT -public: - // = Iteration methods. - - int next (T *&) const; - // Passes back the <entry> under the iterator. Returns 0 if the - // iteration has completed, otherwise 1 - - T *next (void) const; - // Return the address of next (current) unvisited item in the list. - // 0 if there is no more element available. - // DEPRECATED - - - int done (void) const; - // Returns 1 when all items have been seen, else 0. - - T & operator* (void) const ; - // STL-like iterator dereference operator: returns a reference - // to the node underneath the iterator. - - void reset (ACE_Double_Linked_List<T> &); - // Retasks the iterator to iterate over a new - // Double_Linked_List. This allows clients to reuse an iterator - // without incurring the constructor overhead. If you do use this, - // be aware that if there are more than one reference to this - // iterator, the other "clients" may be very bothered when their - // iterator changes. - // @@ Here be dragons. Comments? - - ACE_ALLOC_HOOK_DECLARE; - // Declare the dynamic allocation hooks. - -protected: - // = Initialization methods. - - ACE_Double_Linked_List_Iterator_Base (ACE_Double_Linked_List<T> &); - // Constructor - - ACE_Double_Linked_List_Iterator_Base (const - ACE_Double_Linked_List_Iterator_Base<T> - &iter); - // Copy constructor. - - // = Iteration methods. - int go_head (void); - // Move to the first element of the list. Returns 0 if the list is - // empty, else 1. Note: the head of the ACE_DLList is actually a - // null entry, so the first element is actually the 2n'd entry - - int go_tail (void); - // Move to the last element of the list. Returns 0 if the list is - // empty, else 1. - - T *not_done (void) const ; - // Check if we reach the end of the list. Can also be used to get - // the *current* element in the list. Return the address of the - // current item if there are still elements left , 0 if we run out - // of element. - - T *do_advance (void); - // Advance to the next element in the list. Return the address of the - // next element if there are more, 0 otherwise. - - T *do_retreat (void); - // Retreat to the previous element in the list. Return the address - // of the previous element if there are more, 0 otherwise. - - void dump_i (void) const; - // Dump the state of an object. - - T *current_; - // Remember where we are. - - ACE_Double_Linked_List<T> *dllist_; -}; - -template <class T> -class ACE_Double_Linked_List_Iterator : public ACE_Double_Linked_List_Iterator_Base <T> +class ACE_Double_Linked_List_Iterator { // = TITLE - // Implements an iterator for a double linked list ADT + // Implement an iterator over a container double-linked list // // = DESCRIPTION - // Iterate thru the double-linked list. This class provides + // Iterate thru the double-linked list. This class provide // an interface that let users access the internal element - // addresses directly. Notice <class T> must delcare - // ACE_Double_Linked_List<T>, - // ACE_Double_Linked_List_Iterator_Base <T> and + // addresses directly, which (IMHO) seems to break the + // encasulation. Notice <class T> must delcare + // ACE_Double_Linked_List<T> and // ACE_Double_Linked_List_Iterator as friend classes and class T // should also have data members T* next_ and T* prev_. public: // = Initialization method. ACE_Double_Linked_List_Iterator (ACE_Double_Linked_List<T> &); - int first (void); - // Move to the first element in the list. Returns 0 if the - // list is empty, else 1. + // = Iteration methods. + + T *next (void) const; + // Return the address of next (current) unvisited item in the list. + // 0 if there is no more element available. int advance (void); // Move forward by one element in the list. Returns 0 when all the @@ -634,79 +555,34 @@ public: // <dont_remove> equals 0, this function behaves like advance() but // return 0 (NULL) instead. - // = STL-style iteration methods + int first (void); + // Move to the first element in the list. Returns 0 if the + // list is empty, else 1. - ACE_Double_Linked_List_Iterator<T> & operator++ (void); - // Prefix advance. - - ACE_Double_Linked_List_Iterator<T> operator++ (int); - // Postfix advance. - - ACE_Double_Linked_List_Iterator<T> & operator-- (void); - // Prefix reverse. - - ACE_Double_Linked_List_Iterator<T> operator-- (int); - // Postfix reverse. + int done (void) const; + // Returns 1 when all items have been seen, else 0. void dump (void) const; // Dump the state of an object. ACE_ALLOC_HOOK_DECLARE; // Declare the dynamic allocation hooks. -}; -template <class T> -class ACE_Double_Linked_List_Reverse_Iterator : public ACE_Double_Linked_List_Iterator_Base <T> -{ - // = TITLE - // Implements a reverse iterator for a double linked list ADT - // - // = DESCRIPTION - // Iterate backwards over the double-linked list. This class - // provide an interface that let users access the internal - // element addresses directly, which seems to break the - // encapsulation. Notice <class T> must delcare - // ACE_Double_Linked_List<T>, - // ACE_Double_Linked_List_Iterator_Base <T> and - // ACE_Double_Linked_List_Iterator as friend classes and class T - // should also have data members T* next_ and T* prev_. -public: - // = Initialization method. - ACE_Double_Linked_List_Reverse_Iterator (ACE_Double_Linked_List<T> &); - - int first (void); - // Move to the first element in the list. Returns 0 if the - // list is empty, else 1. - - int advance (void); - // Move forward by one element in the list. Returns 0 when all the - // items in the list have been seen, else 1. - - T* advance_and_remove (int dont_remove); - // Advance the iterator while removing the original item from the list. - // Return a pointer points to the original (removed) item. If - // <dont_remove> equals 0, this function behaves like advance() but - // return 0 (NULL) instead. - - // = STL-style iteration methods - - ACE_Double_Linked_List_Reverse_Iterator<T> & operator++ (void); - // Prefix advance. - - ACE_Double_Linked_List_Reverse_Iterator<T> operator++ (int); - // Postfix advance. +protected: + T *not_done (void) const ; + // Check if we reach the end of the list. Can also be used to get + // the *current* element in the list. Return the address of the + // current item if there are still elements left , 0 if we run out + // of element. - ACE_Double_Linked_List_Reverse_Iterator<T> & operator-- (void); - // Prefix reverse. - - ACE_Double_Linked_List_Reverse_Iterator<T> operator-- (int); - // Postfix reverse. + T *do_advance (void); + // Advance to the next element in the list. Return the address of the + // next element if there are more, 0 otherwise. - void dump (void) const; - // Dump the state of an object. + T *current_; + // Remember where we are. - ACE_ALLOC_HOOK_DECLARE; - // Declare the dynamic allocation hooks. + ACE_Double_Linked_List<T> &dllist_; }; template <class T> @@ -721,13 +597,10 @@ class ACE_Double_Linked_List // like the ACE_Unbounded_Queue except that it allows removing // of a specific element from a specific location. public: - friend class ACE_Double_Linked_List_Iterator_Base<T>; friend class ACE_Double_Linked_List_Iterator<T>; - friend class ACE_Double_Linked_List_Reverse_Iterator<T>; // Trait definition. typedef ACE_Double_Linked_List_Iterator<T> ITERATOR; - typedef ACE_Double_Linked_List_Reverse_Iterator<T> REVERSE_ITERATOR; // = Initialization and termination methods. ACE_Double_Linked_List (ACE_Allocator *alloc = 0); @@ -831,21 +704,11 @@ protected: template <class T> class ACE_DLList; template <class T> class ACE_DLList_Iterator; -template <class T> class ACE_DLList_Reverse_Iterator; - -typedef ACE_Double_Linked_List<ACE_DLList_Node> ACE_DLList_Base; - -//typedef ACE_Double_Linked_List_Iterator <ACE_DLList_Node> -// ACE_DLList_Iterator_Base; -//typedef ACE_Double_Linked_List_Reverse_Iterator <ACE_DLList_Node> -// ACE_DLList_Reverse_Iterator_Base; -//@@ These two typedefs (inherited from James Hu's original design) -// have been removed because Sun CC 4.2 had problems with it. I guess -// having the DLList_Iterators inheriting from a class which is -// actually a typedef leads to problems. #define'ing rather than -// typedef'ing worked, but as per Carlos's reccomendation, I'm just -// replacing all references to the base classes with their actual -// type. Matt Braun (6/15/99) + +typedef ACE_Double_Linked_List<ACE_DLList_Node> + ACE_DLList_Base; +typedef ACE_Double_Linked_List_Iterator<ACE_DLList_Node> + ACE_DLList_Iterator_Base; template <class T> class ACE_DLList : public ACE_DLList_Base @@ -859,9 +722,7 @@ class ACE_DLList : public ACE_DLList_Base // calls to ACE_Double_Linked_List. friend class ACE_DLList_Node; - friend class ACE_Double_Linked_List_Iterator<T>; friend class ACE_DLList_Iterator<T>; - friend class ACE_DLList_Reverse_Iterator<T>; public: void operator= (ACE_DLList<T> &l); @@ -884,9 +745,7 @@ public: // = Additional utility methods. int get (T *&item, size_t slot = 0); - // Delegates to ACE_Double_Linked_List, but where - // ACE_Double_Linked_List returns the node as the item, this get - // returns the contents of the node in item. + // Delegates to ACE_Double_Linked_List. void dump (void) const; // Delegates to ACE_Double_Linked_List. @@ -908,7 +767,7 @@ public: }; template <class T> -class ACE_DLList_Iterator : public ACE_Double_Linked_List_Iterator <ACE_DLList_Node> +class ACE_DLList_Iterator : public ACE_DLList_Iterator_Base { // = TITLE // A double-linked list container class iterator. @@ -927,48 +786,6 @@ public: ACE_DLList_Iterator (ACE_DLList<T> &l); // = Iteration methods. - int advance (void); - // Move forward by one element in the set. Returns 0 when all the - // items in the set have been seen, else 1. - - T *next (void) const; - // Delegates to ACE_Double_Linked_List_Iterator, except that whereas - // the Double_Linked_List version of next returns the node, this next - // returns the contents of the node - - int remove (void); - // Removes the current item (i.e., this->next()) from the list. - - void dump (void) const; - // Delegates to ACE_Double_Linked_List_Iterator. - -private: - ACE_DLList<T> &list_; -}; - -template <class T> -class ACE_DLList_Reverse_Iterator : public ACE_Double_Linked_List_Reverse_Iterator <ACE_DLList_Node> -{ - // = TITLE - // A double-linked list container class iterator. - // - // = DESCRIPTION - // This implementation uses ACE_Double_Linked_List_Iterator to - // perform the logic behind this container class. It delegates - // all of its calls to ACE_Double_Linked_List_Iterator. - - friend class ACE_DLList<T>; - friend class ACE_DLList_Node; - -public: - - // = Initialization method. - ACE_DLList_Reverse_Iterator (ACE_DLList<T> &l); - - // = Iteration methods. - int advance (void); - // Move forward by one element in the set. Returns 0 when all the - // items in the set have been seen, else 1. T *next (void) const; // Delegates to ACE_Double_Linked_List_Iterator. @@ -1122,7 +939,7 @@ private: // Copy nodes into this set. ACE_Node<T> *head_; - // Head of the linked list of Nodes. + // Head of the linked list of Nodes. size_t cur_size_; // Current size of the set. @@ -1548,10 +1365,10 @@ private: // Copy nodes into this set. ACE_DNode<T> *head_; - // Head of the bilinked list of Nodes. + // Head of the bilinked list of Nodes. ACE_DNode<T> *tail_; - // Head of the bilinked list of Nodes. + // Head of the bilinked list of Nodes. size_t cur_size_; // Current size of the set. diff --git a/ace/Containers_T.i b/ace/Containers_T.i index 78cfdb03dfe..9d59bf2ee0a 100644 --- a/ace/Containers_T.i +++ b/ace/Containers_T.i @@ -480,17 +480,9 @@ ACE_DLList<T>::~ACE_DLList (void) while (this->delete_head ()) ; } -template <class T> ACE_INLINE int -ACE_DLList_Iterator<T>::remove (void) -{ - ACE_DLList_Node *temp = this->ACE_Double_Linked_List_Iterator <ACE_DLList_Node>::next (); - this->ACE_Double_Linked_List_Iterator <ACE_DLList_Node>::advance (); - return dllist_->remove (temp); -} - template <class T> ACE_INLINE ACE_DLList_Iterator<T>::ACE_DLList_Iterator (ACE_DLList<T> &l) - : ACE_Double_Linked_List_Iterator <ACE_DLList_Node> ((ACE_DLList_Base &)l), + : ACE_DLList_Iterator_Base ((ACE_DLList_Base &)l), list_ (l) { } @@ -498,54 +490,20 @@ ACE_DLList_Iterator<T>::ACE_DLList_Iterator (ACE_DLList<T> &l) template <class T> ACE_INLINE T * ACE_DLList_Iterator<T>::next (void) const { - ACE_DLList_Node *temp = ACE_Double_Linked_List_Iterator <ACE_DLList_Node>::next (); + ACE_DLList_Node *temp = ACE_DLList_Iterator_Base::next (); return (T *) (temp ? temp->item_ : 0); } template <class T> ACE_INLINE int -ACE_DLList_Iterator<T>::advance (void) +ACE_DLList_Iterator<T>::remove (void) { - return this->ACE_Double_Linked_List_Iterator <ACE_DLList_Node>::advance (); + ACE_DLList_Node *temp = ACE_DLList_Iterator_Base::next (); + ACE_DLList_Iterator_Base::advance (); + return this->list_.remove (temp); } template <class T> ACE_INLINE void ACE_DLList_Iterator<T>::dump (void) const { - ACE_Double_Linked_List_Iterator <ACE_DLList_Node>::dump (); -} - - -template <class T> ACE_INLINE int -ACE_DLList_Reverse_Iterator<T>::remove (void) -{ - ACE_DLList_Node *temp = ACE_Double_Linked_List_Reverse_Iterator <ACE_DLList_Node>::next (); - this->ACE_Double_Linked_List_Reverse_Iterator <ACE_DLList_Node>::advance (); - return dllist_->remove (temp); -} - -template <class T> ACE_INLINE -ACE_DLList_Reverse_Iterator<T>::ACE_DLList_Reverse_Iterator (ACE_DLList<T> &l) - : ACE_Double_Linked_List_Reverse_Iterator <ACE_DLList_Node> ((ACE_DLList_Base &)l), - list_ (l) -{ -} - -template <class T> ACE_INLINE int -ACE_DLList_Reverse_Iterator<T>::advance (void) -{ - return ACE_Double_Linked_List_Reverse_Iterator <ACE_DLList_Node>::advance (); -} - -template <class T> ACE_INLINE T * -ACE_DLList_Reverse_Iterator<T>::next (void) const -{ - ACE_DLList_Node *temp = ACE_Double_Linked_List_Reverse_Iterator <ACE_DLList_Node>::next (); - return (T *) (temp ? temp->item_ : 0); -} - - -template <class T> ACE_INLINE void -ACE_DLList_Reverse_Iterator<T>::dump (void) const -{ - ACE_Double_Linked_List_Reverse_Iterator <ACE_DLList_Node>::dump (); + ACE_DLList_Iterator_Base::dump (); } diff --git a/ace/Containers_bad.i b/ace/Containers_bad.i deleted file mode 100644 index 471a9d559d5..00000000000 --- a/ace/Containers_bad.i +++ /dev/null @@ -1,25 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -ACE_INLINE -ACE_DLList_Node::ACE_DLList_Node (void) - : item_ (0), - next_ (0), - prev_ (0) -{ -} - -ACE_INLINE -ACE_DLList_Node::ACE_DLList_Node (void *&i, - ACE_DLList_Node *n, - ACE_DLList_Node *p) - : item_ (i), - next_ (n), - prev_ (p) -{ -} - -ACE_INLINE -ACE_DLList_Node::~ACE_DLList_Node (void) -{ -} diff --git a/ace/DEV_Addr.cpp b/ace/DEV_Addr.cpp index 60652735fcc..c99a82144d1 100644 --- a/ace/DEV_Addr.cpp +++ b/ace/DEV_Addr.cpp @@ -52,7 +52,6 @@ ACE_DEV_Addr::set (const ACE_DEV_Addr &sa) // Copy constructor. ACE_DEV_Addr::ACE_DEV_Addr (const ACE_DEV_Addr &sa) - : ACE_Addr (AF_DEV, sizeof this->devname_) { ACE_TRACE ("ACE_DEV_Addr::ACE_DEV_Addr"); @@ -60,7 +59,6 @@ ACE_DEV_Addr::ACE_DEV_Addr (const ACE_DEV_Addr &sa) } ACE_DEV_Addr::ACE_DEV_Addr (LPCTSTR devname) - : ACE_Addr (AF_DEV, sizeof this->devname_) { ACE_TRACE ("ACE_DEV_Addr::ACE_DEV_Addr"); diff --git a/ace/Dirent.i b/ace/Dirent.i index 0503442de09..dceba821fa6 100644 --- a/ace/Dirent.i +++ b/ace/Dirent.i @@ -30,8 +30,7 @@ ACE_Dirent::ACE_Dirent (const char *dirname) ACE_INLINE ACE_Dirent::~ACE_Dirent (void) { - if (this->dirp_ != 0) - ACE_OS::closedir (this->dirp_); + ACE_OS::closedir (this->dirp_); } ACE_INLINE dirent * @@ -52,8 +51,7 @@ ACE_Dirent::read (struct dirent *entry, ACE_INLINE void ACE_Dirent::close (void) { - if (this->dirp_ != 0) - ACE_OS::closedir (this->dirp_); + ACE_OS::closedir (this->dirp_); } ACE_INLINE void diff --git a/ace/Env_Value_T.h b/ace/Env_Value_T.h index 3921321985f..be8879c092c 100644 --- a/ace/Env_Value_T.h +++ b/ace/Env_Value_T.h @@ -101,12 +101,6 @@ ACE_Convert (const char *s, char *&v) } inline void -ACE_Convert (const char *s, const char *&v) -{ - v = (const char *) s; -} - -inline void ACE_Convert (const char *s, short &si) { si = ACE_static_cast (short, ACE_OS::strtol (s, 0, 10)); diff --git a/ace/FILE_Addr.cpp b/ace/FILE_Addr.cpp index 17e90a1ed48..80ccd9aff65 100644 --- a/ace/FILE_Addr.cpp +++ b/ace/FILE_Addr.cpp @@ -44,7 +44,6 @@ ACE_FILE_Addr::set (const ACE_FILE_Addr &sa) // Copy constructor. ACE_FILE_Addr::ACE_FILE_Addr (const ACE_FILE_Addr &sa) - : ACE_Addr (AF_FILE, sizeof this->filename_) { this->set (sa); } diff --git a/ace/FILE_IO.cpp b/ace/FILE_IO.cpp index 9f5a848bcce..3486629e491 100644 --- a/ace/FILE_IO.cpp +++ b/ace/FILE_IO.cpp @@ -127,3 +127,4 @@ ACE_FILE_IO::recvv (iovec *io_vec) else return length; } + diff --git a/ace/Functor.h b/ace/Functor.h index c119b86a493..a66788ab876 100644 --- a/ace/Functor.h +++ b/ace/Functor.h @@ -115,60 +115,77 @@ public: // Simply returns t }; +ACE_TEMPLATE_SPECIALIZATION +class ACE_Export ACE_Hash<short> +{ + // = TITLE + // Function object for hashing a short +public: + u_long operator () (short t) const; + // Simply returns t +}; -// @@ ADD HASHES FOR ACE TYPES +ACE_TEMPLATE_SPECIALIZATION +class ACE_Export ACE_Hash<unsigned short> +{ + // = TITLE + // Function object for hashing an unsigned short +public: + u_long operator () (unsigned short t) const; + // Simply returns t +}; ACE_TEMPLATE_SPECIALIZATION -class ACE_Export ACE_Hash<ACE_INT16> +class ACE_Export ACE_Hash<int> { // = TITLE - // Function object for hashing a 16-bit signed number + // Function object for hashing an int public: - u_long operator () (ACE_INT16 t) const; + u_long operator () (int t) const; // Simply returns t }; ACE_TEMPLATE_SPECIALIZATION -class ACE_Export ACE_Hash<ACE_UINT16> +class ACE_Export ACE_Hash<unsigned int> { // = TITLE - // Function object for hashing a 16-bit unsigned number + // Function object for hashing an unsigned int public: - u_long operator () (ACE_UINT16 t) const; + u_long operator () (unsigned int t) const; // Simply returns t }; ACE_TEMPLATE_SPECIALIZATION -class ACE_Export ACE_Hash<ACE_INT32> +class ACE_Export ACE_Hash<long> { // = TITLE - // Function object for hashing a 32-bit signed number + // Function object for hashing a long public: - u_long operator () (ACE_INT32 t) const; + u_long operator () (long t) const; // Simply returns t }; ACE_TEMPLATE_SPECIALIZATION -class ACE_Export ACE_Hash<ACE_UINT32> +class ACE_Export ACE_Hash<unsigned long> { // = TITLE - // Function object for hashing a 32-bit unsigned number + // Function object for hashing an unsigned long public: - u_long operator () (ACE_UINT32 t) const; + u_long operator () (unsigned long t) const; // Simply returns t }; +#if ACE_SIZEOF_LONG != 8 ACE_TEMPLATE_SPECIALIZATION class ACE_Export ACE_Hash<ACE_UINT64> { // = TITLE - // Function object for hashing a 64-bit unsigned number + // Function object for hashing an unsigned long public: u_long operator () (ACE_UINT64 t) const; // Simply returns t }; - -// @@ DONE ADDING HASHES FOR ACE TYPES +#endif /* ACE_SIZEOF_LONG != 8 */ ACE_TEMPLATE_SPECIALIZATION class ACE_Export ACE_Hash<const char *> diff --git a/ace/Functor.i b/ace/Functor.i index abb2ca799a7..8703043412a 100644 --- a/ace/Functor.i +++ b/ace/Functor.i @@ -70,35 +70,48 @@ ACE_Hash<unsigned char>::operator () (unsigned char t) const } ACE_INLINE u_long -ACE_Hash<ACE_INT16>::operator () (ACE_INT16 t) const +ACE_Hash<short>::operator () (short t) const { return t; } ACE_INLINE u_long -ACE_Hash<ACE_UINT16>::operator () (ACE_UINT16 t) const +ACE_Hash<unsigned short>::operator () (unsigned short t) const { return t; } ACE_INLINE u_long -ACE_Hash<ACE_INT32>::operator () (ACE_INT32 t) const +ACE_Hash<int>::operator () (int t) const { return t; } ACE_INLINE u_long -ACE_Hash<ACE_UINT32>::operator () (ACE_UINT32 t) const +ACE_Hash<unsigned int>::operator () (unsigned int t) const { return t; } ACE_INLINE u_long +ACE_Hash<long>::operator () (long t) const +{ + return t; +} + +ACE_INLINE u_long +ACE_Hash<unsigned long>::operator () (unsigned long t) const +{ + return t; +} + +#if ACE_SIZEOF_LONG != 8 +ACE_INLINE u_long ACE_Hash<ACE_UINT64>::operator () (ACE_UINT64 t) const { return ACE_U64_TO_U32 (t); } - +#endif /* ACE_SIZEOF_LONG != 8 */ ACE_INLINE u_long ACE_Hash<const char *>::operator () (const char *t) const diff --git a/ace/Hash_Cache_Map_Manager_T.cpp b/ace/Hash_Cache_Map_Manager_T.cpp index e09f09e3466..614b8d99528 100644 --- a/ace/Hash_Cache_Map_Manager_T.cpp +++ b/ace/Hash_Cache_Map_Manager_T.cpp @@ -19,30 +19,27 @@ ACE_RCSID(ace, Hash_Cache_Map_Manager_T, "$Id$") ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Cache_Map_Manager) -#define T_1 class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY, class ATTRIBUTES -#define T_2 KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES - -template <T_1> -ACE_Hash_Cache_Map_Manager<T_2>::ACE_Hash_Cache_Map_Manager (size_t size, - ACE_Allocator *alloc, - CACHING_STRATEGY *caching_s, - int delete_caching_strategy) - : ACE_HCMM_BASE (size, - alloc, - caching_s, - delete_caching_strategy) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY, class ATTRIBUTES> +ACE_Hash_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES>::ACE_Hash_Cache_Map_Manager (size_t size, + ACE_Allocator *alloc, + CACHING_STRATEGY *caching_s, + int delete_caching_strategy) + : ACE_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, ACE_Hash_Map_Manager_Ex<KEY, ACE_Pair<VALUE, ATTRIBUTES>, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex>, CACHING_STRATEGY, ATTRIBUTES> (size, + alloc, + caching_s, + delete_caching_strategy) { } -template <T_1> -ACE_Hash_Cache_Map_Manager<T_2>::~ACE_Hash_Cache_Map_Manager (void) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY, class ATTRIBUTES> +ACE_Hash_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES>::~ACE_Hash_Cache_Map_Manager (void) { } -template <T_1> int -ACE_Hash_Cache_Map_Manager<T_2>:: bind (const KEY &key, - const VALUE &value, - ACE_Hash_Map_Entry<KEY, ACE_Pair<VALUE, ATTRIBUTES> > *&entry) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY, class ATTRIBUTES> int +ACE_Hash_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES>:: bind (const KEY &key, + const VALUE &value, + ACE_Hash_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES>::CACHE_ENTRY *&entry) { // Insert a entry which has the <key> and the <cache_value> which is // the combination of the <value> and the attributes of the caching @@ -75,10 +72,10 @@ ACE_Hash_Cache_Map_Manager<T_2>:: bind (const KEY &key, return bind_result; } -template <T_1> int -ACE_Hash_Cache_Map_Manager<T_2>::rebind (const KEY &key, - const VALUE &value, - ACE_Hash_Map_Entry<KEY, ACE_Pair<VALUE, ATTRIBUTES> > *&entry) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY, class ATTRIBUTES> int +ACE_Hash_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES>::rebind (const KEY &key, + const VALUE &value, + ACE_Hash_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES>::CACHE_ENTRY *&entry) { CACHE_VALUE cache_value (value, this->caching_strategy_->attributes ()); @@ -113,10 +110,10 @@ ACE_Hash_Cache_Map_Manager<T_2>::rebind (const KEY &key, return rebind_result; } -template <T_1> int -ACE_Hash_Cache_Map_Manager<T_2>::trybind (const KEY &key, - VALUE &value, - ACE_Hash_Map_Entry<KEY, ACE_Pair<VALUE, ATTRIBUTES> > *&entry) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY, class ATTRIBUTES> int +ACE_Hash_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES>::trybind (const KEY &key, + VALUE &value, + ACE_Hash_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES>::CACHE_ENTRY *&entry) { CACHE_VALUE cache_value (value, this->caching_strategy_->attributes ()); @@ -156,9 +153,9 @@ ACE_Hash_Cache_Map_Manager<T_2>::trybind (const KEY &key, return trybind_result; } -template <T_1> int -ACE_Hash_Cache_Map_Manager<T_2>::find (const KEY &key, - ACE_Hash_Map_Entry<KEY, ACE_Pair<VALUE, ATTRIBUTES> > *&entry) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY, class ATTRIBUTES> int +ACE_Hash_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES>::find (const KEY &key, + ACE_Hash_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES>::CACHE_ENTRY *&entry) { // Lookup the key and populate the <value>. int find_result = this->map_.find (key, @@ -182,8 +179,8 @@ ACE_Hash_Cache_Map_Manager<T_2>::find (const KEY &key, return find_result; } -template <T_1> int -ACE_Hash_Cache_Map_Manager<T_2>::unbind (ACE_Hash_Map_Entry<KEY, ACE_Pair<VALUE, ATTRIBUTES> > *entry) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY, class ATTRIBUTES> int +ACE_Hash_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES>::unbind (ACE_Hash_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES>::CACHE_ENTRY *entry) { // Remove the entry from the cache. int unbind_result = this->map_.unbind (entry); @@ -202,7 +199,4 @@ ACE_Hash_Cache_Map_Manager<T_2>::unbind (ACE_Hash_Map_Entry<KEY, ACE_Pair<VALUE, return unbind_result; } -#undef T_1 -#undef T_2 - #endif /* ACE_HASH_CACHE_MAP_MANAGER_T_C */ diff --git a/ace/Hash_Cache_Map_Manager_T.h b/ace/Hash_Cache_Map_Manager_T.h index 7d1c06f9f77..f3d149ff5f8 100644 --- a/ace/Hash_Cache_Map_Manager_T.h +++ b/ace/Hash_Cache_Map_Manager_T.h @@ -28,10 +28,8 @@ class ACE_Allocator; template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY, class ATTRIBUTES> -class ACE_Hash_Cache_Map_Manager : public ACE_Cache_Map_Manager< KEY, VALUE, +class ACE_Hash_Cache_Map_Manager : public ACE_Cache_Map_Manager< KEY, VALUE, HASH_KEY, COMPARE_KEYS, ACE_Hash_Map_Manager_Ex<KEY, ACE_Pair<VALUE, ATTRIBUTES>, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex>, - ACE_Hash_Map_Iterator_Ex<KEY, ACE_Pair<VALUE, ATTRIBUTES>, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex>, - ACE_Hash_Map_Reverse_Iterator_Ex<KEY, ACE_Pair<VALUE, ATTRIBUTES>, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex>, CACHING_STRATEGY, ATTRIBUTES> { // = TITLE @@ -59,6 +57,9 @@ class ACE_Hash_Cache_Map_Manager : public ACE_Cache_Map_Manager< KEY, VALUE, typedef ACE_Hash_Map_Entry<KEY, CACHE_VALUE> CACHE_ENTRY; typedef KEY key_type; typedef VALUE mapped_type; + typedef ACE_TYPENAME HASH_MAP::ITERATOR IMPLEMENTATION; + typedef ACE_TYPENAME HASH_MAP::REVERSE_ITERATOR REVERSE_IMPLEMENTATION; + // The actual value mapped to the key in the map. The <attributes> // are used by the strategy and is transparent to the user of this // class. @@ -165,11 +166,9 @@ class ACE_Hash_Cache_Map_Manager : public ACE_Cache_Map_Manager< KEY, VALUE, protected: - typedef ACE_Cache_Map_Manager<KEY, VALUE, - ACE_Hash_Map_Manager_Ex<KEY, ACE_Pair<VALUE, ATTRIBUTES>, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex>, - ACE_Hash_Map_Iterator_Ex<KEY, ACE_Pair<VALUE, ATTRIBUTES>, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex>, - ACE_Hash_Map_Reverse_Iterator_Ex<KEY, ACE_Pair<VALUE, ATTRIBUTES>, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex>, - CACHING_STRATEGY, ATTRIBUTES> + typedef ACE_Cache_Map_Manager< KEY, VALUE, HASH_KEY, COMPARE_KEYS, + ACE_Hash_Map_Manager_Ex<KEY, ACE_Pair<VALUE, ATTRIBUTES>, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex>, + CACHING_STRATEGY, ATTRIBUTES> ACE_HCMM_BASE; // Base class. }; diff --git a/ace/Hash_Cache_Map_Manager_T.i b/ace/Hash_Cache_Map_Manager_T.i index 0b1b691fd2c..d4c612f3ca1 100644 --- a/ace/Hash_Cache_Map_Manager_T.i +++ b/ace/Hash_Cache_Map_Manager_T.i @@ -1,40 +1,37 @@ /* -*- C++ -*- */ // $Id$ -#define T_1 class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY, class ATTRIBUTES -#define T_2 KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES - -template <T_1> ACE_INLINE int -ACE_Hash_Cache_Map_Manager<T_2>::bind (const KEY &key, - const VALUE &value) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE int +ACE_Hash_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES>::bind (const KEY &key, + const VALUE &value) { return ACE_HCMM_BASE::bind (key, value); } -template <T_1> ACE_INLINE int -ACE_Hash_Cache_Map_Manager<T_2>::rebind (const KEY &key, - const VALUE &value) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE int +ACE_Hash_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES>::rebind (const KEY &key, + const VALUE &value) { return ACE_HCMM_BASE::rebind (key, value); } -template <T_1> ACE_INLINE int -ACE_Hash_Cache_Map_Manager<T_2>::rebind (const KEY &key, - const VALUE &value, - VALUE &old_value) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE int +ACE_Hash_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES>::rebind (const KEY &key, + const VALUE &value, + VALUE &old_value) { return ACE_HCMM_BASE::rebind (key, value, old_value); } -template <T_1> ACE_INLINE int -ACE_Hash_Cache_Map_Manager<T_2>::rebind (const KEY &key, - const VALUE &value, - KEY &old_key, - VALUE &old_value) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE int +ACE_Hash_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES>::rebind (const KEY &key, + const VALUE &value, + KEY &old_key, + VALUE &old_value) { return ACE_HCMM_BASE::rebind (key, value, @@ -42,41 +39,39 @@ ACE_Hash_Cache_Map_Manager<T_2>::rebind (const KEY &key, old_value); } -template <T_1> ACE_INLINE int -ACE_Hash_Cache_Map_Manager<T_2>::trybind (const KEY &key, - VALUE &value) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE int +ACE_Hash_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES>::trybind (const KEY &key, + VALUE &value) { return ACE_HCMM_BASE::trybind (key, value); } -template <T_1> ACE_INLINE int -ACE_Hash_Cache_Map_Manager<T_2>::find (const KEY &key, - VALUE &value) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE int +ACE_Hash_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES>::find (const KEY &key, + VALUE &value) { return ACE_HCMM_BASE::find (key, value); } -template <T_1> ACE_INLINE int -ACE_Hash_Cache_Map_Manager<T_2>::find (const KEY &key) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE int +ACE_Hash_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES>::find (const KEY &key) { return ACE_HCMM_BASE::find (key); } -template <T_1> ACE_INLINE int -ACE_Hash_Cache_Map_Manager<T_2>::unbind (const KEY &key) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE int +ACE_Hash_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES>::unbind (const KEY &key) { return ACE_HCMM_BASE::unbind (key); } -template <T_1> ACE_INLINE int -ACE_Hash_Cache_Map_Manager<T_2>::unbind (const KEY &key, - VALUE &value) +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY, class ATTRIBUTES> ACE_INLINE int +ACE_Hash_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES>::unbind (const KEY &key, + VALUE &value) { return ACE_HCMM_BASE::unbind (key, value); } -#undef T_1 -#undef T_2 diff --git a/ace/INET_Addr.cpp b/ace/INET_Addr.cpp index 503e52dcdbb..341863d32c4 100644 --- a/ace/INET_Addr.cpp +++ b/ace/INET_Addr.cpp @@ -165,7 +165,6 @@ ACE_INET_Addr::set (const ASYS_TCHAR address[]) } ACE_INET_Addr::ACE_INET_Addr (const ASYS_TCHAR address[]) - : ACE_Addr (AF_INET, sizeof this->inet_addr_) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); this->set (address); @@ -174,7 +173,6 @@ ACE_INET_Addr::ACE_INET_Addr (const ASYS_TCHAR address[]) // Copy constructor. ACE_INET_Addr::ACE_INET_Addr (const ACE_INET_Addr &sa) - : ACE_Addr (AF_INET, sizeof this->inet_addr_) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); this->set (sa); diff --git a/ace/INET_Addr.h b/ace/INET_Addr.h index 4958e08e0ed..1d62735b875 100644 --- a/ace/INET_Addr.h +++ b/ace/INET_Addr.h @@ -28,8 +28,7 @@ class ACE_Export ACE_INET_Addr : public ACE_Addr { // = TITLE - // Defines a C++ wrapper facade for the Internet domain address - // family format. + // Defines the Internet domain address family address format. public: // = Initialization methods. ACE_INET_Addr (void); @@ -52,19 +51,16 @@ public: // is assumed to be a port number, with the IP address being // INADDR_ANY. - ACE_INET_Addr (u_short port_number, - ACE_UINT32 ip_addr = INADDR_ANY); + ACE_INET_Addr (u_short port_number, ACE_UINT32 ip_addr = INADDR_ANY); // Creates an <ACE_INET_Addr> from a <port_number> and an Internet // <ip_addr>. This method assumes that <port_number> and <ip_addr> // are in host byte order. - ACE_INET_Addr (const ASYS_TCHAR port_name[], - const ASYS_TCHAR host_name[]); + ACE_INET_Addr (const ASYS_TCHAR port_name[], const ASYS_TCHAR host_name[]); // Uses <getservbyname> to create an <ACE_INET_Addr> from a // <port_name> and the remote <host_name>. - ACE_INET_Addr (const ASYS_TCHAR port_name[], - ACE_UINT32 ip_addr); + ACE_INET_Addr (const ASYS_TCHAR port_name[], ACE_UINT32 ip_addr); // Uses <getservbyname> to create an <ACE_INET_Addr> from a // <port_name> and an Internet <ip_addr>. This method assumes that // <ip_addr> is in host byte order. @@ -72,15 +68,12 @@ public: ~ACE_INET_Addr (void); // Default dtor. - // = Direct initialization methods. - - // These methods are useful after the object has been constructed. - + // = Direct initialization methods (useful after the object has been + // constructed). int set (const ACE_INET_Addr &); // Initializes from another <ACE_INET_Addr>. - int set (u_short port_number, - const ASYS_TCHAR host_name[], + int set (u_short port_number, const ASYS_TCHAR host_name[], int encode = 1); // Initializes an <ACE_INET_Addr> from a <port_number> and the // remote <host_name>. If <encode> is enabled then <port_number> is @@ -96,13 +89,11 @@ public: // they are assumed to be in network byte order already and are // passed straight through. - int set (const ASYS_TCHAR port_name[], - const ASYS_TCHAR host_name[]); + int set (const ASYS_TCHAR port_name[], const ASYS_TCHAR host_name[]); // Uses <getservbyname> to initialize an <ACE_INET_Addr> from a // <port_name> and the remote <host_name>. - int set (const ASYS_TCHAR port_name[], - ACE_UINT32 ip_addr); + int set (const ASYS_TCHAR port_name[], ACE_UINT32 ip_addr); // Uses <getservbyname> to initialize an <ACE_INET_Addr> from a // <port_name> and an Internet address. This assumes that <ip_addr> // is already in network byte order. @@ -114,8 +105,7 @@ public: // is assumed to be a port number, with the IP address being // INADDR_ANY. - int set (const sockaddr_in *, - int len); + int set (const sockaddr_in *, int len); // Creates an <ACE_INET_Addr> from a sockaddr_in structure. virtual void *get_addr (void) const; @@ -143,8 +133,7 @@ public: // is no ':' in the <address> it is assumed to be a port number, // with the IP address being INADDR_ANY. - void set_port_number (u_short, - int encode = 1); + void set_port_number (u_short, int encode = 1); // Sets the port number without affecting the host name. If // <encode> is enabled then <port_number> is converted into network // byte order, otherwise it is assumed to be in network byte order diff --git a/ace/LSOCK_Acceptor.cpp b/ace/LSOCK_Acceptor.cpp index fad95eca458..1e6b696eeda 100644 --- a/ace/LSOCK_Acceptor.cpp +++ b/ace/LSOCK_Acceptor.cpp @@ -67,61 +67,25 @@ ACE_LSOCK_Acceptor::ACE_LSOCK_Acceptor (const ACE_Addr &remote_sap, int protocol) { ACE_TRACE ("ACE_LSOCK_Acceptor::ACE_LSOCK_Acceptor"); - if (this->open (remote_sap, - reuse_addr, - protocol_family, - backlog, - protocol) == -1) - ACE_ERROR ((LM_ERROR, - "ACE_LSOCK_Acceptor::ACE_LSOCK_Acceptor")); + if (this->open (remote_sap, reuse_addr, + protocol_family, backlog, protocol) == -1) + ACE_ERROR ((LM_ERROR, "ACE_LSOCK_Acceptor::ACE_LSOCK_Acceptor")); } // General purpose routine for accepting new connections. int -ACE_LSOCK_Acceptor::accept (ACE_LSOCK_Stream &new_stream, +ACE_LSOCK_Acceptor::accept (ACE_LSOCK_Stream &new_local_ipc_sap, ACE_Addr *remote_addr, ACE_Time_Value *timeout, int restart, int reset_new_handle) const { ACE_TRACE ("ACE_LSOCK_Acceptor::accept"); - - int in_blocking_mode = 0; - if (this->shared_accept_start (timeout, - restart, - in_blocking_mode) == -1) - return -1; - else - { - sockaddr *addr = 0; - int len = 0; - - if (remote_addr != 0) - { - len = remote_addr->get_size (); - addr = (sockaddr *) remote_addr->get_addr (); - } - - do - new_stream.set_handle (ACE_OS::accept (this->get_handle (), - addr, - &len)); - while (new_stream.get_handle () == ACE_INVALID_HANDLE - && restart != 0 - && errno == EINTR - && timeout == 0); - - // Reset the size of the addr, which is only necessary for UNIX - // domain sockets. - if (new_stream.get_handle () != ACE_INVALID_HANDLE - && remote_addr != 0) - remote_addr->set_size (len); - } - - return this->shared_accept_finish (new_stream, - in_blocking_mode, - reset_new_handle); + ACE_HANDLE new_handle = + ACE_SOCK_Acceptor::shared_accept (remote_addr, timeout, restart, reset_new_handle); + new_local_ipc_sap.set_handle (new_handle); + return new_handle == ACE_INVALID_HANDLE ? -1 : 0; } // Close down the UNIX domain stream and remove the rendezvous point diff --git a/ace/Local_Tokens.cpp b/ace/Local_Tokens.cpp index a5c1260f0b8..a6e359ef34b 100644 --- a/ace/Local_Tokens.cpp +++ b/ace/Local_Tokens.cpp @@ -1299,9 +1299,12 @@ ACE_Token_Proxy::handle_options (ACE_Synch_Options &options, if (options[ACE_Synch_Options::USE_REACTOR] == 1) // Asynchronous. { - // Save/restore errno. - ACE_Errno_Guard error (errno); + int error = errno; + // if (options[ACE_Synch_Options::USE_TIMEOUT] == 1) + // ACE_ERROR_RETURN ((LM_ERROR, "Timeouts not yet supported" " + // with asynchronous operations."), -1); cv.mutex ().release (); + errno = error; ACE_RETURN (-1); } else diff --git a/ace/Log_Msg.cpp b/ace/Log_Msg.cpp index 7114ce06675..06d3aeb191f 100644 --- a/ace/Log_Msg.cpp +++ b/ace/Log_Msg.cpp @@ -123,9 +123,9 @@ ACE_Log_Msg_Manager::close (void) } /* static */ -#if defined (ACE_HAS_THR_C_DEST) +#if defined (ACE_HAS_THR_C_FUNC) extern "C" -#endif /* ACE_HAS_THR_C_DEST */ +#endif /* ACE_HAS_THR_C_FUNC */ void ACE_TSS_cleanup (void *ptr) { diff --git a/ace/Message_Queue_T.cpp b/ace/Message_Queue_T.cpp index 67e76992def..f1255f597a6 100644 --- a/ace/Message_Queue_T.cpp +++ b/ace/Message_Queue_T.cpp @@ -492,10 +492,9 @@ ACE_Message_Queue<ACE_SYNCH_USE>::wait_not_full_cond (ACE_Guard<ACE_SYNCH_MUTEX_ result = this->not_full_cond_.acquire (); else result = this->not_full_cond_.acquire (*timeout); - - // Save/restore errno. - ACE_Errno_Guard error (errno); + int error = errno; mon.acquire (); + errno = error; } #else ACE_UNUSED_ARG (mon); @@ -541,9 +540,9 @@ ACE_Message_Queue<ACE_SYNCH_USE>::wait_not_empty_cond (ACE_Guard<ACE_SYNCH_MUTEX if (result == -1 && errno == ETIME) errno = EWOULDBLOCK; } - // Save/restore errno. - ACE_Errno_Guard error (errno); + int error = errno; mon.acquire (); + errno = error; } #else ACE_UNUSED_ARG (mon); diff --git a/ace/Message_Queue_T.h b/ace/Message_Queue_T.h index 90484d98a28..95ece558c3a 100644 --- a/ace/Message_Queue_T.h +++ b/ace/Message_Queue_T.h @@ -213,9 +213,6 @@ public: virtual ACE_Notification_Strategy *notification_strategy (void); virtual void notification_strategy (ACE_Notification_Strategy *s); - ACE_SYNCH_MUTEX_T &lock (void); - // Returns a reference to the lock used by the <ACE_Message_Queue>. - virtual void dump (void) const; // Dump the state of an object. @@ -224,7 +221,6 @@ public: protected: // = Routines that actually do the enqueueing and dequeueing. - // These routines assume that locks are held by the corresponding // public methods. Since they are virtual, you can change the // queueing mechanism by subclassing from <ACE_Message_Queue>. @@ -243,25 +239,18 @@ protected: // queue. // = Check the boundary conditions (assumes locks are held). - virtual int is_full_i (void); // True if queue is full, else false. - virtual int is_empty_i (void); // True if queue is empty, else false. - // = Implementation of the public <activate> and <deactivate> methods. - - // These methods assume locks are held. - + // = Implementation of the public activate() and deactivate() methods above (assumes locks are held). virtual int deactivate_i (void); // Deactivate the queue. - virtual int activate_i (void); // Activate the queue. // = Helper methods to factor out common #ifdef code. - virtual int wait_not_full_cond (ACE_Guard<ACE_SYNCH_MUTEX_T> &mon, ACE_Time_Value *timeout); // Wait for the queue to become non-full. diff --git a/ace/Message_Queue_T.i b/ace/Message_Queue_T.i index b5ddf46a60f..c0517a71f47 100644 --- a/ace/Message_Queue_T.i +++ b/ace/Message_Queue_T.i @@ -149,10 +149,4 @@ ACE_Message_Queue<ACE_SYNCH_USE>::deactivated (void) return this->deactivated_; } -template <ACE_SYNCH_DECL> ACE_INLINE ACE_SYNCH_MUTEX_T & -ACE_Message_Queue<ACE_SYNCH_USE>::lock (void) -{ - return this->lock_; -} - ACE_ALLOC_HOOK_DEFINE(ACE_Message_Queue_Reverse_Iterator) diff --git a/ace/OS.cpp b/ace/OS.cpp index b5fef535e14..425bcad3dbf 100644 --- a/ace/OS.cpp +++ b/ace/OS.cpp @@ -5244,12 +5244,12 @@ ACE_OS::rwlock_init (ACE_rwlock_t *rw, if (result == -1) { - // Save/restore errno. - ACE_Errno_Guard error (errno); + int error = errno; ACE_OS::mutex_destroy (&rw->lock_); ACE_OS::cond_destroy (&rw->waiting_readers_); ACE_OS::cond_destroy (&rw->waiting_writers_); ACE_OS::cond_destroy (&rw->waiting_important_writer_); + errno = error; } return result; # else @@ -5498,7 +5498,7 @@ ACE_OS::cond_timedwait (ACE_cond_t *cv, ACE_OS::thread_mutex_unlock (&cv->waiters_lock_); int result = 0; - ACE_Errno_Guard error (errno, 0); + int error = 0; int msec_timeout; if (timeout->sec () == 0 && timeout->usec () == 0) @@ -5648,6 +5648,7 @@ ACE_OS::cond_timedwait (ACE_cond_t *cv, // occur because that's the guarantee that we give to our callers. ACE_OS::mutex_lock (external_mutex); + errno = error; return result; # endif /* ACE_HAS_WTHREADS || ACE_HAS_VXWORKS || ACE_PSOS */ # else @@ -296,12 +296,6 @@ # define ACE_DEFAULT_SERVER_HOST "localhost" # endif /* ACE_DEFAULT_SERVER_HOST */ -// The way to specify the local host for loopback IP. This is usually -// "localhost" but it may need changing on some platforms. -# if !defined (ACE_LOCALHOST) -# define ACE_LOCALHOST ASYS_TEXT("localhost") -# endif - // Default shared memory key # if !defined (ACE_DEFAULT_SHM_KEY) # define ACE_DEFAULT_SHM_KEY 1234 @@ -1114,7 +1108,6 @@ private: // This needs to go here *first* to avoid problems with AIX. # if defined (ACE_HAS_PTHREADS) extern "C" { -# include /**/ <signal.h> # include /**/ <pthread.h> # if defined (DIGITAL_UNIX) # define pthread_self __pthread_self @@ -2018,31 +2011,19 @@ typedef pthread_mutex_t ACE_thread_mutex_t; # if defined (ACE_HAS_PTHREADS_DRAFT4) # if defined (PTHREAD_PROCESS_PRIVATE) -# if !defined (USYNC_THREAD) # define USYNC_THREAD PTHREAD_PROCESS_PRIVATE -# endif /* ! USYNC_THREAD */ # else -# if !defined (USYNC_THREAD) # define USYNC_THREAD MUTEX_NONRECURSIVE_NP -# endif /* ! USYNC_THREAD */ # endif /* PTHREAD_PROCESS_PRIVATE */ # if defined (PTHREAD_PROCESS_SHARED) -# if !defined (USYNC_PROCESS) # define USYNC_PROCESS PTHREAD_PROCESS_SHARED -# endif /* ! USYNC_PROCESS */ # else -# if !defined (USYNC_PROCESS) # define USYNC_PROCESS MUTEX_NONRECURSIVE_NP -# endif /* ! USYNC_PROCESS */ # endif /* PTHREAD_PROCESS_SHARED */ # elif !defined (ACE_HAS_STHREADS) -# if !defined (USYNC_THREAD) # define USYNC_THREAD PTHREAD_PROCESS_PRIVATE -# endif /* ! USYNC_THREAD */ -# if !defined (USYNC_PROCESS) # define USYNC_PROCESS PTHREAD_PROCESS_SHARED -# endif /* ! USYNC_PROCESS */ # endif /* ACE_HAS_PTHREADS_DRAFT4 */ # define THR_BOUND 0x00000001 @@ -2091,8 +2072,14 @@ protected: # endif /* !ACE_HAS_POSIX_SEM */ # if defined (ACE_LACKS_PTHREAD_YIELD) && defined (ACE_HAS_THR_YIELD) - // If we are on Solaris we can just reuse the existing - // implementations of these synchronization types. +# if defined (USYNC_THREAD) +# undef USYNC_THREAD +# endif /* USYNC_THREAD */ +# if defined (USYNC_PROCESS) +# undef USYNC_PROCESS +# endif /* USYNC_PROCESS */ +// If we are on Solaris we can just reuse the existing implementations +// of these synchronization types. # if !defined (ACE_LACKS_RWLOCK_T) # include /**/ <synch.h> typedef rwlock_t ACE_rwlock_t; @@ -2318,11 +2305,11 @@ public: # define THR_CANCEL_ENABLE 0 # define THR_CANCEL_DEFERRED 0 # define THR_CANCEL_ASYNCHRONOUS 0 -# define THR_DETACHED 0x02000000 /* ignore in most places */ -# define THR_BOUND 0 /* ignore in most places */ -# define THR_NEW_LWP 0 /* ignore in most places */ -# define THR_DAEMON 0 /* ignore in most places */ -# define THR_JOINABLE 0 /* ignore in most places */ +# define THR_DETACHED 0x02000000 /* ?? ignore in most places */ +# define THR_BOUND 0 /* ?? ignore in most places */ +# define THR_NEW_LWP 0 /* ?? ignore in most places */ +# define THR_DAEMON 0 /* ?? ignore in most places */ +# define THR_JOINABLE 0 /* ?? ignore in most places */ # define THR_SUSPENDED CREATE_SUSPENDED # define THR_USE_AFX 0x01000000 # define THR_SCHED_FIFO 0 @@ -3126,8 +3113,6 @@ struct iovec { size_t iov_len; // byte count to read/write char *iov_base; // data to be read/written - - operator WSABUF &(void) { return *((WSABUF *) this); } }; struct msghdr @@ -3483,16 +3468,9 @@ typedef void (*__sighandler_t)(int); // keep Signal compilation happy # include /**/ <sys/time.h> # include /**/ <sys/wait.h> # include /**/ <pwd.h> - // sets O_NDELAY -# include /**/ <unix.h> -# include /**/ <sys/param.h> /* for NBBY */ - typedef long fd_mask; -# if !defined (NFDBITS) -# define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */ -# endif /* ! NFDBITS */ -# if !defined (howmany) +# ifndef howmany # define howmany(x, y) (((x)+((y)-1))/(y)) -# endif /* ! howmany */ +# endif /* howmany */ # elif ! defined (VXWORKS) # include /**/ <sys/uio.h> # include /**/ <sys/ipc.h> @@ -4165,9 +4143,7 @@ union semun // Max size of an ACE Token client ID. # define ACE_MAXCLIENTIDLEN MAXHOSTNAMELEN + 20 -// // Create some useful typedefs. -// typedef const char **SYS_SIGLIST; typedef void *(*ACE_THR_FUNC)(void *); // This is for C++ static methods. @@ -4231,12 +4207,6 @@ struct ACE_Export siginfo_t }; # endif /* ACE_HAS_SIGINFO_T */ -// Typedef for the null handler func. -extern "C" -{ - typedef void (*ACE_SIGNAL_C_FUNC)(int,siginfo_t*,void*); -} - # if !defined (ACE_HAS_UCONTEXT_T) typedef int ucontext_t; # endif /* ACE_HAS_UCONTEXT_T */ @@ -4709,251 +4679,6 @@ extern "C" { typedef int (*ACE_COMPARE_FUNC)(const void *, const void *); } -class ACE_Export ACE_Errno_Guard -{ - // = TITLE - // Provides a wrapper to improve performance when thread-specific - // errno must be saved and restored in a block of code. - // - // = DESCRIPTION - // The typical use-case for this is the following: - // - // int error = errno; - // call_some_function_that_might_change_errno (); - // errno = error; - // - // This can be replaced with - // - // { - // ACE_Errno_Guard guard (errno); - // call_some_function_that_might_change_errno (); - // } - // - // This implementation is more elegant and more efficient since it - // avoids an unnecessary second access to thread-specific storage - // by caching a pointer to the value of errno in TSS. -public: - // = Initialization and termination methods. - ACE_Errno_Guard (int &errno_ref, - int error); - // Stash the value of <error> into <error_> and initialize the - // <errno_ptr_> to the address of <errno_ref>. - - ACE_Errno_Guard (int &errno_ref); - // Stash the value of <errno> into <error_> and initialize the - // <errno_ptr_> to the address of <errno_ref>. - - ~ACE_Errno_Guard (void); - // Reset the value of <errno> to <error>. - - int operator= (int error); - // Assign <error> to <error_>. - - int operator== (int error); - // Compare <error> with <error_> for equality. - - int operator!= (int error); - // Compare <error> with <error_> for inequality. - -private: -#if defined (ACE_MT_SAFE) - int *errno_ptr_; -#endif /* ACE_MT_SAFE */ - int error_; -}; - -#if defined (ACE_HAS_WINSOCK2) -typedef SERVICETYPE ACE_SERVICE_TYPE; -typedef GROUP ACE_SOCK_GROUP; -typedef WSAPROTOCOL_INFO ACE_Protocol_Info; -#else -typedef u_long ACE_SOCK_GROUP; -typedef u_long ACE_SERVICE_TYPE; -typedef u_long ACE_Protocol_Info; -#endif /* SERVICETYPE */ - -class ACE_Export ACE_Flow_Spec -#if defined (ACE_HAS_WINSOCK2) - : public FLOWSPEC -#endif /* ACE_HAS_WINSOCK2 */ -{ - // = TITLE - // Wrapper class that defines the flow spec QoS information, which - // is used by RSVP. -public: - // = Get/set the token rate in bytes/sec. - u_long token_rate (void); - void token_rate (u_long tr); - - // = Get/set the token bucket size in bytes. - u_long token_bucket_size (void); - void token_bucket_size (u_long tbs); - - // = Get/set the PeakBandwidth in bytes/sec. - u_long peak_bandwidth (void); - void peak_bandwidth (u_long pb); - - // = Get/set the latency in microseconds. - u_long latency (void); - void latency (u_long l); - - // = Get/set the delay variation in microseconds. - u_long delay_variation (void); - void delay_variation (u_long dv); - - // = Get/set the service type. - ACE_SERVICE_TYPE service_type (void); - void service_type (ACE_SERVICE_TYPE st); - - // = Get/set the maximum SDU size in bytes. - u_long max_sdu_size (void); - void max_sdu_size (u_long mss); - - // = Get/set the minimum policed size in bytes. - u_long minimum_policed_size (void); - void minimum_policed_size (u_long mps); -}; - -class ACE_Export ACE_QoS -#if defined (ACE_HAS_WINSOCK2) - : public QOS -#endif /* ACE_HAS_WINSOCK2 */ -{ - // = TITLE - // Wrapper class that holds the sender and receiver flow spec - // information, which is used by RSVP. -public: - // = Get/set the flow spec for data sending. - ACE_Flow_Spec sending_flowspec (void); - void sending_flowspec (const ACE_Flow_Spec &fs); - - // = Get/set the flow spec for data receiving. - ACE_Flow_Spec receiving_flowspec (void); - void receiving_flowspec (const ACE_Flow_Spec &fs); - - // = Get/set the provider specific information. - iovec provider_specific (void); - void provider_specific (const iovec &ps); -}; - -class ACE_Export ACE_Connect_QoS_Params -{ - // = TITLE - // Wrapper class that simplifies the information passed to the QoS - // enabled <ACE_OS::connect> and <ACE_OS::join_leaf> methods. -public: - ACE_Connect_QoS_Params (iovec *caller_data = 0, - iovec *callee_data = 0, - ACE_QoS *socket_qos = 0, - ACE_QoS *group_socket_qos = 0, - u_long flags = 0); - // Initialize the data members. The <caller_data> is a pointer to - // the user data that is to be transferred to the peer during - // connection establishment. The <callee_data> is a pointer to the - // user data that is to be transferred back from the peer during - // connection establishment. The_<socket_qos> is a pointer to the - // flow speicfications for the socket, one for each direction. The - // <group_socket_qos> is a pointer to the flow speicfications for - // the socket group, if applicable. The_<flags> indicate if we're a - // sender, receiver, or both. - - // = Get/set caller data. - iovec *caller_data (void) const; - void caller_data (iovec *); - - // = Get/set callee data. - iovec *callee_data (void) const; - void callee_data (iovec *); - - // = Get/set socket qos. - ACE_QoS *socket_qos (void) const; - void socket_qos (ACE_QoS *); - - // = Get/set group socket qos. - ACE_QoS *group_socket_qos (void) const; - void group_socket_qos (ACE_QoS *); - - // = Get/set flags. - u_long flags (void) const; - void flags (u_long); - -private: - iovec *caller_data_; - // A pointer to the user data that is to be transferred to the peer - // during connection establishment. - - iovec *callee_data_; - // A pointer to the user data that is to be transferred back from - // the peer during connection establishment. - - ACE_QoS *socket_qos_; - // A pointer to the flow speicfications for the socket, one for each - // direction. - - ACE_QoS *group_socket_qos_; - // A pointer to the flow speicfications for the socket group, if - // applicable. - - u_long flags_; - // Flags that indicate if we're a sender, receiver, or both. -}; - -// Callback function that's used by the QoS-enabled <ACE_OS::accept> -// method. -typedef int (*ACE_QOS_CONDITION_FUNC) (iovec *caller_id, - iovec *caller_data, - ACE_QoS *socket_qos, - ACE_QoS *group_socket_qos, - iovec *callee_id, - iovec *callee_data, - ACE_SOCK_GROUP *g, - u_long callbackdata); - -// Callback function that's used by the QoS-enabled <ACE_OS::ioctl> -// method. -typedef void (*ACE_OVERLAPPED_COMPLETION_FUNC) (u_long error, - u_long bytes_transferred, - ACE_OVERLAPPED *overlapped, - u_long flags); -class ACE_Export ACE_Accept_QoS_Params -{ - // = TITLE - // Wrapper class that simplifies the information passed to the QoS - // enabled <ACE_OS::accept> method. -public: - ACE_Accept_QoS_Params (ACE_QOS_CONDITION_FUNC qos_condition_callback = 0, - u_long callback_data = 0); - // Initialize the data members. The <qos_condition_callback> is the - // address of an optional, application-supplied condition function - // that will make an accept/reject decision based on the caller - // information pass in as parameters, and optionally create or join - // a socket group by assinging an appropriate value to the result - // parameter <g> of this function. The <callback_data> data is - // passed back to the application as a condition function parameter, - // i.e., it is an Asynchronous Completion Token (ACT). - - // = Get/set QoS condition callback. - ACE_QOS_CONDITION_FUNC qos_condition_callback (void) const; - void qos_condition_callback (ACE_QOS_CONDITION_FUNC qcc); - - // = Get/Set callback data. - u_long callback_data (void) const; - void callback_data (u_long cd); - -private: - ACE_QOS_CONDITION_FUNC qos_condition_callback_; - // This is the address of an optional, application-supplied - // condition function that will make an accept/reject decision based - // on the caller information pass in as parameters, and optionally - // create or join a socket group by assinging an appropriate value - // to the result parameter <g> of this function. - - u_long callback_data_; - // This data is passed back to the application as a condition - // function parameter, i.e., it is an Asynchronous Completion Token - // (ACT). -}; - class ACE_Export ACE_OS { // = TITLE @@ -5338,9 +5063,9 @@ public: static int memcmp (const void *t, const void *s, size_t len); - static const void *memchr (const void *s, - int c, - size_t len); + static void *memchr(const void *s, + int c, + size_t len); static void *memcpy (void *t, const void *s, size_t len); @@ -5465,17 +5190,6 @@ public: static int ioctl (ACE_HANDLE handle, int cmd, void * = 0); - // UNIX-style <ioctl>. - static int ioctl (ACE_HANDLE socket, - u_long io_control_code, - void *in_buffer_p, - u_long in_buffer, - void *out_buffer_p, - u_long out_buffer, - u_long *bytes_returned, - ACE_OVERLAPPED *overlapped, - ACE_OVERLAPPED_COMPLETION_FUNC func); - // QoS-enabled <ioctl>. static int isastream (ACE_HANDLE handle); static int isatty (ACE_HANDLE handle); static off_t lseek (ACE_HANDLE handle, @@ -5704,29 +5418,12 @@ public: static ACE_HANDLE accept (ACE_HANDLE handle, struct sockaddr *addr, int *addrlen); - // BSD-style <accept> (no QoS). - static ACE_HANDLE accept (ACE_HANDLE handle, - struct sockaddr *addr, - int *addrlen, - const ACE_Accept_QoS_Params &qos_params); - // QoS-enabled <accept>, which passes <qos_params> to <accept>. If - // the OS platform doesn't support QoS-enabled <accept> then the - // <qos_params> are ignored and the BSD-style <accept> is called. static int bind (ACE_HANDLE s, struct sockaddr *name, int namelen); static int connect (ACE_HANDLE handle, struct sockaddr *addr, int addrlen); - // BSD-style <connect> (no QoS). - static int connect (ACE_HANDLE handle, - const sockaddr *addr, - int addrlen, - const ACE_Connect_QoS_Params &qos_params); - // QoS-enabled <connect>, which passes <qos_params> to <connect>. - // If the OS platform doesn't support QoS-enabled <connect> then the - // <qos_params> are ignored and the BSD-style <connect> is called. - static int closesocket (ACE_HANDLE s); static struct hostent *gethostbyaddr (const char *addr, int length, @@ -5772,6 +5469,7 @@ public: static char *inet_ntoa (const struct in_addr addr); static int inet_aton (const char *strptr, struct in_addr *addr); + static const char *inet_ntop (int family, const void *addrptr, char *strptr, @@ -5779,11 +5477,8 @@ public: static int inet_pton (int family, const char *strptr, void *addrptr); - static ACE_HANDLE join_leaf (ACE_HANDLE socket, - const sockaddr *name, - int namelen, - const ACE_Connect_QoS_Params &qos_params); - // Joins a leaf node into a QoS-enabled multi-point session. + + static int listen (ACE_HANDLE handle, int backlog); static int recv (ACE_HANDLE handle, @@ -5814,22 +5509,11 @@ public: int optname, const char *optval, int optlen); - // QoS-enabled <ioctl> wrapper. static int shutdown (ACE_HANDLE handle, int how); static ACE_HANDLE socket (int domain, int type, int proto); - // Create a BSD-style socket (no QoS). - static ACE_HANDLE socket (int domain, - int type, - int proto, - ACE_Protocol_Info *protocolinfo, - ACE_SOCK_GROUP g, - u_long flags); - // Create a QoS-enabled socket. If the OS platform doesn't support - // QoS-enabled <socket> then the BSD-style <socket> is called. - static int socketpair (int domain, int type, int protocol, @@ -7277,18 +6961,6 @@ ACE_MAIN (int argc, ASYS_TCHAR *argv[]) /* user's entry point, e.g., main */ \ } \ int \ ace_main_i -# if defined (ACE_WIN32) && defined (UNICODE) -# define wmain \ -ace_main_i (int, ASYS_TCHAR *[]); /* forward declaration */ \ -int \ -wmain (int argc, ASYS_TCHAR *argv[]) /* user's entry point, e.g., main */ \ -{ \ - ACE_MAIN_OBJECT_MANAGER \ - return ace_main_i (argc, argv); /* what the user calls "main" */ \ -} \ -int \ -ace_main_i -# endif /* ACE_WIN32 && UNICODE */ # endif /* ACE_PSOSIM */ # endif /* ACE_HAS_NONSTATIC_OBJECT_MANAGER && !ACE_HAS_WINCE && !ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER */ @@ -107,55 +107,6 @@ typedef const struct timespec * ACE_TIMESPEC_PTR; # include /**/ <malloc.h> #endif /* ACE_LACKS_MALLOC_H */ -ACE_INLINE -ACE_Errno_Guard::ACE_Errno_Guard (int &errno_ref, - int error) - : -#if defined (ACE_MT_SAFE) - errno_ptr_ (&errno_ref), -#endif /* ACE_MT_SAFE */ - error_ (error) -{ -} - -ACE_INLINE -ACE_Errno_Guard::ACE_Errno_Guard (int &errno_ref) - : -#if defined (ACE_MT_SAFE) - errno_ptr_ (&errno_ref), -#endif /* ACE_MT_SAFE */ - error_ (errno_ref) -{ -} - -ACE_INLINE -ACE_Errno_Guard::~ACE_Errno_Guard (void) -{ -#if defined (ACE_MT_SAFE) - *errno_ptr_ = this->error_; -#else - errno = this->error_; -#endif /* ACE_MT_SAFE */ -} - -ACE_INLINE int -ACE_Errno_Guard::operator= (int error) -{ - return this->error_ = error; -} - -ACE_INLINE int -ACE_Errno_Guard::operator== (int error) -{ - return this->error_ == error; -} - -ACE_INLINE int -ACE_Errno_Guard::operator!= (int error) -{ - return this->error_ != error; -} - // Returns the value of the object as a timeval. ACE_INLINE @@ -746,6 +697,8 @@ ACE_OS::umask (mode_t cmask) #else /* ACE_WIN32 */ +// This is for Win32 exclusively! + // Adapt the Win32 System Calls (which return BOOLEAN values of TRUE // and FALSE) into int values expected by the ACE_OSCALL macros. # define ACE_ADAPT_RETVAL(OP,RESULT) ((RESULT = (OP)) == FALSE ? -1 : 0) @@ -1243,22 +1196,22 @@ ACE_OS::memcmp (const void *t, const void *s, size_t len) return ::memcmp (t, s, len); } -ACE_INLINE const void * +ACE_INLINE void * ACE_OS::memchr (const void *s, int c, size_t len) { #if defined (ACE_HAS_MEMCHR) ACE_TRACE ("ACE_OS::memchr"); return ::memchr (s, c, len); #else - u_char *t = (u_char *) s; - u_char *e = (u_char *) s + len; - + unsigned char *t = (unsigned char *) s; + unsigned char *e = (unsigned char *) s + len; while (t < e) - if (((int) *t) == c) - return t; - else - t++; - + { + if (((int) *t) == c) + return t; + else + t++; + } return 0; #endif /* ACE_HAS_MEMCHR */ } @@ -2635,11 +2588,9 @@ ACE_OS::recursive_mutex_lock (ACE_recursive_thread_mutex_t *m) m->nesting_level_++; } - { - // Save/restore errno. - ACE_Errno_Guard error (errno); - ACE_OS::thread_mutex_unlock (&m->nesting_mutex_); - } + int error = errno; + ACE_OS::thread_mutex_unlock (&m->nesting_mutex_); + errno = error; return result; #endif /* ACE_HAS_RECURSIVE_MUTEXES */ #else @@ -2680,11 +2631,9 @@ ACE_OS::recursive_mutex_trylock (ACE_recursive_thread_mutex_t *m) } } - { - // Save/restore errno. - ACE_Errno_Guard error (errno); - ACE_OS::thread_mutex_unlock (&m->nesting_mutex_); - } + int error = errno; + ACE_OS::thread_mutex_unlock (&m->nesting_mutex_); + errno = error; return result; #endif /* ACE_HAS_RECURSIVE_MUTEXES */ #else @@ -2733,12 +2682,9 @@ ACE_TRACE ("ACE_Recursive_Thread_Mutex::release"); } } } - - { - // Save/restore errno. - ACE_Errno_Guard error (errno); - ACE_OS::thread_mutex_unlock (&m->nesting_mutex_); - } + int error = errno; + ACE_OS::thread_mutex_unlock (&m->nesting_mutex_); + errno = error; return result; #endif /* ACE_HAS_RECURSIVE_MUTEXES */ #else @@ -3675,16 +3621,16 @@ ACE_OS::rw_unlock (ACE_rwlock_t *rw) int result = 0; - ACE_Errno_Guard error (errno, 0); + int error = 0; if (rw->important_writer_ && rw->ref_count_ == 1) - // only the reader requesting to upgrade its lock is left over. + // only the reader requesting to upgrade its lock is left over { result = ACE_OS::cond_signal (&rw->waiting_important_writer_); error = errno; } else if (rw->num_waiting_writers_ > 0 && rw->ref_count_ == 0) - // give preference to writers over readers... + // Give preference to writers over readers... { result = ACE_OS::cond_signal (&rw->waiting_writers_); error = errno; @@ -3695,13 +3641,15 @@ ACE_OS::rw_unlock (ACE_rwlock_t *rw) error = errno; } + ACE_OS::mutex_unlock (&rw->lock_); + errno = error; return result; -# endif /* ! ace_lacks_rwlock_t */ +# endif /* ! ACE_LACKS_RWLOCK_T */ #else - ace_unused_arg (rw); - ace_notsup_return (-1); -#endif /* ace_has_threads */ + ACE_UNUSED_ARG (rw); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ } // Note that the caller of this method *must* already possess this @@ -4188,465 +4136,48 @@ ACE_OS::event_reset (ACE_event_t *event) # endif /* ACE_MT_SAFE && ACE_MT_SAFE != 0 */ #endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */ -ACE_INLINE u_long -ACE_Flow_Spec::token_rate (void) -{ -#if defined (ACE_HAS_WINSOCK2) - return this->TokenRate; -#else - ACE_NOTSUP_RETURN (0); -#endif /* ACE_HAS_WINSOCK2 */ -} - -ACE_INLINE void -ACE_Flow_Spec::token_rate (u_long tr) -{ -#if defined (ACE_HAS_WINSOCK2) - this->TokenRate = tr; -#else - ACE_UNUSED_ARG (tr); -#endif /* ACE_HAS_WINSOCK2 */ -} - -ACE_INLINE u_long -ACE_Flow_Spec::token_bucket_size (void) -{ -#if defined (ACE_HAS_WINSOCK2) - return this->TokenBucketSize; -#else - ACE_NOTSUP_RETURN (0); -#endif /* ACE_HAS_WINSOCK2 */ -} - -ACE_INLINE void -ACE_Flow_Spec::token_bucket_size (u_long tbs) -{ -#if defined (ACE_HAS_WINSOCK2) - this->TokenBucketSize = tbs; -#else - ACE_UNUSED_ARG (tbs); -#endif /* ACE_HAS_WINSOCK2 */ -} - -ACE_INLINE u_long -ACE_Flow_Spec::peak_bandwidth (void) -{ -#if defined (ACE_HAS_WINSOCK2) - return this->PeakBandwidth; -#else - ACE_NOTSUP_RETURN (0); -#endif /* ACE_HAS_WINSOCK2 */ -} - -ACE_INLINE void -ACE_Flow_Spec::peak_bandwidth (u_long pb) -{ -#if defined (ACE_HAS_WINSOCK2) - this->PeakBandwidth = pb; -#else - ACE_UNUSED_ARG (pb); -#endif /* ACE_HAS_WINSOCK2 */ -} - -ACE_INLINE u_long -ACE_Flow_Spec::latency (void) -{ -#if defined (ACE_HAS_WINSOCK2) - return this->Latency; -#else - ACE_NOTSUP_RETURN (0); -#endif /* ACE_HAS_WINSOCK2 */ -} - -ACE_INLINE void -ACE_Flow_Spec::latency (u_long l) -{ -#if defined (ACE_HAS_WINSOCK2) - this->Latency = l; -#else - ACE_UNUSED_ARG (l); -#endif /* ACE_HAS_WINSOCK2 */ -} - -ACE_INLINE u_long -ACE_Flow_Spec::delay_variation (void) -{ -#if defined (ACE_HAS_WINSOCK2) - return this->DelayVariation; -#else - ACE_NOTSUP_RETURN (0); -#endif /* ACE_HAS_WINSOCK2 */ -} -ACE_INLINE void -ACE_Flow_Spec::delay_variation (u_long dv) -{ -#if defined (ACE_HAS_WINSOCK2) - this->DelayVariation = dv; -#else - ACE_UNUSED_ARG (dv); -#endif /* ACE_HAS_WINSOCK2 */ -} - -ACE_INLINE ACE_SERVICE_TYPE -ACE_Flow_Spec::service_type (void) -{ -#if defined (ACE_HAS_WINSOCK2) && defined (ACE_HAS_WINNT5) - return this->ServiceType; -#else - ACE_NOTSUP_RETURN (0); -#endif /* ACE_HAS_WINSOCK2 */ -} - -ACE_INLINE void -ACE_Flow_Spec::service_type (ACE_SERVICE_TYPE st) -{ -#if defined (ACE_HAS_WINSOCK2) && defined (ACE_HAS_WINNT5) - this->ServiceType = st; -#else - ACE_UNUSED_ARG (st); -#endif /* ACE_HAS_WINSOCK2 */ -} - -ACE_INLINE u_long -ACE_Flow_Spec::max_sdu_size (void) -{ -#if defined (ACE_HAS_WINSOCK2) && defined (ACE_HAS_WINNT5) - return this->MaxSduSize; -#else - ACE_NOTSUP_RETURN (0); -#endif /* ACE_HAS_WINSOCK2 */ -} - -ACE_INLINE void -ACE_Flow_Spec::max_sdu_size (u_long mss) -{ -#if defined (ACE_HAS_WINSOCK2) && defined (ACE_HAS_WINNT5) - this->MaxSduSize = mss; -#else - ACE_UNUSED_ARG (mss); -#endif /* ACE_HAS_WINSOCK2 */ -} - -ACE_INLINE u_long -ACE_Flow_Spec::minimum_policed_size (void) -{ -#if defined (ACE_HAS_WINSOCK2) && defined (ACE_HAS_WINNT5) - return this->MinimumPolicedSize; -#else - ACE_NOTSUP_RETURN (0); -#endif /* ACE_HAS_WINSOCK2 */ -} - -ACE_INLINE void -ACE_Flow_Spec::minimum_policed_size (u_long mps) -{ -#if defined (ACE_HAS_WINSOCK2) && defined (ACE_HAS_WINNT5) - this->MinimumPolicedSize = mps; -#else - ACE_UNUSED_ARG (mps); -#endif /* ACE_HAS_WINSOCK2 */ -} - -ACE_INLINE ACE_Flow_Spec -ACE_QoS::sending_flowspec (void) -{ -#if defined (ACE_HAS_WINSOCK2) - return (ACE_Flow_Spec &) this->SendingFlowspec; -#else - ACE_NOTSUP_RETURN (ACE_Flow_Spec ()); -#endif /* ACE_HAS_WINSOCK2 */ -} - -ACE_INLINE void -ACE_QoS::sending_flowspec (const ACE_Flow_Spec &fs) -{ -#if defined (ACE_HAS_WINSOCK2) - this->SendingFlowspec = (FLOWSPEC) fs; -#else - ACE_UNUSED_ARG (fs); -#endif /* ACE_HAS_WINSOCK2 */ -} - -ACE_INLINE ACE_Flow_Spec -ACE_QoS::receiving_flowspec (void) -{ -#if defined (ACE_HAS_WINSOCK2) - return (ACE_Flow_Spec &) this->ReceivingFlowspec; -#else - ACE_NOTSUP_RETURN (ACE_Flow_Spec ()); -#endif /* ACE_HAS_WINSOCK2 */ -} - -ACE_INLINE void -ACE_QoS::receiving_flowspec (const ACE_Flow_Spec &fs) -{ -#if defined (ACE_HAS_WINSOCK2) - this->ReceivingFlowspec = (FLOWSPEC) fs; -#else - ACE_UNUSED_ARG (fs); -#endif /* ACE_HAS_WINSOCK2 */ -} - -ACE_INLINE iovec -ACE_QoS::provider_specific (void) -{ -#if defined (ACE_HAS_WINSOCK2) - return (iovec &) this->ProviderSpecific; -#else - ACE_NOTSUP_RETURN (iovec ()); -#endif /* ACE_HAS_WINSOCK2 */ -} - -ACE_INLINE void -ACE_QoS::provider_specific (const iovec &ps) -{ -#if defined (ACE_HAS_WINSOCK2) - this->ProviderSpecific = (WSABUF) ((iovec &) ps); -#else - ACE_UNUSED_ARG (ps); -#endif /* ACE_HAS_WINSOCK2 */ -} - -ACE_INLINE -ACE_Connect_QoS_Params::ACE_Connect_QoS_Params (iovec *caller_data, - iovec *callee_data, - ACE_QoS *socket_qos, - ACE_QoS *group_socket_qos, - u_long flags) - : caller_data_ (caller_data), - callee_data_ (callee_data), - socket_qos_ (socket_qos), - group_socket_qos_ (group_socket_qos), - flags_ (flags) -{ -} - -ACE_INLINE iovec * -ACE_Connect_QoS_Params::caller_data (void) const -{ - return this->caller_data_; -} - -ACE_INLINE void -ACE_Connect_QoS_Params::caller_data (iovec *cd) -{ - this->caller_data_ = cd; -} - -ACE_INLINE iovec * -ACE_Connect_QoS_Params::callee_data (void) const -{ - return this->callee_data_; -} - -ACE_INLINE void -ACE_Connect_QoS_Params::callee_data (iovec *cd) -{ - this->callee_data_ = cd; -} - -ACE_INLINE ACE_QoS * -ACE_Connect_QoS_Params::socket_qos (void) const -{ - return this->socket_qos_; -} - -ACE_INLINE void -ACE_Connect_QoS_Params::socket_qos (ACE_QoS *sq) -{ - this->socket_qos_ = sq; -} - -ACE_INLINE ACE_QoS * -ACE_Connect_QoS_Params::group_socket_qos (void) const -{ - return this->group_socket_qos_; -} - -ACE_INLINE void -ACE_Connect_QoS_Params::group_socket_qos (ACE_QoS *gsq) -{ - this->group_socket_qos_ = gsq; -} - -ACE_INLINE u_long -ACE_Connect_QoS_Params::flags (void) const -{ - return this->flags_; -} - -ACE_INLINE void -ACE_Connect_QoS_Params::flags (u_long f) -{ - this->flags_ = f; -} - -ACE_INLINE -ACE_Accept_QoS_Params::ACE_Accept_QoS_Params (ACE_QOS_CONDITION_FUNC qos_condition_callback, - u_long callback_data) - : qos_condition_callback_ (qos_condition_callback), - callback_data_ (callback_data) -{ -} - -ACE_INLINE ACE_QOS_CONDITION_FUNC -ACE_Accept_QoS_Params::qos_condition_callback (void) const -{ - return this->qos_condition_callback_; -} - -ACE_INLINE void -ACE_Accept_QoS_Params::qos_condition_callback (ACE_QOS_CONDITION_FUNC qcc) -{ - this->qos_condition_callback_ = qcc; -} - -ACE_INLINE u_long -ACE_Accept_QoS_Params::callback_data (void) const -{ - return this->callback_data_; -} - -ACE_INLINE void -ACE_Accept_QoS_Params::callback_data (u_long cd) -{ - this->callback_data_ = cd; -} ACE_INLINE ACE_HANDLE -ACE_OS::accept (ACE_HANDLE handle, - struct sockaddr *addr, +ACE_OS::accept (ACE_HANDLE handle, struct sockaddr *addr, int *addrlen) { ACE_TRACE ("ACE_OS::accept"); #if defined (ACE_PSOS) # if !defined (ACE_PSOS_DIAB_PPC) - ACE_SOCKCALL_RETURN (::accept ((ACE_SOCKET) handle, - (struct sockaddr_in *) addr, - (ACE_SOCKET_LEN *) addrlen), - ACE_HANDLE, - ACE_INVALID_HANDLE); +ACE_SOCKCALL_RETURN (::accept ((ACE_SOCKET) handle, (struct sockaddr_in *) addr, + (ACE_SOCKET_LEN *) addrlen), + ACE_HANDLE, ACE_INVALID_HANDLE); # else -ACE_SOCKCALL_RETURN (::accept ((ACE_SOCKET) handle, - (struct sockaddr *) addr, - (ACE_SOCKET_LEN *) addrlen), - ACE_HANDLE, - ACE_INVALID_HANDLE); +ACE_SOCKCALL_RETURN (::accept ((ACE_SOCKET) handle, (struct sockaddr *) addr, + (ACE_SOCKET_LEN *) addrlen), + ACE_HANDLE, ACE_INVALID_HANDLE); # endif /* defined ACE_PSOS_DIAB_PPC */ #else - // On a non-blocking socket with no connections to accept, this - // system call will return EWOULDBLOCK or EAGAIN, depending on the - // platform. UNIX 98 allows either errno, and they may be the same - // numeric value. So to make life easier for upper ACE layers as - // well as application programmers, always change EAGAIN to - // EWOULDBLOCK. Rather than hack the ACE_OSCALL_RETURN macro, it's - // handled explicitly here. If the ACE_OSCALL macro ever changes, - // this function needs to be reviewed. On Win32, the regular macros - // can be used, as this is not an issue. + // On a non-blocking socket with no connections to accept, this system + // call will return EWOULDBLOCK or EAGAIN, depending on the platform. + // UNIX 98 allows either errno, and they may be the same numeric value. + // So to make life easier for upper ACE layers as well as application + // programmers, always change EAGAIN to EWOULDBLOCK. Rather than hack the + // ACE_OSCALL_RETURN macro, it's handled explicitly here. If the ACE_OSCALL + // macro ever changes, this function needs to be reviewed. + // On Win32, the regular macros can be used, as this is not an issue. # if defined (ACE_WIN32) - ACE_SOCKCALL_RETURN (::accept ((ACE_SOCKET) handle, - addr, - (ACE_SOCKET_LEN *) addrlen), - ACE_HANDLE, - ACE_INVALID_HANDLE); + ACE_SOCKCALL_RETURN (::accept ((ACE_SOCKET) handle, addr, (ACE_SOCKET_LEN *) addrlen), + ACE_HANDLE, ACE_INVALID_HANDLE); # else - ACE_HANDLE ace_result = ::accept ((ACE_SOCKET) handle, - addr, - (ACE_SOCKET_LEN *) addrlen) ; - if (ace_result == ACE_INVALID_HANDLE && errno == EAGAIN) + + ACE_HANDLE ace_result_; + ace_result_ = ::accept ((ACE_SOCKET) handle, addr, + (ACE_SOCKET_LEN *) addrlen) ; + if (ace_result_ == ACE_INVALID_HANDLE && errno == EAGAIN) errno = EWOULDBLOCK; - return ace_result; + return ace_result_; # endif /* defined (ACE_WIN32) */ #endif /* defined (ACE_PSOS) */ } -ACE_INLINE ACE_HANDLE -ACE_OS::accept (ACE_HANDLE handle, - struct sockaddr *addr, - int *addrlen, - const ACE_Accept_QoS_Params &qos_params) -{ -#if defined (ACE_HAS_WINSOCK2) - ACE_SOCKCALL_RETURN (::WSAAccept ((ACE_SOCKET) handle, - addr, - (ACE_SOCKET_LEN *) addrlen, - (LPCONDITIONPROC) qos_params.qos_condition_callback (), - qos_params.callback_data ()), - ACE_HANDLE, - ACE_INVALID_HANDLE); -#else - ACE_UNUSED_ARG (qos_params); - return ACE_OS::accept (handle, - addr, - addrlen); -#endif /* ACE_HAS_WINSOCK2 */ -} - -ACE_INLINE ACE_HANDLE -ACE_OS::join_leaf (ACE_HANDLE socket, - const sockaddr *name, - int namelen, - const ACE_Connect_QoS_Params &qos_params) -{ -#if defined (ACE_HAS_WINSOCK2) - ACE_SOCKCALL_RETURN (::WSAJoinLeaf ((ACE_SOCKET) socket, - name, - namelen, - (WSABUF *) qos_params.caller_data (), - (WSABUF *) qos_params.callee_data (), - (QOS *) qos_params.socket_qos (), - (QOS *) qos_params.group_socket_qos (), - qos_params.flags ()), - ACE_HANDLE, - ACE_INVALID_HANDLE); -#else - ACE_UNUSED_ARG (socket); - ACE_UNUSED_ARG (name); - ACE_UNUSED_ARG (namelen); - ACE_UNUSED_ARG (qos_params); - ACE_NOTSUP_RETURN (ACE_INVALID_HANDLE); -#endif /* ACE_HAS_WINSOCK2 */ -} - -ACE_INLINE int -ACE_OS::ioctl (ACE_HANDLE socket, - u_long io_control_code, - void *in_buffer_p, - u_long in_buffer, - void *out_buffer_p, - u_long out_buffer, - u_long *bytes_returned, - ACE_OVERLAPPED *overlapped, - ACE_OVERLAPPED_COMPLETION_FUNC func) -{ -#if defined (ACE_HAS_WINSOCK2) - ACE_SOCKCALL_RETURN (::WSAIoctl ((ACE_SOCKET) socket, - io_control_code, - in_buffer_p, - in_buffer, - out_buffer_p, - out_buffer, - bytes_returned, - (WSAOVERLAPPED *) overlapped, - (LPWSAOVERLAPPED_COMPLETION_ROUTINE) func), - int, - SOCKET_ERROR); -#else - ACE_UNUSED_ARG (socket); - ACE_UNUSED_ARG (io_control_code); - ACE_UNUSED_ARG (in_buffer_p); - ACE_UNUSED_ARG (in_buffer); - ACE_UNUSED_ARG (out_buffer_p); - ACE_UNUSED_ARG (out_buffer); - ACE_UNUSED_ARG (bytes_returned); - ACE_UNUSED_ARG (overlapped); - ACE_UNUSED_ARG (func); - ACE_NOTSUP_RETURN (ACE_INVALID_HANDLE); -#endif /* ACE_HAS_WINSOCK2 */ -} - ACE_INLINE int ACE_OS::bind (ACE_HANDLE handle, struct sockaddr *addr, int addrlen) { @@ -4661,9 +4192,7 @@ ACE_OS::bind (ACE_HANDLE handle, struct sockaddr *addr, int addrlen) } ACE_INLINE int -ACE_OS::connect (ACE_HANDLE handle, - struct sockaddr *addr, - int addrlen) +ACE_OS::connect (ACE_HANDLE handle, struct sockaddr *addr, int addrlen) { ACE_TRACE ("ACE_OS::connect"); #if defined (ACE_PSOS) && !defined (ACE_PSOS_DIAB_PPC) @@ -4675,30 +4204,6 @@ ACE_OS::connect (ACE_HANDLE handle, #endif /* defined (ACE_PSOS) && !defined (ACE_PSOS_DIAB_PPC) */ } -ACE_INLINE int -ACE_OS::connect (ACE_HANDLE handle, - const sockaddr *addr, - int addrlen, - const ACE_Connect_QoS_Params &qos_params) -{ - ACE_TRACE ("ACE_OS::connect"); -#if defined (ACE_HAS_WINSOCK2) - ACE_SOCKCALL_RETURN (::WSAConnect ((ACE_SOCKET) handle, - (const sockaddr *) addr, - (ACE_SOCKET_LEN) addrlen, - (WSABUF *) qos_params.caller_data (), - (WSABUF *) qos_params.callee_data (), - (QOS *) qos_params.socket_qos (), - (QOS *) qos_params.group_socket_qos ()), - int, -1); -#else - ACE_UNUSED_ARG (qos_params); - return ACE_OS::connect (handle, - (sockaddr *) addr, - addrlen); -#endif /* ACE_HAS_WINSOCK2 */ -} - #if !defined (VXWORKS) ACE_INLINE struct hostent * ACE_OS::gethostbyname (const char *name) @@ -5109,46 +4614,11 @@ ACE_OS::shutdown (ACE_HANDLE handle, int how) } ACE_INLINE ACE_HANDLE -ACE_OS::socket (int domain, - int type, - int proto) +ACE_OS::socket (int domain, int type, int proto) { ACE_TRACE ("ACE_OS::socket"); - ACE_SOCKCALL_RETURN (::socket (domain, - type, - proto), - ACE_HANDLE, - ACE_INVALID_HANDLE); -} - -ACE_INLINE ACE_HANDLE -ACE_OS::socket (int domain, - int type, - int proto, - ACE_Protocol_Info *protocolinfo, - ACE_SOCK_GROUP g, - u_long flags) -{ - ACE_TRACE ("ACE_OS::socket"); - -#if defined (ACE_HAS_WINSOCK2) - ACE_SOCKCALL_RETURN (::WSASocket (domain, - type, - proto, - protocolinfo, - g, - flags), - ACE_HANDLE, - ACE_INVALID_HANDLE); -#else - ACE_UNUSED_ARG (protocolinfo); - ACE_UNUSED_ARG (g); - ACE_UNUSED_ARG (flags); - - return ACE_OS::socket (domain, - type, - proto); -#endif /* ACE_HAS_WINSOCK2 */ + ACE_SOCKCALL_RETURN (::socket (domain, type, proto), + ACE_HANDLE, ACE_INVALID_HANDLE); } ACE_INLINE int @@ -5550,14 +5020,12 @@ ACE_OS::gethostbyname_r (const char *name, hostent *result, ACE_UNUSED_ARG (h_errnop); ACE_NOTSUP_RETURN (0); # elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) -# if defined (DIGITAL_UNIX) || \ - (defined (ACE_AIX_MINOR_VERS) && (ACE_AIX_MINOR_VERS > 2)) +# if defined (DIGITAL_UNIX) ACE_UNUSED_ARG (result); ACE_UNUSED_ARG (buffer); ACE_UNUSED_ARG (h_errnop); - // gethostbyname returns thread-specific storage on Digital Unix and - // AIX 4.3 + // gethostbyname returns thread-specific storage on Digital Unix ACE_SOCKCALL_RETURN (::gethostbyname (name), struct hostent *, 0); # elif defined (AIX) || defined (HPUX_10) ::memset (buffer, 0, sizeof (ACE_HOSTENT_DATA)); @@ -5744,8 +5212,8 @@ ACE_OS::inet_ntop (int family, const void *addrptr, char *strptr, size_t len) #if defined (ACE_HAS_IP6) ACE_OSCALL_RETURN (::inet_ntop (family, addrptr, strptr, len), const char *, 0); #else - const u_char *p = - ACE_reinterpret_cast (const u_char *, addrptr); + const unsigned char *p = + ACE_reinterpret_cast (const unsigned char *, addrptr); if (family == AF_INET) { @@ -6027,14 +5495,17 @@ ACE_OS::thr_getspecific (ACE_OS_thread_key_t key, void **data) // of ACE_Log_Msg may not work correctly, so we're keeping this as // it is for now. - ACE_Errno_Guard error (errno); + int error = errno; *data = ::TlsGetValue (key); # if !defined (ACE_HAS_WINCE) - if (*data == 0 && (error = ::GetLastError ()) != NO_ERROR) + if (*data == 0 && (errno = ::GetLastError ()) != NO_ERROR) return -1; else # endif /* ACE_HAS_WINCE */ - return 0; + { + errno = error; + return 0; + } # endif /* ACE_HAS_STHREADS */ #else ACE_UNUSED_ARG (key); @@ -6172,15 +5643,18 @@ ACE_OS::thr_getspecific (ACE_thread_key_t key, void **data) // of ACE_Log_Msg may not work correctly, so we're keeping this as // it is for now. - ACE_Errno_Guard error (errno); + int error = errno; *data = ::TlsGetValue (key); # if !defined (ACE_HAS_WINCE) - if (*data == 0 && (error = ::GetLastError ()) != NO_ERROR) + if (*data == 0 && (errno = ::GetLastError ()) != NO_ERROR) return -1; else # endif /* ACE_HAS_WINCE */ - return 0; + { + errno = error; + return 0; + } # else ACE_UNUSED_ARG (key); ACE_UNUSED_ARG (data); @@ -7075,7 +6549,7 @@ ACE_OS::t_error (const char *errmsg) ACE_TRACE ("ACE_OS::t_error"); #if defined (ACE_HAS_TLI) #if defined (ACE_HAS_BROKEN_T_ERROR) - ::t_error (ACE_const_cast (char *, errmsg)); + ::t_error ((char *) errmsg); #else ::t_error (errmsg); #endif /* ACE_HAS_BROKEN_T_ERROR */ @@ -9379,7 +8853,7 @@ ACE_OS::gethrtime (const ACE_HRTimer_Op op) # if defined (ACE_LACKS_LONGLONG_T) ACE_UINT32 least, most; ACE_OS::memcpy (&least, &now, sizeof (ACE_UINT32)); - ACE_OS::memcpy (&most, (u_char *) &now + sizeof (ACE_UINT32), + ACE_OS::memcpy (&most, (unsigned char *) &now + sizeof (ACE_UINT32), sizeof (ACE_UINT32)); ACE_hrtime_t ret (least, most); @@ -11477,5 +10951,3 @@ ACE_OS_CString::wchar_rep (void) { return this->rep_; } - - diff --git a/ace/POSIX_Proactor.cpp b/ace/POSIX_Proactor.cpp index 9738b4f1c1a..eb89f8fa7ed 100644 --- a/ace/POSIX_Proactor.cpp +++ b/ace/POSIX_Proactor.cpp @@ -1022,9 +1022,7 @@ ACE_POSIX_SIG_Proactor::setup_signal_handler (int signal_number) const // Lynx says, it is better to set this bit, to be portable. reaction.sa_flags &= SA_SIGACTION; #endif /* SA_SIGACTION */ - // Null handler function. - reaction.sa_sigaction = - ACE_SIGNAL_C_FUNC (&ACE_POSIX_SIG_Proactor::null_handler); + reaction.sa_sigaction = null_handler; // Null handler function. int sigaction_return = sigaction (signal_number, &reaction, 0); diff --git a/ace/POSIX_Proactor.h b/ace/POSIX_Proactor.h index d9af1faa1c6..5308a582550 100644 --- a/ace/POSIX_Proactor.h +++ b/ace/POSIX_Proactor.h @@ -359,7 +359,7 @@ public: const ACE_Time_Value &tv, ACE_HANDLE event = ACE_INVALID_HANDLE, int priority = 0, - int signal_number = ACE_SIGRTMIN); + int signal_number = ACE_SIGRTMIN) ; // If <signal_number> is -1, check with the Proactor and use one of // the signals that is present in the mask set (i.e. the signals for // which the Proactor will be waiting) of the Proactor. If there are diff --git a/ace/Pipe.cpp b/ace/Pipe.cpp index e76ccd73e2b..fa25315f78f 100644 --- a/ace/Pipe.cpp +++ b/ace/Pipe.cpp @@ -41,7 +41,7 @@ ACE_Pipe::open (void) else { ACE_INET_Addr sv_addr (my_addr.get_port_number (), - ACE_LOCALHOST); + ASYS_TEXT ("localhost")); // Establish a connection within the same process. if (connector.connect (writer, sv_addr) == -1) diff --git a/ace/Process_Manager.cpp b/ace/Process_Manager.cpp index d1d3f0ada79..f3581390241 100644 --- a/ace/Process_Manager.cpp +++ b/ace/Process_Manager.cpp @@ -265,9 +265,12 @@ ACE_Process_Manager::terminate (pid_t pid) if (result == -1) { - // Save/restore errno. - ACE_Errno_Guard error (errno); + // We need to save this across calls to remove_thr() since that + // call may reset errno. + int error = errno; + this->remove (this->proc_table_[i].proc_id_); + errno = error; return -1; } else diff --git a/ace/RB_Tree.h b/ace/RB_Tree.h index 7b61793711a..2c54983e515 100644 --- a/ace/RB_Tree.h +++ b/ace/RB_Tree.h @@ -465,12 +465,26 @@ class ACE_RB_Tree_Iterator_Base { // = TITLE // Implements a common base class for iterators for a Red-Black Tree ADT. - public: + // = Initialization and termination methods. + + ACE_RB_Tree_Iterator_Base (const ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &tree, + int set_first); + // Constructor. Takes an ACE_RB_Tree over which to iterate, and + // an integer indicating (if non-zero) to position the iterator + // at the first element in the tree (if this integer is 0, the + // iterator is positioned at the last element in the tree). + + ACE_RB_Tree_Iterator_Base (const ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &iter); + // Copy constructor. + void operator= (const ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &iter); // Assignment operator: copies both the tree reference and the position in the tree. + ~ACE_RB_Tree_Iterator_Base (void); + // Destructor. + // = Iteration methods. int next (ACE_RB_Tree_Node<EXT_ID, INT_ID> *&next_entry) const; @@ -498,22 +512,7 @@ public: protected: - // = Initialization and termination methods. - - ACE_RB_Tree_Iterator_Base (const ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &tree, - int set_first); - // Constructor. Takes an ACE_RB_Tree over which to iterate, and - // an integer indicating (if non-zero) to position the iterator - // at the first element in the tree (if this integer is 0, the - // iterator is positioned at the last element in the tree). - - ACE_RB_Tree_Iterator_Base (const ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &iter); - // Copy constructor. - - ~ACE_RB_Tree_Iterator_Base (void); - // Destructor. - - // = Internal methods + // = protected methods int forward_i (void); // Move forward by one element in the tree. Returns 0 when diff --git a/ace/Remote_Tokens.cpp b/ace/Remote_Tokens.cpp index 72881602d7d..928a9b98de3 100644 --- a/ace/Remote_Tokens.cpp +++ b/ace/Remote_Tokens.cpp @@ -257,10 +257,9 @@ ACE_Remote_Token_Proxy::tryacquire (void (*sleep_hook)(void *)) { if (debug_) { - // Save/restore errno. - ACE_Errno_Guard error (errno); - ACE_DEBUG ((LM_DEBUG, - ASYS_TEXT ("shadow try acquire failed\n"))); + int error = errno; + ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("shadow try acquire failed\n"))); + errno = error; } return -1; @@ -308,14 +307,11 @@ ACE_Remote_Token_Proxy::renew (int requeue_position, if (result == -1) { - { - // Save/restore errno. - ACE_Errno_Guard error (errno); - ACE_Token_Proxy::release (); - } - ACE_ERROR_RETURN ((LM_ERROR, - "%p error on remote renew, releasing shadow mutex.\n", - "ACE_Remote_Token_Proxy"), -1); + int error = errno; + ACE_Token_Proxy::release (); + errno = error; + ACE_ERROR_RETURN ((LM_ERROR, "%p error on remote renew, releasing shadow mutex.\n", + "ACE_Remote_Token_Proxy"), -1); } else { diff --git a/ace/SOCK_Acceptor.cpp b/ace/SOCK_Acceptor.cpp index 04c8553631e..f86f37c67b5 100644 --- a/ace/SOCK_Acceptor.cpp +++ b/ace/SOCK_Acceptor.cpp @@ -21,75 +21,6 @@ ACE_SOCK_Acceptor::ACE_SOCK_Acceptor (void) ACE_TRACE ("ACE_SOCK_Acceptor::ACE_SOCK_Acceptor"); } -// Performs the timed accept operation. - -int -ACE_SOCK_Acceptor::shared_accept_start (ACE_Time_Value *timeout, - int restart, - int &in_blocking_mode) const -{ - ACE_TRACE ("ACE_SOCK_Acceptor::shared_accept_start"); - - ACE_HANDLE handle = this->get_handle (); - - // Handle the case where we're doing a timed <accept>. - if (timeout != 0) - { - if (ACE::handle_timed_accept (handle, - timeout, - restart) == -1) - return -1; - else - { - in_blocking_mode = ACE_BIT_DISABLED (ACE::get_flags (handle), - ACE_NONBLOCK); - // Set the handle into non-blocking mode if it's not already - // in it. - if (in_blocking_mode - && ACE::set_flags (handle, - ACE_NONBLOCK) == -1) - return -1; - } - } - - return 0; -} - -int -ACE_SOCK_Acceptor::shared_accept_finish (ACE_SOCK_Stream new_stream, - int in_blocking_mode, - int reset_new_handle) const -{ - ACE_TRACE ("ACE_SOCK_Acceptor::shared_accept_finish ()"); - - ACE_HANDLE new_handle = new_stream.get_handle (); - - // Check to see if we were originally in blocking mode, and if so, - // set the <new_stream>'s handle and <this> handle to be in blocking - // mode. - if (in_blocking_mode) - { - // Save/restore errno. - ACE_Errno_Guard error (errno); - // Only disable ACE_NONBLOCK if we weren't in - // non-blocking mode originally. - ACE::clr_flags (this->get_handle (), - ACE_NONBLOCK); - ACE::clr_flags (new_handle, - ACE_NONBLOCK); - } - -#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) - if (reset_new_handle) - // Reset the event association inherited by the new handle. - ::WSAEventSelect ((SOCKET) new_handle, 0, 0); -#else - ACE_UNUSED_ARG (reset_new_handle); -#endif /* ACE_WIN32 */ - - return new_handle == ACE_INVALID_HANDLE ? -1 : 0; -} - // General purpose routine for accepting new connections. int @@ -101,97 +32,13 @@ ACE_SOCK_Acceptor::accept (ACE_SOCK_Stream &new_stream, { ACE_TRACE ("ACE_SOCK_Acceptor::accept"); - int in_blocking_mode = 0; - if (this->shared_accept_start (timeout, - restart, - in_blocking_mode) == -1) - return -1; - else - { - // On Win32 the third parameter to <accept> must be a NULL - // pointer if we want to ignore the client's address. - int *len_ptr = 0; - sockaddr *addr = 0; - int len = 0; - - if (remote_addr != 0) - { - len = remote_addr->get_size (); - len_ptr = &len; - addr = (sockaddr *) remote_addr->get_addr (); - } - - do - new_stream.set_handle (ACE_OS::accept (this->get_handle (), - addr, - len_ptr)); - while (new_stream.get_handle () == ACE_INVALID_HANDLE - && restart != 0 - && errno == EINTR - && timeout == 0); - - // Reset the size of the addr, which is only necessary for UNIX - // domain sockets. - if (new_stream.get_handle () != ACE_INVALID_HANDLE - && remote_addr != 0) - remote_addr->set_size (len); - } - - return this->shared_accept_finish (new_stream, - in_blocking_mode, - reset_new_handle); -} - -int -ACE_SOCK_Acceptor::accept (ACE_SOCK_Stream &new_stream, - ACE_Accept_QoS_Params qos_params, - ACE_Addr *remote_addr, - ACE_Time_Value *timeout, - int restart, - int reset_new_handle) const -{ - ACE_TRACE ("ACE_SOCK_Acceptor::accept"); - - int in_blocking_mode = 0; - if (this->shared_accept_start (timeout, - restart, - in_blocking_mode) == -1) - return -1; - else - { - // On Win32 the third parameter to <accept> must be a NULL - // pointer if we want to ignore the client's address. - int *len_ptr = 0; - int len = 0; - sockaddr *addr = 0; - - if (remote_addr != 0) - { - len = remote_addr->get_size (); - len_ptr = &len; - addr = (sockaddr *) remote_addr->get_addr (); - } - - do - new_stream.set_handle (ACE_OS::accept (this->get_handle (), - addr, - len_ptr, - qos_params)); - while (new_stream.get_handle () == ACE_INVALID_HANDLE - && restart != 0 - && errno == EINTR - && timeout == 0); - - // Reset the size of the addr, which is only necessary for UNIX - // domain sockets. - if (new_stream.get_handle () != ACE_INVALID_HANDLE - && remote_addr != 0) - remote_addr->set_size (len); - } - - return this->shared_accept_finish (new_stream, - in_blocking_mode, - reset_new_handle); + ACE_HANDLE new_handle = + this->shared_accept (remote_addr, + timeout, + restart, + reset_new_handle); + new_stream.set_handle (new_handle); + return new_handle == ACE_INVALID_HANDLE ? -1 : 0; } // General purpose routine for performing server ACE_SOCK creation. @@ -203,14 +50,9 @@ ACE_SOCK_Acceptor::ACE_SOCK_Acceptor (const ACE_Addr &local_sap, int protocol) { ACE_TRACE ("ACE_SOCK_Acceptor::ACE_SOCK_Acceptor"); - if (this->open (local_sap, - reuse_addr, - protocol_family, - backlog, - protocol) == -1) - ACE_ERROR ((LM_ERROR, - ASYS_TEXT ("%p\n"), - ASYS_TEXT ("ACE_SOCK_Acceptor"))); + if (this->open (local_sap, reuse_addr, protocol_family, + backlog, protocol) == -1) + ACE_ERROR ((LM_ERROR, ASYS_TEXT ("%p\n"), ASYS_TEXT ("ACE_SOCK_Acceptor"))); } void @@ -231,10 +73,8 @@ ACE_SOCK_Acceptor::open (const ACE_Addr &local_sap, ACE_TRACE ("ACE_SOCK_Acceptor::open"); int error = 0; - if (ACE_SOCK::open (SOCK_STREAM, - protocol_family, - protocol, - reuse_addr) == -1) + if (ACE_SOCK::open (SOCK_STREAM, protocol_family, + protocol, reuse_addr) == -1) error = 1; else if (protocol_family == PF_INET) @@ -261,20 +101,95 @@ ACE_SOCK_Acceptor::open (const ACE_Addr &local_sap, else { if (ACE_OS::bind (this->get_handle (), - ACE_reinterpret_cast (sockaddr *, - &local_inet_addr), + ACE_reinterpret_cast(sockaddr *, &local_inet_addr), sizeof local_inet_addr) == -1) error = 1; } } - else if (ACE_OS::bind (this->get_handle (), - (sockaddr *) local_sap.get_addr (), + else if (ACE_OS::bind (this->get_handle (), (sockaddr *) local_sap.get_addr (), local_sap.get_size ()) == -1) error = 1; - if (error || ACE_OS::listen (this->get_handle (), - backlog) == -1) + if (error || ACE_OS::listen (this->get_handle (), backlog) == -1) this->close (); return error ? -1 : 0; } + +// Performs the timed accept operation. + +ACE_HANDLE +ACE_SOCK_Acceptor::shared_accept (ACE_Addr *remote_addr, + ACE_Time_Value *timeout, + int restart, + int reset_new_handle) const +{ + ACE_TRACE ("ACE_SOCK_Acceptor::shared_accept"); + ACE_UNUSED_ARG (reset_new_handle); + + sockaddr *addr = 0; + int *len_ptr = 0; + int len; + ACE_HANDLE new_handle; + ACE_HANDLE handle = this->get_handle (); + + if (remote_addr != 0) + { + len = remote_addr->get_size (); + len_ptr = &len; + addr = (sockaddr *) remote_addr->get_addr (); + } + + // Handle the case where we're doing a timed <accept>. + if (timeout != 0) + { + if (ACE::handle_timed_accept (handle, timeout, restart) == -1) + return ACE_INVALID_HANDLE; + else + { + int val = ACE::get_flags (handle); + + // Set the handle into non-blocking mode if it's not already + // in it. + if (ACE_BIT_DISABLED (val, ACE_NONBLOCK) + && ACE::set_flags (handle, ACE_NONBLOCK) == -1) + return ACE_INVALID_HANDLE; + + new_handle = ACE_OS::accept (handle, addr, len_ptr); + + if (ACE_BIT_DISABLED (val, ACE_NONBLOCK)) + { + // We need to stash errno here because <ACE::clr_flags> + // may reset it. + int error = errno; + + // Only disable ACE_NONBLOCK if we weren't in + // non-blocking mode originally. + ACE::clr_flags (handle, ACE_NONBLOCK); + ACE::clr_flags (new_handle, ACE_NONBLOCK); + errno = error; + } + } + } + else + { + // Perform a blocking accept. + + do + new_handle = ACE_OS::accept (handle, addr, len_ptr); + while (new_handle == ACE_INVALID_HANDLE && restart && errno == EINTR); + } + +#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) + if (reset_new_handle) + // Reset the event association inherited by the new handle. + ::WSAEventSelect ((SOCKET) new_handle, NULL, 0); +#endif /* ACE_WIN32 */ + + // Reset the size of the addr (really only necessary for the + // UNIX domain sockets). + if (new_handle != ACE_INVALID_HANDLE && remote_addr != 0) + remote_addr->set_size (*len_ptr); + + return new_handle; +} diff --git a/ace/SOCK_Acceptor.h b/ace/SOCK_Acceptor.h index e7c301de34a..5f68e60030f 100644 --- a/ace/SOCK_Acceptor.h +++ b/ace/SOCK_Acceptor.h @@ -28,7 +28,8 @@ class ACE_Export ACE_SOCK_Acceptor : public ACE_SOCK { // = TITLE - // Defines a factory that creates new <ACE_Stream>s passively. + // Defines the format and interface for an <ACE_Stream> + // acceptor. public: // = Initialization methods. ACE_SOCK_Acceptor (void); @@ -51,26 +52,15 @@ public: int protocol = 0); // Initiate a passive mode socket. - // = Passive connection <accept> methods. + // = Passive connection acceptance method. int accept (ACE_SOCK_Stream &new_stream, ACE_Addr *remote_addr = 0, ACE_Time_Value *timeout = 0, int restart = 1, int reset_new_handle = 0) const; - // Accept a new <ACE_SOCK_Stream> connection. A <timeout> of 0 - // means block forever, a <timeout> of {0, 0} means poll. <restart> - // == 1 means "restart if interrupted," i.e., if errno == EINTR. - - int accept (ACE_SOCK_Stream &new_stream, - ACE_Accept_QoS_Params qos_params, - ACE_Addr *remote_addr = 0, - ACE_Time_Value *timeout = 0, - int restart = 1, - int reset_new_handle = 0) const; - // Accept a new <ACE_SOCK_Stream> connection using the RVSP QoS - // information in <qos_params>. A <timeout> of 0 means block - // forever, a <timeout> of {0, 0} means poll. <restart> == 1 means - // "restart if interrupted," i.e., if errno == EINTR. + // Accept a new data transfer connection. A <timeout> of 0 means + // block forever, a <timeout> of {0, 0} means poll. <restart> == 1 + // means "restart if interrupted." // = Meta-type info typedef ACE_INET_Addr PEER_ADDR; @@ -83,17 +73,11 @@ public: // Declare the dynamic allocation hooks. protected: - int shared_accept_start (ACE_Time_Value *timeout, - int restart, - int &in_blocking_mode) const; - // Perform operations that must occur before <ACE_OS::accept> is - // called. - - int shared_accept_finish (ACE_SOCK_Stream new_stream, - int in_blocking_mode, - int reset_new_handle) const; - // Perform operations that must occur after <ACE_OS::accept> is - // called. + ACE_HANDLE shared_accept (ACE_Addr *remote_addr, + ACE_Time_Value *, + int restart, + int reset_new_handle) const; + // Shared by both the ACE_LSOCK_Acceptor and ACE_SOCK_Acceptor. private: int get_remote_addr (ACE_Addr &) const; diff --git a/ace/SOCK_Connector.cpp b/ace/SOCK_Connector.cpp index 9938d839f4a..0d2c4ddabb5 100644 --- a/ace/SOCK_Connector.cpp +++ b/ace/SOCK_Connector.cpp @@ -20,15 +20,22 @@ ACE_SOCK_Connector::dump (void) const ACE_TRACE ("ACE_SOCK_Connector::dump"); } -int -ACE_SOCK_Connector::shared_connect_start (ACE_SOCK_Stream &new_stream, - ACE_Time_Value *timeout, - const ACE_Addr &local_sap, - int reuse_addr, - int protocol_family, - int protocol) +// Actively connect and produce a new ACE_SOCK_Stream if things go well... + +int +ACE_SOCK_Connector::connect (ACE_SOCK_Stream &new_stream, + const ACE_Addr &remote_sap, + ACE_Time_Value *timeout, + const ACE_Addr &local_sap, + int reuse_addr, + int /* flags */, + int /* perms */, + int protocol_family, + int protocol) { - ACE_TRACE ("ACE_SOCK_Connector::shared_connect_start"); + ACE_TRACE ("ACE_SOCK_Connector::connect"); + int result = 0; + // Only open a new socket if we don't already have a valid handle. if (new_stream.get_handle () == ACE_INVALID_HANDLE && new_stream.open (SOCK_STREAM, @@ -36,126 +43,66 @@ ACE_SOCK_Connector::shared_connect_start (ACE_SOCK_Stream &new_stream, protocol, reuse_addr) == -1) return -1; - else if (local_sap != ACE_Addr::sap_any) + + sockaddr *raddr = (sockaddr *) remote_sap.get_addr (); + size_t rsize = remote_sap.get_size (); + + if (local_sap != ACE_Addr::sap_any) { sockaddr *laddr = (sockaddr *) local_sap.get_addr (); size_t size = local_sap.get_size (); - if (ACE_OS::bind (new_stream.get_handle (), - laddr, - size) == -1) + result = ACE_OS::bind (new_stream.get_handle (), + laddr, + size); + + if (result == -1) { - // Save/restore errno. - ACE_Errno_Guard error (errno); new_stream.close (); return -1; } } // Enable non-blocking, if required. - if (timeout != 0 && new_stream.enable (ACE_NONBLOCK) == -1) - return -1; - else - return 0; -} - -int -ACE_SOCK_Connector::shared_connect_finish (ACE_SOCK_Stream &new_stream, - ACE_Time_Value *timeout, - int result) -{ - ACE_TRACE ("ACE_SOCK_Connector::shared_connect_finish"); - // Save/restore errno. - ACE_Errno_Guard error (errno); - - if (result == -1 && timeout != 0) + if (timeout != 0) { - // Check whether the connection is in progress. - if (error == EINPROGRESS || error == EWOULDBLOCK) + if (new_stream.enable (ACE_NONBLOCK) == -1) + result = -1; + + if (ACE_OS::connect (new_stream.get_handle (), raddr, rsize) == -1) { - // This expression checks if we were polling. - if (timeout->sec () == 0 && timeout->usec () == 0) - error = EWOULDBLOCK; - // Wait synchronously using timeout. - else if (this->complete (new_stream, - 0, - timeout) == -1) - error = errno; - else - return 0; + result = -1; + + // Check whether the connection is in progress. + if (errno == EINPROGRESS || errno == EWOULDBLOCK) + { + // This expression checks if we were polling. + if (timeout->sec () == 0 && timeout->usec () == 0) + errno = EWOULDBLOCK; + // Wait synchronously + else if (this->complete (new_stream, 0, timeout) != -1) + return 0; + } } } + // Do a blocking connect. + else if (ACE_OS::connect (new_stream.get_handle (), raddr, rsize) == -1) + result = -1; // EISCONN is treated specially since this routine may be used to // check if we are already connected. - if (result != -1 || error == EISCONN) + if (result != -1 || errno == EISCONN) // Start out with non-blocking disabled on the <new_stream>. new_stream.disable (ACE_NONBLOCK); - else if (!(error == EWOULDBLOCK || error == ETIMEDOUT)) - new_stream.close (); - + else if (!(errno == EWOULDBLOCK || errno == ETIMEDOUT)) + { + // If things have gone wrong, close down and return an error. + int saved_errno = errno; + new_stream.close (); + errno = saved_errno; + } + return result; } -// Actively connect and produce a new ACE_SOCK_Stream if things go well... - -int -ACE_SOCK_Connector::connect (ACE_SOCK_Stream &new_stream, - const ACE_Addr &remote_sap, - ACE_Time_Value *timeout, - const ACE_Addr &local_sap, - int reuse_addr, - int /* flags */, - int /* perms */, - int protocol_family, - int protocol) -{ - ACE_TRACE ("ACE_SOCK_Connector::connect"); - if (this->shared_connect_start (new_stream, - timeout, - local_sap, - reuse_addr, - protocol_family, - protocol) == -1) - return -1; - - int result = ACE_OS::connect (new_stream.get_handle (), - (sockaddr *) remote_sap.get_addr (), - remote_sap.get_size ()); - - return this->shared_connect_finish (new_stream, - timeout, - result); -} - -int -ACE_SOCK_Connector::connect (ACE_SOCK_Stream &new_stream, - const ACE_Addr &remote_sap, - ACE_Connect_QoS_Params qos_params, - ACE_Time_Value *timeout, - const ACE_Addr &local_sap, - int reuse_addr, - int /* flags */, - int /* perms */, - int protocol_family, - int protocol) -{ - ACE_TRACE ("ACE_SOCK_Connector::connect"); - if (this->shared_connect_start (new_stream, - timeout, - local_sap, - reuse_addr, - protocol_family, - protocol) == -1) - return -1; - - int result = ACE_OS::connect (new_stream.get_handle (), - (sockaddr *) remote_sap.get_addr (), - remote_sap.get_size (), - qos_params); - - return this->shared_connect_finish (new_stream, - timeout, - result); -} // Try to complete a non-blocking connection. @@ -172,92 +119,39 @@ ACE_SOCK_Connector::complete (ACE_SOCK_Stream &new_stream, ACE_Time_Value time (0, ACE_NON_BLOCKING_BUG_DELAY); ACE_OS::sleep (time); #endif /* ACE_HAS_BROKEN_NON_BLOCKING_CONNECTS */ - ACE_HANDLE h = ACE::handle_timed_complete (new_stream.get_handle (), - tv); - // We failed to get connected. + ACE_HANDLE h = ACE::handle_timed_complete (new_stream.get_handle (), tv); + if (h == ACE_INVALID_HANDLE) { - // Save/restore errno. - ACE_Errno_Guard error (errno); + // Preserve the value of errno across the close() call. + int error = errno; new_stream.close (); + errno = error; return -1; } - else if (remote_sap != 0) + else // We've successfully connected! { - int len = remote_sap->get_size (); - sockaddr *addr = (sockaddr *) remote_sap->get_addr (); - - if (ACE_OS::getpeername (h, - addr, - &len) == -1) + if (remote_sap != 0) { - // Save/restore errno. - ACE_Errno_Guard error (errno); - new_stream.close (); - return -1; + int len; + + len = remote_sap->get_size (); + sockaddr *addr = (sockaddr *) remote_sap->get_addr (); + + if (ACE_OS::getpeername (h, addr, &len) == -1) + { + // Preserve the value of errno across the close() call. + int error = errno; + new_stream.close (); + errno = error; + return -1; + } } - } - - // Start out with non-blocking disabled on the <new_stream>. - new_stream.disable (ACE_NONBLOCK); - return 0; -} - -ACE_SOCK_Connector::ACE_SOCK_Connector (ACE_SOCK_Stream &new_stream, - const ACE_Addr &remote_sap, - ACE_Time_Value *timeout, - const ACE_Addr &local_sap, - int reuse_addr, - int flags, - int perms, - int protocol_family, - int protocol) -{ - ACE_TRACE ("ACE_SOCK_Connector::ACE_SOCK_Connector"); - if (this->connect (new_stream, - remote_sap, - timeout, - local_sap, - reuse_addr, - flags, - perms, - protocol_family, - protocol) == -1 - && timeout != 0 - && !(errno == EWOULDBLOCK || errno == ETIME)) - ACE_ERROR ((LM_ERROR, - ASYS_TEXT ("%p\n"), - ASYS_TEXT ("ACE_SOCK_Connector::ACE_SOCK_Connector"))); + // Start out with non-blocking disabled on the <new_stream>. + new_stream.disable (ACE_NONBLOCK); + return 0; + } } -ACE_SOCK_Connector::ACE_SOCK_Connector (ACE_SOCK_Stream &new_stream, - const ACE_Addr &remote_sap, - ACE_Connect_QoS_Params qos_params, - ACE_Time_Value *timeout, - const ACE_Addr &local_sap, - int reuse_addr, - int flags, - int perms, - int protocol_family, - int protocol) -{ - ACE_TRACE ("ACE_SOCK_Connector::ACE_SOCK_Connector"); - - if (this->connect (new_stream, - remote_sap, - qos_params, - timeout, - local_sap, - reuse_addr, - flags, - perms, - protocol_family, - protocol) == -1 - && timeout != 0 - && !(errno == EWOULDBLOCK || errno == ETIME)) - ACE_ERROR ((LM_ERROR, - ASYS_TEXT ("%p\n"), - ASYS_TEXT ("ACE_SOCK_Connector::ACE_SOCK_Connector"))); -} diff --git a/ace/SOCK_Connector.h b/ace/SOCK_Connector.h index e6abeb6a0e9..57d52903f52 100644 --- a/ace/SOCK_Connector.h +++ b/ace/SOCK_Connector.h @@ -61,30 +61,8 @@ public: // the OS do the binding. If <reuse_addr> == 1 then the // <local_addr> is reused, even if it hasn't been cleanedup yet. - ACE_SOCK_Connector (ACE_SOCK_Stream &new_stream, - const ACE_Addr &remote_sap, - ACE_Connect_QoS_Params qos_params, - ACE_Time_Value *timeout = 0, - const ACE_Addr &local_sap = ACE_Addr::sap_any, - int reuse_addr = 0, - int flags = 0, - int perms = 0, - int protocol_family = PF_INET, - int protocol = 0); - // Actively connect and produce a <new_stream> if things go well. - // The <remote_sap> is the address that we are trying to connect - // with. The <qos_params> contains QoS parameters that are passed - // to RSVP. The <timeout> is the amount of time to wait to connect. - // If it's 0 then we block indefinitely. If *timeout == {0, 0} then - // the connection is done using non-blocking mode. In this case, if - // the connection can't be made immediately the value of -1 is - // returned with <errno == EWOULDBLOCK>. If *timeout > {0, 0} then - // this is the amount of time to wait before timing out. If the - // time expires before the connection is made <errno == ETIME>. The - // <local_sap> is the value of local address to bind to. If it's - // the default value of <ACE_Addr::sap_any> then the user is letting - // the OS do the binding. If <reuse_addr> == 1 then the - // <local_addr> is reused, even if it hasn't been cleanedup yet. + ~ACE_SOCK_Connector (void); + // Default dtor. int connect (ACE_SOCK_Stream &new_stream, const ACE_Addr &remote_sap, @@ -109,34 +87,6 @@ public: // the OS do the binding. If <reuse_addr> == 1 then the // <local_addr> is reused, even if it hasn't been cleanedup yet. - int connect (ACE_SOCK_Stream &new_stream, - const ACE_Addr &remote_sap, - ACE_Connect_QoS_Params qos_params, - ACE_Time_Value *timeout = 0, - const ACE_Addr &local_sap = ACE_Addr::sap_any, - int reuse_addr = 0, - int flags = 0, - int perms = 0, - int protocol_family = PF_INET, - int protocol = 0); - // Actively connect and produce a <new_stream> if things go well. - // The <remote_sap> is the address that we are trying to connect - // with. The <qos_params> contains QoS parameters that are passed - // to RSVP. The <timeout> is the amount of time to wait to connect. - // If it's 0 then we block indefinitely. If *timeout == {0, 0} then - // the connection is done using non-blocking mode. In this case, if - // the connection can't be made immediately the value of -1 is - // returned with <errno == EWOULDBLOCK>. If *timeout > {0, 0} then - // this is the amount of time to wait before timing out. If the - // time expires before the connection is made <errno == ETIME>. The - // <local_sap> is the value of local address to bind to. If it's - // the default value of <ACE_Addr::sap_any> then the user is letting - // the OS do the binding. If <reuse_addr> == 1 then the - // <local_addr> is reused, even if it hasn't been cleanedup yet. - - ~ACE_SOCK_Connector (void); - // Default dtor. - // = Completion routine. int complete (ACE_SOCK_Stream &new_stream, ACE_Addr *remote_sap = 0, @@ -158,20 +108,6 @@ public: ACE_ALLOC_HOOK_DECLARE; // Declare the dynamic allocation hooks. - -protected: - int shared_connect_start (ACE_SOCK_Stream &new_stream, - ACE_Time_Value *timeout, - const ACE_Addr &local_sap, - int reuse_addr, - int protocol_family, - int protocol); - // Perform operations that must be called before <ACE_OS::connect>. - - int shared_connect_finish (ACE_SOCK_Stream &new_stream, - ACE_Time_Value *timeout, - int result); - // Perform operations that must be called after <ACE_OS::connect>. }; #if !defined (ACE_LACKS_INLINE_FUNCTIONS) diff --git a/ace/SOCK_Connector.i b/ace/SOCK_Connector.i index c4801c01cf0..ebce17c7f53 100644 --- a/ace/SOCK_Connector.i +++ b/ace/SOCK_Connector.i @@ -12,6 +12,24 @@ ACE_SOCK_Connector::~ACE_SOCK_Connector (void) ACE_TRACE ("ACE_SOCK_Connector::~ACE_SOCK_Connector"); } +ASYS_INLINE +ACE_SOCK_Connector::ACE_SOCK_Connector (ACE_SOCK_Stream &new_stream, + const ACE_Addr &remote_sap, + ACE_Time_Value *timeout, + const ACE_Addr &local_sap, + int reuse_addr, + int flags, + int perms, + int protocol_family, + int protocol) +{ + ACE_TRACE ("ACE_SOCK_Connector::ACE_SOCK_Connector"); + if (this->connect (new_stream, remote_sap, timeout, local_sap, + reuse_addr, flags, perms, protocol_family, protocol) == -1 + && timeout != 0 && !(errno == EWOULDBLOCK || errno == ETIME)) + ACE_ERROR ((LM_ERROR, ASYS_TEXT ("%p\n"), ASYS_TEXT ("ACE_SOCK_Connector::ACE_SOCK_Connector"))); +} + // Do-nothing constructor... ASYS_INLINE diff --git a/ace/SOCK_Dgram_Bcast.h b/ace/SOCK_Dgram_Bcast.h index c74416f0714..0faf2391775 100644 --- a/ace/SOCK_Dgram_Bcast.h +++ b/ace/SOCK_Dgram_Bcast.h @@ -26,11 +26,8 @@ class ACE_Export ACE_Bcast_Node { - // = TITLE - // Linked list of broadcast interfaces. public: - ACE_Bcast_Node (ACE_INET_Addr &, - ACE_Bcast_Node *); + ACE_Bcast_Node (ACE_INET_Addr &, ACE_Bcast_Node *); ~ACE_Bcast_Node (void); // Default dtor. diff --git a/ace/SOCK_Dgram_Mcast.cpp b/ace/SOCK_Dgram_Mcast.cpp index 05ee72132c3..1a30f757e43 100644 --- a/ace/SOCK_Dgram_Mcast.cpp +++ b/ace/SOCK_Dgram_Mcast.cpp @@ -26,25 +26,29 @@ ACE_SOCK_Dgram_Mcast::ACE_SOCK_Dgram_Mcast (void) } int -ACE_SOCK_Dgram_Mcast::subscribe_i (const ACE_INET_Addr &mcast_addr, - int reuse_addr, - const ASYS_TCHAR *net_if, - int protocol_family, - int protocol) +ACE_SOCK_Dgram_Mcast::subscribe (const ACE_INET_Addr &mcast_addr, + int reuse_addr, +#if defined (ACE_PSOS) + // pSOS supports numbers, not + // names for network interfaces + long net_if, +#else + const ASYS_TCHAR *net_if, +#endif /* defined (ACE_PSOS) */ + int protocol_family, + int protocol) { - ACE_TRACE ("ACE_SOCK_Dgram_Mcast::subscribe_i"); + ACE_TRACE ("ACE_SOCK_Dgram_Mcast::subscribe"); - // Make a copy of address to use in the <send> methods. + // Make a local copy of address to use in sends. this->mcast_addr_.set (mcast_addr); - // Only perform the <open> initialization if we haven't been opened - // earlier. + // Only perform the open() initialization if we haven't been opened + // previously. if (this->get_handle () == ACE_INVALID_HANDLE) { - if (ACE_SOCK::open (SOCK_DGRAM, - protocol_family, - protocol, - reuse_addr) == -1) + if (ACE_SOCK::open (SOCK_DGRAM, protocol_family, + protocol, reuse_addr) == -1) return -1; int one = 1; @@ -63,67 +67,61 @@ ACE_SOCK_Dgram_Mcast::subscribe_i (const ACE_INET_Addr &mcast_addr, #endif /* SO_REUSEPORT */ // Create an address to bind the socket to. + ACE_INET_Addr local; if (local.set (this->mcast_addr_.get_port_number ()) == -1) return -1; - else if (ACE_SOCK_Dgram::shared_open (local, - protocol_family) == -1) + else if (ACE_SOCK_Dgram::shared_open (local, protocol_family) == -1) return -1; } #if defined (ACE_WIN32) - // Windows NT's winsock has trouble with multicast subscribes in the - // presence of multiple network interfaces when the IP address is - // given as INADDR_ANY. It will pick the first interface and only - // accept mcast there. So, to work around this, cycle through all - // of the interfaces known and subscribe to all the non-loopback - // ones. + // Windows NT's winsock has trouble with multicast subscribes in the presence + // of multiple network interfaces when the IP address is given as INADDR_ANY. + // It will pick the first interface and only accept mcast there. So, to work + // around this, cycle through all of the interfaces known and subscribe to + // all the non-loopback ones. + // Note that this only needs to be done on NT, but there's no way to tell + // at this point if the code will be running on NT - only if it is compiled + // for NT-only or for NT/95, and that doesn't really help us. It doesn't + // hurt to do this on Win95, it's just a little slower than it normally + // would be. // - // Note that this only needs to be done on NT, but there's no way to - // tell at this point if the code will be running on NT - only if it - // is compiled for NT-only or for NT/95, and that doesn't really - // help us. It doesn't hurt to do this on Win95, it's just a little - // slower than it normally would be. - // - // NOTE - <ACE::get_ip_interfaces> doesn't always get all of the - // interfaces. In particular, it may not get a PPP interface. This - // is a limitation of the way <ACE::get_ip_interfaces> works with - // MSVC. The reliable way of getting the interface list is - // available only with MSVC 5. + // NOTE - get_ip_interfaces doesn't always get all of the interfaces. In + // particular, it may not get a PPP interface. This is a limitation of the + // way get_ip_interfaces works with MSVC. The reliable way of getting the + // interface list is available only with MSVC 5. if (net_if == 0) { ACE_INET_Addr *if_addrs = 0; - size_t if_cnt; + size_t if_cnt, nr_subscribed; - if (ACE::get_ip_interfaces (if_cnt, - if_addrs) != 0) + if (ACE::get_ip_interfaces(if_cnt, if_addrs) != 0) return -1; - size_t nr_subscribed = 0; + nr_subscribed = 0; if (if_cnt < 2) { - if (this->subscribe (mcast_addr, - reuse_addr, - ASYS_WIDE_STRING ("0.0.0.0"), - protocol_family, - protocol) == 0) + if (this->subscribe(mcast_addr, + reuse_addr, + ASYS_WIDE_STRING ("0.0.0.0"), + protocol_family, + protocol) == 0) ++nr_subscribed; } else while (if_cnt > 0) { - --if_cnt; - - // Convert to 0-based for indexing, next loop check. + --if_cnt; // Convert to 0-based for indexing, next loop check if (if_addrs[if_cnt].get_ip_address() == INADDR_LOOPBACK) continue; - if (this->subscribe (mcast_addr, - reuse_addr, - ASYS_WIDE_STRING (if_addrs[if_cnt].get_host_addr()), - protocol_family, - protocol) == 0) + if (this->subscribe(mcast_addr, + reuse_addr, + ASYS_WIDE_STRING (if_addrs[if_cnt].get_host_addr()), + protocol_family, + protocol) == 0) ++nr_subscribed; } @@ -140,97 +138,56 @@ ACE_SOCK_Dgram_Mcast::subscribe_i (const ACE_INET_Addr &mcast_addr, #endif /* ACE_WIN32 */ // Create multicast request. - if (this->make_multicast_address (this->mcast_addr_, - net_if) == -1) + if (this->make_multicast_address (this->mcast_addr_, net_if) == -1) return -1; - else - return 0; -} -int -ACE_SOCK_Dgram_Mcast::subscribe (const ACE_INET_Addr &mcast_addr, - int reuse_addr, - const ASYS_TCHAR *net_if, - int protocol_family, - int protocol) -{ - if (this->subscribe_i (mcast_addr, - reuse_addr, - net_if, - protocol_family, - protocol) == -1) - return -1; - // Tell network device driver to read datagrams with a - // multicast_address IP interface. + // multicast_address address. else if (this->ACE_SOCK::set_option (IPPROTO_IP, IP_ADD_MEMBERSHIP, - &this->mcast_request_if_, - sizeof this->mcast_request_if_) == -1) + &multicast_address_, + sizeof multicast_address_) == -1) return -1; - else - return 0; -} - -ACE_HANDLE -ACE_SOCK_Dgram_Mcast::subscribe (const ACE_INET_Addr &mcast_addr, - const ACE_Connect_QoS_Params &qos_params, - int reuse_addr, - const ASYS_TCHAR *net_if, - int protocol_family, - int protocol) -{ - if (this->subscribe_i (mcast_addr, - reuse_addr, - net_if, - protocol_family, - protocol) == -1) - return ACE_INVALID_HANDLE; - - // Tell network device driver to read datagrams with a - // <mcast_request_if_> IP interface. - else - return ACE_OS::join_leaf (this->get_handle (), - ACE_reinterpret_cast (const sockaddr *, - &this->mcast_request_if_.imr_multiaddr.s_addr), - sizeof this->mcast_request_if_.imr_multiaddr.s_addr, - qos_params); + return 0; } int -ACE_SOCK_Dgram_Mcast::unsubscribe_i (const ACE_INET_Addr &mcast_addr, - const ASYS_TCHAR *net_if, - int protocol_family, - int protocol) +ACE_SOCK_Dgram_Mcast::unsubscribe (const ACE_INET_Addr &mcast_addr, +#if defined (ACE_PSOS) + // pSOS supports numbers, not + // names for network interfaces + long net_if, +#else + const ASYS_TCHAR *net_if, +#endif /* defined (ACE_PSOS) */ + int protocol_family, + int protocol) { - ACE_TRACE ("ACE_SOCK_Dgram_Mcast::unsubscribe_i"); + ACE_TRACE ("ACE_SOCK_Dgram_Mcast::unsubscribe"); + #if defined (ACE_WIN32) - // Windows NT's winsock has trouble with multicast subscribes in the - // presence of multiple network interfaces when the IP address is - // given as INADDR_ANY. It will pick the first interface and only - // accept mcast there. So, to work around this, cycle through all - // of the interfaces known and subscribe to all the non-loopback - // ones. - // - // Note that this only needs to be done on NT, but there's no way to - // tell at this point if the code will be running on NT - only if it - // is compiled for NT-only or for NT/95, and that doesn't really - // help us. It doesn't hurt to do this on Win95, it's just a little - // slower than it normally would be. + // Windows NT's winsock has trouble with multicast subscribes in the presence + // of multiple network interfaces when the IP address is given as INADDR_ANY. + // It will pick the first interface and only accept mcast there. So, to work + // around this, cycle through all of the interfaces known and subscribe to + // all the non-loopback ones. + // Note that this only needs to be done on NT, but there's no way to tell + // at this point if the code will be running on NT - only if it is compiled + // for NT-only or for NT/95, and that doesn't really help us. It doesn't + // hurt to do this on Win95, it's just a little slower than it normally + // would be. // - // NOTE - <ACE::get_ip_interfaces> doesn't always get all of the - // interfaces. In particular, it may not get a PPP interface. This - // is a limitation of the way <ACE::get_ip_interfaces> works with - // MSVC. The reliable way of getting the interface list is - // available only with MSVC 5. + // NOTE - get_ip_interfaces doesn't always get all of the interfaces. In + // particular, it may not get a PPP interface. This is a limitation of the + // way get_ip_interfaces works with MSVC. The reliable way of getting the + // interface list is available only with MSVC 5. if (net_if == 0) { ACE_INET_Addr *if_addrs = 0; - size_t if_cnt; + size_t if_cnt; - if (ACE::get_ip_interfaces (if_cnt, - if_addrs) != 0) + if (ACE::get_ip_interfaces(if_cnt, if_addrs) != 0) return -1; size_t nr_unsubscribed = 0; @@ -246,8 +203,7 @@ ACE_SOCK_Dgram_Mcast::unsubscribe_i (const ACE_INET_Addr &mcast_addr, else while (if_cnt > 0) { - --if_cnt; - // Convert to 0-based for indexing, next loop check + --if_cnt; // Convert to 0-based for indexing, next loop check if (if_addrs[if_cnt].get_ip_address() == INADDR_LOOPBACK) continue; if (this->unsubscribe (mcast_addr, @@ -274,32 +230,15 @@ ACE_SOCK_Dgram_Mcast::unsubscribe_i (const ACE_INET_Addr &mcast_addr, ip_mreq multicast_address; // Create multicast request. - if (this->make_multicast_address_i (mcast_addr, - multicast_address, - net_if) == -1) + if (this->make_multicast_address_i (mcast_addr, multicast_address, net_if) == -1) return -1; - else - return 0; -} -int -ACE_SOCK_Dgram_Mcast::unsubscribe (const ACE_INET_Addr &mcast_addr, - const ASYS_TCHAR *net_if, - int protocol_family, - int protocol) -{ - ACE_TRACE ("ACE_SOCK_Dgram_Mcast::unsubscribe"); - if (this->unsubscribe_i (mcast_addr, - net_if, - protocol_family, - protocol) == -1) - return -1; // Tell network device driver to read datagrams with a // multicast_address address. - else if (ACE_SOCK::set_option (IPPROTO_IP, - IP_DROP_MEMBERSHIP, - &this->mcast_request_if_, - sizeof this->mcast_request_if_) == -1) + else if (this->ACE_SOCK::set_option (IPPROTO_IP, + IP_DROP_MEMBERSHIP, + &multicast_address, + sizeof multicast_address) == -1) return -1; return 0; } @@ -310,64 +249,76 @@ ACE_SOCK_Dgram_Mcast::unsubscribe (void) ACE_TRACE ("ACE_SOCK_Dgram_Mcast::unsubscribe"); return this->ACE_SOCK::set_option (IPPROTO_IP, IP_DROP_MEMBERSHIP, - &this->mcast_request_if_, - sizeof this->mcast_request_if_); + &multicast_address_, + sizeof multicast_address_); +} + +int +ACE_SOCK_Dgram_Mcast::make_multicast_address (const ACE_INET_Addr &mcast_addr, +#if defined (ACE_PSOS) + // pSOS supports numbers, not + // names for network interfaces + long net_if +#else + const ASYS_TCHAR *net_if +#endif /* defined (ACE_PSOS) */ + ) +{ + ACE_TRACE ("ACE_SOCK_Dgram_Mcast::make_multicast_address"); + + return this->make_multicast_address_i (mcast_addr, + this->multicast_address_, + net_if ); } int ACE_SOCK_Dgram_Mcast::make_multicast_address_i (const ACE_INET_Addr &mcast_addr, ip_mreq &multicast_address , - const ASYS_TCHAR *net_if) +#if defined (ACE_PSOS) + // pSOS supports numbers, not + // names for network interfaces + long net_if +#else + const ASYS_TCHAR *net_if +#endif /* defined (ACE_PSOS) */ + ) { if (net_if != 0) { -#if defined (ACE_WIN32) - // This port number is not necessary, just convenient - ACE_INET_Addr interface_addr; - if (interface_addr.set (mcast_addr.get_port_number (), - net_if) == -1) - return -1; - multicast_address.imr_interface.s_addr = - htonl (interface_addr.get_ip_address ()); -#else +#if !defined (ACE_WIN32) struct ifreq if_address; #if defined (ACE_PSOS) - // Look up the interface by number, not name. - if_address.ifr_ifno = ACE_OS::atoi (net_if); + // look up the interface by number, not name + if_address.ifr_ifno = net_if; #else ACE_OS::strcpy (if_address.ifr_name, net_if); #endif /* defined (ACE_PSOS) */ - if (ACE_OS::ioctl (this->get_handle (), - SIOCGIFADDR, - &if_address) == -1) + if (ACE_OS::ioctl (this->get_handle (), SIOCGIFADDR, &if_address) == -1) return -1; struct sockaddr_in *socket_address; socket_address = ACE_reinterpret_cast(sockaddr_in *, &if_address.ifr_addr); multicast_address.imr_interface.s_addr = socket_address->sin_addr.s_addr; +#else + // This port number is not necessary, just convenient + ACE_INET_Addr interface_addr; + if (interface_addr.set (mcast_addr.get_port_number (), + net_if) == -1) + return -1; + multicast_address.imr_interface.s_addr = + htonl (interface_addr.get_ip_address ()); #endif /* ACE_WIN32 */ } else multicast_address.imr_interface.s_addr = INADDR_ANY; #if defined (ACE_PSOS) && !defined (ACE_PSOS_TM) && !defined (ACE_PSOS_DIAB_MIPS) - multicast_address.imr_mcastaddr.s_addr = htonl (mcast_addr.get_ip_address()); + multicast_address.imr_mcastaddr.s_addr = htonl(mcast_addr.get_ip_address()); #else multicast_address.imr_multiaddr.s_addr = htonl (mcast_addr.get_ip_address ()); #endif /* defined (ACE_PSOS) */ return 0; } - -int -ACE_SOCK_Dgram_Mcast::make_multicast_address (const ACE_INET_Addr &mcast_addr, - const ASYS_TCHAR *net_if) -{ - ACE_TRACE ("ACE_SOCK_Dgram_Mcast::make_multicast_address"); - - return this->make_multicast_address_i (mcast_addr, - this->mcast_request_if_, - net_if ); -} diff --git a/ace/SOCK_Dgram_Mcast.h b/ace/SOCK_Dgram_Mcast.h index 7b8a1c24955..55d3ba832dd 100644 --- a/ace/SOCK_Dgram_Mcast.h +++ b/ace/SOCK_Dgram_Mcast.h @@ -10,9 +10,8 @@ // SOCK_Dgram_Mcast.h // // = AUTHORS -// Irfan Pyrali <irfan@cs.wustl.edu>, -// Tim Harrison <harrison@cs.wustl.edu>, and -// Douglas C. Schmidt <schmidt@cs.wustl.edu> +// Irfan Pyrali (ip1@cs.wustl.edu) +// Tim Harrison (harrison@cs.wustl.edu) // // ============================================================================ @@ -30,15 +29,15 @@ class ACE_Export ACE_SOCK_Dgram_Mcast : public ACE_SOCK_Dgram { // = TITLE - // Defines the member functions for the ACE socket wrapper - // for UDP/IP multicast. + // Defines the member functions for the ACE SOCK wrapper + // multicast abstraction. public: // = Initialization routine. ACE_SOCK_Dgram_Mcast (void); - // Note that there is no public <open> method. Therefore, this - // class cannot be used unless you <subscribe> to a multicast group. - // If you just want to send (and not listen) to a multicast group, - // use <ACE_SOCK_Dgram> or <ACE_SOCK_CODgram> instead. + // Note that there is no <open>. This cannot be used unless you + // subscribe to the multicast group. If you just want to send (and + // not listen) to the multicast group, use ACE_SOCK_Dgram or + // ACE_SOCK_CODgram. ~ACE_SOCK_Dgram_Mcast (void); // Default dtor. @@ -47,63 +46,41 @@ public: int subscribe (const ACE_INET_Addr &mcast_addr, int reuse_addr = 1, +#if defined (ACE_PSOS) + // pSOS supports numbers, not names for network interfaces + long net_if = 0, +#else const ASYS_TCHAR *net_if = 0, +#endif /* defined (ACE_PSOS) */ int protocol_family = PF_INET, int protocol = 0); - // This is a BSD-style method for joining a multicast group (i.e., - // no QoS). The network interface device driver is instructed to - // accept datagrams with <mcast_addr> multicast addresses. If the - // socket has already been opened, <subscribe> closes the socket and - // opens a new socket bound to the <mcast_addr>. + // Join a multicast group by telling the network interface device + // driver to accept datagrams with ACE_INET_Addr &mcast_addr + // multicast addresses. // - // The <net_if> interface is hardware specific, e.g., use "netstat - // -i" to find whether your interface is, such as "le0" or something - // else. If net_if == 0, <subscribe> uses the default mcast - // interface. Returns: -1 on error, else 0. - // - // Note that some platforms, such as pSoS, support only number, not - // names, for network interfaces. For these platforms, just give - // these numbers in alphanumeric form and <subscribe> will convert - // them into numbers via <ACE_OS::atoi>. - - ACE_HANDLE subscribe (const ACE_INET_Addr &mcast_addr, - const ACE_Connect_QoS_Params &qos_params, - int reuse_addr = 1, - const ASYS_TCHAR *net_if = 0, - int protocol_family = PF_INET, - int protocol = 0); - // This is a QoS-enabled method for joining a multicast group, which - // passes <qos_params> via <ACE_OS::join_leaf>. The network - // interface device driver is instructed to accept datagrams with - // <mcast_addr> multicast addresses. If the socket has already been - // opened, <subscribe> closes the socket and opens a new socket - // bound to the <mcast_addr>. + // If you have called open already, subscribe closes the socket and + // opens a new socket bound to the mcast_addr. // - // The <net_if> interface is hardware specific, e.g., use "netstat - // -i" to find whether your interface is, such as "le0" or something - // else. If net_if == 0, <subscribe> uses the default mcast - // interface. Returns: an <ACE_HANDLE> to the newly created - // multipoint socket on success or ACE_INVALID_HANDLE on failure. - // - // Note that some platforms, such as pSoS, support only number, not - // names, for network interfaces. For these platforms, just give - // these numbers in alphanumeric form and <subscribe> will convert - // them into numbers via <ACE_OS::atoi>. + // Interface is hardware specific. use netstat -i to find whether + // your interface is, say, le0 or something else. If net_if == 0, + // subscribe uses the default mcast interface. + // Returns: -1 on error, else 0. int unsubscribe (const ACE_INET_Addr &mcast_addr, +#if defined (ACE_PSOS) + // pSOS supports numbers, not names for network interfaces + long net_if = 0, +#else const ASYS_TCHAR *net_if = 0, +#endif /* defined (ACE_PSOS) */ int protocol_family = PF_INET, int protocol = 0); - // Leave a multicast group identified by <mcast_addr>. The <net_if> - // interface is hardware specific. Use something like "netstat -i" - // to find whether your interface is, such as "le0" or something - // else. If <net_if> == 0, <subscribe> uses the default mcast - // interface. Returns: -1 on error, else 0. - // - // Note that some platforms, such as pSoS, support only number, not - // names, for network interfaces. For these platforms, just give - // these numbers in alphanumeric form and <subscribe> will convert - // them into numbers via <ACE_OS::atoi>. + // Leave a multicast group. + // + // Interface is hardware specific. use netstat -i to find whether + // your interface is, say, le0 or something else. If net_if == 0, + // subscribe uses the default mcast interface. + // Returns: -1 on error, else 0. int unsubscribe (void); // Unsubscribe from a multicast group. Returns 0 on success, -1 on @@ -121,12 +98,11 @@ public: // Send <n> <iovecs>. // = Options. - int set_option (int option, - char optval); - // Set an ip option that takes a char as input, such as - // <IP_MULTICAST_LOOP>. This is just a more concise nice interface - // to a subset of possible <ACE_SOCK::set_option> calls. Returns 0 - // on success, -1 on failure. + int set_option (int option, char optval); + // Set an ip option that takes a char as input. + // e.g. IP_MULTICAST_LOOP. This is just a nice interface to a + // subset of possible setsockopt/ACE_SOCK::set_option calls Returns + // 0 on success, -1 on failure. void dump (void) const; // Dump the state of an object. @@ -138,24 +114,10 @@ private: ACE_HANDLE open (const ACE_Addr &local, int protocol_family = PF_INET, int protocol = 0); - // Disable public use of <ACE_SOCK_Dgram::open> to ensure the class - // is used properly. - - int subscribe_i (const ACE_INET_Addr &mcast_addr, - int reuse_addr = 1, - const ASYS_TCHAR *net_if = 0, - int protocol_family = PF_INET, - int protocol = 0); - // Implementation method of <subscribe>. - - int unsubscribe_i (const ACE_INET_Addr &mcast_addr, - const ASYS_TCHAR *net_if = 0, - int protocol_family = PF_INET, - int protocol = 0); - // Implementation method of <unsubscribe>. - - // = Disable public use of <ACE_SOCK_Dgram::send>s and force - // <ACE_SOCK_Dgram_Mcast::send>s inline. + // disable public use of ACE_SOCK_Dgram::open () + + // = Disable public use of ACE_SOCK_Dgram::sends and force + // ACE_SOCK_Dgram_Mcast::sends inline ssize_t send (const void *buf, size_t n, const ACE_Addr &addr, @@ -166,25 +128,37 @@ private: int flags = 0) const; int make_multicast_address (const ACE_INET_Addr &mcast_addr, - const ASYS_TCHAR *net_if = ASYS_TEXT ("le0")); - // Initialize the <multicast_address_> IP address. +#if defined (ACE_PSOS) + // pSOS supports numbers, not + // names for network interfaces + long net_if = 0 +#else + const ASYS_TCHAR *net_if = ASYS_TEXT ("le0") +#endif /* defined (ACE_PSOS) */ + ); + // Initialize the <multicast_addres_ field> int make_multicast_address_i (const ACE_INET_Addr &mcast_addr, ip_mreq& multicast_address, - const ASYS_TCHAR *net_if = ASYS_TEXT ("le0")); - // Initialize a multicast address. This method factors out common - // code called by <make_multicast_address> and <subscribe>. +#if defined (ACE_PSOS) + // pSOS supports numbers, not + // names for network interfaces + long net_if = 0 +#else + const ASYS_TCHAR *net_if = ASYS_TEXT ("le0") +#endif /* defined (ACE_PSOS) */ + ); + // Initialize a multicast address. ACE_INET_Addr mcast_addr_; - // A copy of the address that we use to <send> multicasts. + // Multicast group address. - ip_mreq mcast_request_if_; - // IP address of the interface upon which we're receiving - // multicasts. + ip_mreq multicast_address_; + // IP address. }; #if !defined (ACE_LACKS_INLINE_FUNCTIONS) #include "ace/SOCK_Dgram_Mcast.i" -#endif /* ACE_LACKS_INLINE_FUNCTIONS */ +#endif #endif /* ACE_SOCK_DGRAM_MCAST_H */ diff --git a/ace/SPIPE_Addr.cpp b/ace/SPIPE_Addr.cpp index 85c0445cdd9..ede9445b6cd 100644 --- a/ace/SPIPE_Addr.cpp +++ b/ace/SPIPE_Addr.cpp @@ -74,7 +74,6 @@ ACE_SPIPE_Addr::set (const ACE_SPIPE_Addr &sa) // Copy constructor. ACE_SPIPE_Addr::ACE_SPIPE_Addr (const ACE_SPIPE_Addr &sa) - : ACE_Addr (AF_SPIPE, sizeof this->SPIPE_addr_) { this->set (sa); } @@ -144,7 +143,6 @@ ACE_SPIPE_Addr::set (LPCTSTR addr, ACE_SPIPE_Addr::ACE_SPIPE_Addr (LPCTSTR addr, gid_t gid, uid_t uid) - : ACE_Addr (AF_SPIPE, sizeof this->SPIPE_addr_) { this->set (addr, gid, uid); } diff --git a/ace/SPIPE_Stream.h b/ace/SPIPE_Stream.h index eec059af87d..f21e17ed423 100644 --- a/ace/SPIPE_Stream.h +++ b/ace/SPIPE_Stream.h @@ -108,19 +108,6 @@ public: ssize_t recv (void *buf, size_t n, ACE_OVERLAPPED *overlapped) const; // Recv <n> bytes via Win32 ReadFile using overlapped I/O. - ssize_t sendv (const iovec iov[], - size_t n) const; - // Send an <iovec> of size <n> to the stream. - - ssize_t sendv_n (const iovec iov[], - size_t n) const; - // Send an <iovec> of size <n> to the stream. Will block until all - // bytes are sent or an error occurs. - - ssize_t recvv_n (iovec iov[], - size_t n) const; - // Receive an <iovec> of size <n> to the stream. - // = Meta-type info typedef ACE_SPIPE_Addr PEER_ADDR; diff --git a/ace/SPIPE_Stream.i b/ace/SPIPE_Stream.i index 4733a628815..d790a2f0c53 100644 --- a/ace/SPIPE_Stream.i +++ b/ace/SPIPE_Stream.i @@ -155,44 +155,6 @@ ACE_SPIPE_Stream::recv (void *buf, size_t n, ACE_OVERLAPPED *overlapped) const { ACE_TRACE ("ACE_SPIPE_Stream::recv"); - return ACE_OS::read (this->get_handle (), - (char *) buf, n, + return ACE_OS::read (this->get_handle (), (char *) buf, n, overlapped); } - -ASYS_INLINE ssize_t -ACE_SPIPE_Stream::sendv_n (const iovec iov[], - size_t n) const -{ - ACE_TRACE ("ACE_SPIPE_Stream::sendv_n"); - return ACE::writev_n (this->get_handle (), - iov, - n); -} - -// Recv an n byte message from the Stream. - -ASYS_INLINE ssize_t -ACE_SPIPE_Stream::recvv_n (iovec iov[], - size_t n) const -{ - ACE_TRACE ("ACE_SPIPE_Stream::recvv_n"); - // @@ Carlos, can you please update this to call the - // new ACE::recvv_n() method that you write? - return ACE_OS::readv (this->get_handle (), - iov, - n); -} - -// Send an <iovec> of size <n> to the Stream. - -ASYS_INLINE ssize_t -ACE_SPIPE_Stream::sendv (const iovec iov[], - size_t n) const -{ - ACE_TRACE ("ACE_SPIPE_Stream::sendv"); - return ACE_OS::writev (this->get_handle (), - iov, - n); -} - diff --git a/ace/Service_Types.cpp b/ace/Service_Types.cpp index 228b0e8bb8c..2b808ea9c3d 100644 --- a/ace/Service_Types.cpp +++ b/ace/Service_Types.cpp @@ -405,7 +405,6 @@ ACE_Service_Object_Type::fini (void) const #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Message_Queue<ACE_SYNCH>; -template class ACE_Message_Queue_Iterator<ACE_SYNCH>; template class ACE_Message_Queue_Factory<ACE_SYNCH>; template class ACE_Dynamic_Message_Queue<ACE_SYNCH>; template class ACE_Module<ACE_SYNCH>; @@ -418,7 +417,6 @@ template class ACE_Thru_Task<ACE_SYNCH>; // Even with threads, these ACE_NULL_SYNCH specializations are necessary. #if defined (ACE_HAS_THREADS) template class ACE_Message_Queue<ACE_NULL_SYNCH>; - template class ACE_Message_Queue_Iterator<ACE_NULL_SYNCH>; template class ACE_Message_Queue_Factory<ACE_NULL_SYNCH>; template class ACE_Dynamic_Message_Queue<ACE_NULL_SYNCH>; template class ACE_Module<ACE_NULL_SYNCH>; @@ -427,7 +425,6 @@ template class ACE_Thru_Task<ACE_SYNCH>; #endif /* ACE_HAS_THREADS */ #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) #pragma instantiate ACE_Message_Queue<ACE_SYNCH> -#pragma instantiate ACE_Message_Queue_Iterator<ACE_SYNCH> #pragma instantiate ACE_Message_Queue_Factory<ACE_SYNCH> #pragma instantiate ACE_Dynamic_Message_Queue<ACE_SYNCH> #pragma instantiate ACE_Module<ACE_SYNCH> @@ -439,7 +436,6 @@ template class ACE_Thru_Task<ACE_SYNCH>; // Even with threads, these ACE_NULL_SYNCH specializations are necessary. #if defined (ACE_HAS_THREADS) #pragma instantiate ACE_Message_Queue<ACE_NULL_SYNCH> - #pragma instantiate ACE_Message_Queue_Iterator<ACE_NULL_SYNCH> #pragma instantiate ACE_Message_Queue_Factory<ACE_NULL_SYNCH> #pragma instantiate ACE_Dynamic_Message_Queue<ACE_NULL_SYNCH> #pragma instantiate ACE_Module<ACE_NULL_SYNCH> diff --git a/ace/Signal.cpp b/ace/Signal.cpp index 16fd4fef9f5..859076fcde1 100644 --- a/ace/Signal.cpp +++ b/ace/Signal.cpp @@ -320,8 +320,8 @@ ACE_Sig_Handler::dispatch (int signum, ACE_TSS_Guard<ACE_Recursive_Thread_Mutex> m (*lock)); #endif /* 0 */ - // Save/restore errno. - ACE_Errno_Guard error (errno); + // Preserve errno across callbacks! + int old_errno = errno; // We can't use the <sig_pending> call here because that acquires // the lock, which is non-portable... @@ -351,6 +351,9 @@ ACE_Sig_Handler::dispatch (int signum, eh->handle_close (ACE_INVALID_HANDLE, ACE_Event_Handler::SIGNAL_MASK); } + + // Restore error when callback completes. + errno = old_errno; } ACE_Sig_Adapter::ACE_Sig_Adapter (ACE_Sig_Action &sa, int sigkey) @@ -683,8 +686,8 @@ ACE_Sig_Handlers::dispatch (int signum, ACE_TSS_Guard<ACE_Recursive_Thread_Mutex> m (*lock)); #endif /* 0 */ - // Save/restore errno. - ACE_Errno_Guard error (errno); + // Preserve errno across callbacks! + int old_errno = errno; ACE_Sig_Handler::sig_pending_ = 1; @@ -706,6 +709,9 @@ ACE_Sig_Handlers::dispatch (int signum, delete *eh; } } + + // Restore error when callback completes. + errno = old_errno; } // Return the first item in the list of handlers. Note that this will diff --git a/ace/Strategies.cpp b/ace/Strategies.cpp index edd7ca41f57..82515e14ddc 100644 --- a/ace/Strategies.cpp +++ b/ace/Strategies.cpp @@ -87,3 +87,4 @@ ACE_Connection_Recycling_Strategy::~ACE_Connection_Recycling_Strategy (void) } #endif /* ACE_STRATEGIES_C */ + diff --git a/ace/Svc_Conf.y b/ace/Svc_Conf.y index a936a9a2047..921d2b0a8dc 100644 --- a/ace/Svc_Conf.y +++ b/ace/Svc_Conf.y @@ -15,9 +15,8 @@ static ACE_Module_Type *ace_get_module (ACE_Static_Node *str_rec, const char *svc_name); #define YYDEBUG_LEXER_TEXT (yytext[yyleng] = '\0', yytext) - // Force the pretty debugging code to compile. -// #define YYDEBUG 1 +#define YYDEBUG 1 // Efficient memory allocation technique. ACE_Obstack *ace_obstack; diff --git a/ace/Svc_Conf_y.cpp b/ace/Svc_Conf_y.cpp index 9083f7fd7e1..d92ca5f05bc 100644 --- a/ace/Svc_Conf_y.cpp +++ b/ace/Svc_Conf_y.cpp @@ -19,14 +19,13 @@ static ACE_Module_Type *ace_get_module (ACE_Static_Node *str_rec, const char *svc_name); #define ACE_YYDEBUG_LEXER_TEXT (ace_yytext[ace_yyleng] = '\0', ace_yytext) - /* Force the pretty debugging code to compile.*/ -/* #define ACE_YYDEBUG 1*/ +#define ACE_YYDEBUG 1 /* Efficient memory allocation technique.*/ ACE_Obstack *ace_obstack; -#line 30 "Svc_Conf_y.cpp" +#line 29 "Svc_Conf_y.cpp" #define ACE_DYNAMIC 257 #define ACE_STATIC 258 #define ACE_SUSPEND 259 @@ -170,7 +169,7 @@ short ace_yycheck[] = { 8, #endif #define ACE_YYMAXTOKEN 276 #if ACE_YYDEBUG -const char *ace_yyname[] = { +char *ace_yyname[] = { "end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -183,7 +182,7 @@ const char *ace_yyname[] = { "ACE_IDENT","ACE_STRING","ACE_LPAREN","ACE_RPAREN","ACE_LBRACE","ACE_RBRACE", "ACE_STAR","ACE_COLON", }; -const char *ace_yyrule[] = { +char *ace_yyrule[] = { "$accept : svc_config_entries", "svc_config_entries : svc_config_entries svc_config_entry", "svc_config_entries : svc_config_entries error", @@ -250,7 +249,7 @@ ACE_YYSTYPE ace_yylval; #define ace_yystacksize ACE_YYSTACKSIZE short ace_yyss[ACE_YYSTACKSIZE]; ACE_YYSTYPE ace_yyvs[ACE_YYSTACKSIZE]; -#line 315 "Svc_Conf.y" +#line 314 "Svc_Conf.y" // Prints the error string to standard output. Cleans up the error // messages. @@ -396,7 +395,7 @@ main (int argc, char *argv[]) return ace_yyparse (); } #endif /* DEBUGGING */ -#line 400 "Svc_Conf_y.cpp" +#line 399 "Svc_Conf_y.cpp" #define ACE_YYABORT goto ace_yyabort #define ACE_YYACCEPT goto ace_yyaccept #define ACE_YYERROR goto ace_yyerrlab @@ -424,7 +423,7 @@ int ace_yyindent; #endif /* ACE_YYDEBUG_INDENT */ #ifndef ACE_YYDEBUG_REDUCE #ifdef __cplusplus -void ACE_YYDEBUG_REDUCE(int /* ace_yynew_state */, int /* ace_yyrule_num */, const char *ace_yyrule_string, int ace_yynew_indent, int ace_yyrhs_count) +void ACE_YYDEBUG_REDUCE(int /* ace_yynew_state */, int /* ace_yyrule_num */, char *ace_yyrule_string, int ace_yynew_indent, int ace_yyrhs_count) #else ACE_YYDEBUG_REDUCE(ace_yynew_state, ace_yyrule_num, ace_yyrule_string, ace_yynew_indent, ace_yyrhs_count) int ace_yynew_state; @@ -454,7 +453,7 @@ int ace_yyrhs_count; #endif /* ACE_YYDEBUG_REDUCE */ #ifndef ACE_YYDEBUG_SHIFT_LEXEME #ifdef __cplusplus -void ACE_YYDEBUG_SHIFT_LEXEME(int /* ace_yyold_state */, int /* ace_yynew_state*/, const char *ace_yytoken_string, int ace_yynew_indent) +void ACE_YYDEBUG_SHIFT_LEXEME(int /* ace_yyold_state */, int /* ace_yynew_state*/, char *ace_yytoken_string, int ace_yynew_indent) #else ACE_YYDEBUG_SHIFT_LEXEME(ace_yyold_state, ace_yynew_state, ace_yytoken_string, ace_yynew_indent) int ace_yyold_state; @@ -469,7 +468,7 @@ int ace_yynew_indent; #endif /* ACE_YYDEBUG_SHIFT_LEXEME */ #ifndef ACE_YYDEBUG_LOOK_AHEAD #ifdef __cplusplus -void ACE_YYDEBUG_LOOK_AHEAD(int /* ace_yynew_state */, int ace_yytoken_num, const char *ace_yytoken_string, int ace_yyindent) +void ACE_YYDEBUG_LOOK_AHEAD(int /* ace_yynew_state */, int ace_yytoken_num, char *ace_yytoken_string, int ace_yyindent) #else ACE_YYDEBUG_LOOK_AHEAD(ace_yynew_state, ace_yytoken_num, ace_yytoken_string, ace_yyindent) int ace_yynew_state; @@ -514,7 +513,7 @@ int ace_yyindent; #endif /* ACE_YYDEBUG_DISCARD_STATE */ #ifndef ACE_YYDEBUG_DISCARD_TOKEN #ifdef __cplusplus -void ACE_YYDEBUG_DISCARD_TOKEN(int /* ace_yynew_state */, int /* ace_yytoken_num */, const char *ace_yytoken_string, int ace_yyindent) +void ACE_YYDEBUG_DISCARD_TOKEN(int /* ace_yynew_state */, int /* ace_yytoken_num */, char *ace_yytoken_string, int ace_yyindent) #else ACE_YYDEBUG_DISCARD_TOKEN(ace_yynew_state, ace_yytoken_num, ace_yytoken_string, ace_yyindent) int ace_yynew_state; @@ -550,7 +549,7 @@ ace_yyparse() { register int ace_yym, ace_yyn, ace_yystate; #if ACE_YYDEBUG - register const char *ace_yys; + register char *ace_yys; #ifndef __cplusplus extern char *ace_foo(); #endif @@ -703,7 +702,7 @@ ace_yyreduce: switch (ace_yyn) { case 1: -#line 45 "Svc_Conf.y" +#line 44 "Svc_Conf.y" { if (ace_yyvsp[0].parse_node_ != 0) { @@ -713,13 +712,13 @@ case 1: } break; case 2: -#line 53 "Svc_Conf.y" +#line 52 "Svc_Conf.y" { ace_obstack->release (); } break; case 10: -#line 70 "Svc_Conf.y" +#line 69 "Svc_Conf.y" { if (ace_yyvsp[-1].svc_record_ != 0) ace_yyval.parse_node_ = new ACE_Dynamic_Node (ace_yyvsp[-1].svc_record_, ace_yyvsp[0].ident_); @@ -728,74 +727,74 @@ case 10: } break; case 11: -#line 80 "Svc_Conf.y" +#line 79 "Svc_Conf.y" { ace_yyval.parse_node_ = new ACE_Static_Node (ace_yyvsp[-1].ident_, ace_yyvsp[0].ident_); } break; case 12: -#line 87 "Svc_Conf.y" +#line 86 "Svc_Conf.y" { ace_yyval.parse_node_ = new ACE_Suspend_Node (ace_yyvsp[0].ident_); } break; case 13: -#line 94 "Svc_Conf.y" +#line 93 "Svc_Conf.y" { ace_yyval.parse_node_ = new ACE_Resume_Node (ace_yyvsp[0].ident_); } break; case 14: -#line 101 "Svc_Conf.y" +#line 100 "Svc_Conf.y" { ace_yyval.parse_node_ = new ACE_Remove_Node (ace_yyvsp[0].ident_); } break; case 15: -#line 108 "Svc_Conf.y" +#line 107 "Svc_Conf.y" { ace_yyval.parse_node_ = new ACE_Stream_Node (ace_yyvsp[-1].static_node_, ace_yyvsp[0].parse_node_); } break; case 16: -#line 111 "Svc_Conf.y" +#line 110 "Svc_Conf.y" { ace_yyval.static_node_ = new ACE_Static_Node (ace_yyvsp[0].ident_); } break; case 17: -#line 112 "Svc_Conf.y" +#line 111 "Svc_Conf.y" { ace_yyval.parse_node_ = new ACE_Dummy_Node (ace_yyvsp[-1].static_node_, ace_yyvsp[0].parse_node_); } break; case 18: -#line 119 "Svc_Conf.y" +#line 118 "Svc_Conf.y" { } break; case 19: -#line 122 "Svc_Conf.y" +#line 121 "Svc_Conf.y" { } break; case 20: -#line 128 "Svc_Conf.y" +#line 127 "Svc_Conf.y" { /* Initialize left context...*/ ace_yyval.static_node_ = ace_yyvsp[-1].static_node_; } break; case 21: -#line 133 "Svc_Conf.y" +#line 132 "Svc_Conf.y" { ace_yyval.parse_node_ = ace_yyvsp[-1].parse_node_; } break; case 22: -#line 136 "Svc_Conf.y" +#line 135 "Svc_Conf.y" { ace_yyval.parse_node_ = 0; } break; case 23: -#line 141 "Svc_Conf.y" +#line 140 "Svc_Conf.y" { if (ace_yyvsp[0].parse_node_ != 0) { @@ -805,11 +804,11 @@ case 23: } break; case 24: -#line 148 "Svc_Conf.y" +#line 147 "Svc_Conf.y" { ace_yyval.parse_node_ = 0; } break; case 25: -#line 153 "Svc_Conf.y" +#line 152 "Svc_Conf.y" { ACE_Static_Node *svc_type = ace_yyvsp[0].static_node_; @@ -837,7 +836,7 @@ case 25: } break; case 26: -#line 179 "Svc_Conf.y" +#line 178 "Svc_Conf.y" { ACE_Module_Type *mt = ace_get_module (ace_yyvsp[-2].static_node_, ace_yyvsp[0].static_node_->name ()); @@ -850,7 +849,7 @@ case 26: } break; case 27: -#line 190 "Svc_Conf.y" +#line 189 "Svc_Conf.y" { ACE_Module_Type *mt = ace_get_module (ace_yyvsp[-2].static_node_, ace_yyvsp[0].static_node_->name ()); @@ -859,7 +858,7 @@ case 27: } break; case 28: -#line 197 "Svc_Conf.y" +#line 196 "Svc_Conf.y" { ACE_Module_Type *mt = ace_get_module (ace_yyvsp[-2].static_node_, ace_yyvsp[0].static_node_->name ()); @@ -868,7 +867,7 @@ case 28: } break; case 29: -#line 204 "Svc_Conf.y" +#line 203 "Svc_Conf.y" { ACE_Static_Node *stream = ace_yyvsp[-2].static_node_; ACE_Static_Node *module = ace_yyvsp[0].static_node_; @@ -890,7 +889,7 @@ case 29: } break; case 30: -#line 227 "Svc_Conf.y" +#line 226 "Svc_Conf.y" { u_int flags = ACE_Service_Type::DELETE_THIS @@ -923,64 +922,64 @@ case 30: } break; case 31: -#line 261 "Svc_Conf.y" +#line 260 "Svc_Conf.y" { ace_yyval.type_ = 1; } break; case 32: -#line 265 "Svc_Conf.y" +#line 264 "Svc_Conf.y" { ace_yyval.type_ = 0; } break; case 33: -#line 269 "Svc_Conf.y" +#line 268 "Svc_Conf.y" { ace_yyval.type_ = 1; } break; case 34: -#line 276 "Svc_Conf.y" +#line 275 "Svc_Conf.y" { ace_yyval.location_node_ = new ACE_Object_Node (ace_yyvsp[-2].ident_, ace_yyvsp[0].ident_); } break; case 35: -#line 280 "Svc_Conf.y" +#line 279 "Svc_Conf.y" { ace_yyval.location_node_ = new ACE_Function_Node (ace_yyvsp[-4].ident_, ace_yyvsp[-2].ident_); } break; case 36: -#line 284 "Svc_Conf.y" +#line 283 "Svc_Conf.y" { ace_yyval.location_node_ = new ACE_Static_Function_Node (ace_yyvsp[-2].ident_); } break; case 37: -#line 291 "Svc_Conf.y" +#line 290 "Svc_Conf.y" { ace_yyval.type_ = ACE_MODULE_T; } break; case 38: -#line 295 "Svc_Conf.y" +#line 294 "Svc_Conf.y" { ace_yyval.type_ = ACE_SVC_OBJ_T; } break; case 39: -#line 299 "Svc_Conf.y" +#line 298 "Svc_Conf.y" { ace_yyval.type_ = ACE_STREAM_T; } break; case 41: -#line 306 "Svc_Conf.y" +#line 305 "Svc_Conf.y" { ace_yyval.ident_ = 0; } break; -#line 983 "Svc_Conf_y.cpp" +#line 982 "Svc_Conf_y.cpp" } ace_yyssp -= ace_yym; ace_yystate = *ace_yyssp; diff --git a/ace/Svc_Handler.cpp b/ace/Svc_Handler.cpp index effa6ab4608..56d4e15074b 100644 --- a/ace/Svc_Handler.cpp +++ b/ace/Svc_Handler.cpp @@ -99,20 +99,19 @@ ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::ACE_Svc_Handler (ACE_Thread_Manager *tm // work correctly in multi-threaded programs by using our ACE_TSS // class. this->dynamic_ = ACE_Dynamic::instance ()->is_dynamic (); - - if (this->dynamic_ != 0) - // Make sure to reset the flag. + if (this->dynamic_) + // Make sure to reset the flag ACE_Dynamic::instance ()->reset (); } -// Default behavior for a ACE_Svc_Handler object is to be registered -// with the ACE_Reactor (thereby ensuring single threading). +// Default behavior for a ACE_Svc_Handler object is to be registered with +// the ACE_Reactor (thereby ensuring single threading). template <PR_ST_1, ACE_SYNCH_DECL> int ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::open (void *) { ACE_TRACE ("ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::open"); -#if defined (ACE_DEBUGGING) +#if defined (DEBUGGING) ASYS_TCHAR buf[BUFSIZ]; ACE_PEER_STREAM_ADDR client_addr; @@ -130,7 +129,7 @@ ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::open (void *) ASYS_TEXT ("connected to %s on fd %d\n"), buf, this->peer_.get_handle ())); -#endif /* ACE_DEBUGGING */ +#endif /* DEBUGGING */ if (this->reactor () && this->reactor ()->register_handler (this, @@ -183,20 +182,6 @@ template <PR_ST_1, ACE_SYNCH_DECL> void ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::dump (void) const { ACE_TRACE ("ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::dump"); - - this->peer_.dump (); - ACE_DEBUG ((LM_DEBUG, - "dynamic_ = %d\n", - this->dynamic_)); - ACE_DEBUG ((LM_DEBUG, - "closing_ = %d\n", - this->closing_)); - ACE_DEBUG ((LM_DEBUG, - "recycler_ = %d\n", - this->recycler_)); - ACE_DEBUG ((LM_DEBUG, - "recycling_act_ = %d\n", - this->recycling_act_)); } template <PR_ST_1, ACE_SYNCH_DECL> ACE_PEER_STREAM & @@ -328,168 +313,6 @@ ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::recycle (void *) return 0; } -template <PR_ST_1, ACE_SYNCH_DECL> -ACE_Buffered_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::~ACE_Buffered_Svc_Handler (void) -{ - this->flush (); -} - -template <PR_ST_1, ACE_SYNCH_DECL> -ACE_Buffered_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::ACE_Buffered_Svc_Handler (ACE_Thread_Manager *tm, - ACE_Message_Queue<ACE_SYNCH_USE> *mq, - ACE_Reactor *reactor, - size_t maximum_buffer_size, - ACE_Time_Value *timeout) - : ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE> (tm, mq, reactor), - maximum_buffer_size_ (maximum_buffer_size), - current_buffer_size_ (0), - timeoutp_ (timeout) -{ - ACE_TRACE ("ACE_Buffered_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::ACE_Buffered_Svc_Handler"); - - if (this->timeoutp_ != 0) - { - this->interval_ = *timeout; - this->next_timeout_ = ACE_OS::gettimeofday () + this->interval_; - } -} - -template <PR_ST_1, ACE_SYNCH_DECL> int -ACE_Buffered_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::put (ACE_Message_Block *mb, - ACE_Time_Value *tv) -{ - ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, m, this->msg_queue ()->lock (), -1); - - // Enqueue <mb> onto the message queue. - if (this->putq (mb, tv) == -1) - return -1; - else - { - // Update the current number of bytes on the queue. - this->current_buffer_size_ += mb->total_size (); - - // Flush the buffer when the number of bytes exceeds the maximum - // buffer size or when the timeout period has elapsed. - if (this->current_buffer_size_ >= this->maximum_buffer_size_ - || (this->timeoutp_ != 0 - && this->next_timeout_ <= ACE_OS::gettimeofday ())) - return this->flush (); - else - return 0; - } -} - -// Flush the buffer. - -template <PR_ST_1, ACE_SYNCH_DECL> int -ACE_Buffered_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::flush (void) -{ - ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, m, this->msg_queue ()->lock (), -1); - ACE_Message_Block *entry = 0; - iovec iov[IOV_MAX]; - size_t i = 0; - int result = 0; - - // Iterate over all the <ACE_Message_Block>s in the - // <ACE_Message_Queue> and prepare them to be written out. - for (ACE_Message_Queue_Iterator<ACE_SYNCH_USE> iterator (*this->msg_queue ()); - iterator.next (entry) != 0 - && result == 0; - iterator.advance ()) - { - // Iterate over all the <Message_Block>s in a chain, including - // continuations. - for (ACE_Message_Block *temp = entry; - temp != 0; - temp = temp->cont ()) - { - iov[i].iov_len = temp->length (); - iov[i].iov_base = temp->rd_ptr (); - - i++; - - // Flush the <iovec>s when we've reached the maximum size - // for the platform. - if (i == IOV_MAX) - { -#if defined (ACE_DEBUGGING) - ACE_DEBUG ((LM_DEBUG, - "sending data (inside loop, i = %d)\n", - i)); -#endif /* ACE_DEBUGGING */ - // Send off the data. - if (this->peer ().sendv_n (iov, - i) == -1) - { - result = -1; - break; - } - i = 0; - } - } - } - - // Take care of any remaining <iovec>s. - if (i > 0 && result != -1) - { - if (this->peer ().sendv_n (iov, i) == -1) - result = -1; -#if defined (ACE_DEBUGGING) - ACE_DEBUG ((LM_DEBUG, - "sending data (final flush, i = %d)\n", - i)); -#endif /* ACE_DEBUGGING */ - } - - // Remove all the <ACE_Message_Block>s in the <ACE_Message_Queue> - // and <release> their memory. - while (this->msg_queue ()->is_empty () == 0) - { - if (this->msg_queue ()->dequeue_head (entry) == -1) - break; - - entry->release (); - } - - if (this->timeoutp_ != 0) - // Update the next timeout period by adding the interval. - this->next_timeout_ += this->interval_; - - this->current_buffer_size_ = 0; - - return result; -} - -template <PR_ST_1, ACE_SYNCH_DECL> void -ACE_Buffered_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::dump (void) const -{ - ACE_TRACE ("ACE_Buffered_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::dump"); - - ACE_Buffered_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::dump (); - ACE_DEBUG ((LM_DEBUG, - "maximum_buffer_size_ = %d\n", - this->maximum_buffer_size_)); - ACE_DEBUG ((LM_DEBUG, - "current_buffer_size_ = %d\n", - this->current_buffer_size_)); - if (this->timeoutp_ != 0) - ACE_DEBUG ((LM_DEBUG, - "next_timeout_.sec = %d, next_timeout_.usec = %d\n", - this->next_timeout_.sec (), - this->next_timeout_.usec ())); - else - ACE_DEBUG ((LM_DEBUG, - "timeoutp_ == NULL")); -} - -template <PR_ST_1, ACE_SYNCH_DECL> int -ACE_Buffered_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::handle_timeout (const ACE_Time_Value &, - const void *) -{ - ACE_TRACE ("ACE_Buffered_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::handle_timeout"); - return 0; -} - #undef PR_ST_1 #undef PR_ST_2 #endif /* ACE_SVC_HANDLER_C */ diff --git a/ace/Svc_Handler.h b/ace/Svc_Handler.h index a1251999404..b84b825be42 100644 --- a/ace/Svc_Handler.h +++ b/ace/Svc_Handler.h @@ -48,23 +48,18 @@ class ACE_Svc_Handler : public ACE_Task<ACE_SYNCH_USE> // ACE_Svc_Handler and the peer it is connected with. public: // = Initialization and termination methods. - ACE_Svc_Handler (ACE_Thread_Manager *thr_mgr = 0, - ACE_Message_Queue<ACE_SYNCH_USE> *mq = 0, - ACE_Reactor *reactor = ACE_Reactor::instance ()); - // Constructor initializes the <thr_mgr> and <mq> by passing them - // down to the <ACE_Task> base class. The <reactor> is passed to - // the <ACE_Event_Handler>. + ACE_Svc_Handler (ACE_Thread_Manager * = 0, + ACE_Message_Queue<ACE_SYNCH_USE> * = 0, + ACE_Reactor * = ACE_Reactor::instance ()); virtual ~ACE_Svc_Handler (void); - // Destructor. virtual int open (void * = 0); - // Activate the client handler. This is typically called by the - // <ACE_Acceptor> or <ACE_Connector>. + // Activate the client handler (called by the ACE_Acceptor or + // ACE_Connector). virtual int close (u_long flags = 0); - // Object termination hook -- application-specific cleanup code goes - // here. + // Object termination hook. virtual int idle (u_long flags = 0); // Call this method if you want to recycling the <Svc_Handler> @@ -138,9 +133,8 @@ public: public: - // = The following methods are not suppose to be public. - - // Because friendship is *not* inherited in C++, these methods have + // Note: The following methods are not suppose to be public. But + // because friendship is *not* inherited in C++, these methods have // to be public. // = Accessors to set/get the connection recycler. @@ -162,7 +156,7 @@ public: // recycling. Return 0 if the object is ready for recycling, -1 on // failures. -protected: +private: ACE_PEER_STREAM peer_; // Maintain connection with client. @@ -177,76 +171,7 @@ protected: // Pointer to the connection recycler. const void *recycling_act_; - // Asynchronous Completion Token (ACT) to be used to when talking to - // the recycler. -}; - -template <ACE_PEER_STREAM_1, ACE_SYNCH_DECL> -class ACE_Buffered_Svc_Handler : public ACE_Svc_Handler<ACE_PEER_STREAM_2, ACE_SYNCH_USE> -{ - // = TITLE - // Defines the interface for a service that exchanges data with - // its connected peer and supports buffering. - // - // = DESCRIPTION - // The buffering feature makes it possible to queue up - // <ACE_Message_Blocks> in an <ACE_Message_Queue> until (1) the - // queue is "full" or (2) a period of time elapses, at which - // point the queue is "flushed" via <sendv_n> to the peer. -public: - // = Initialization and termination methods. - ACE_Buffered_Svc_Handler (ACE_Thread_Manager *thr_mgr = 0, - ACE_Message_Queue<ACE_SYNCH_USE> *mq = 0, - ACE_Reactor *reactor = ACE_Reactor::instance (), - size_t max_buffer_size = 0, - ACE_Time_Value *relative_timeout = 0); - // Constructor initializes the <thr_mgr> and <mq> by passing them - // down to the <ACE_Task> base class. The <reactor> is passed to - // the <ACE_Event_Handler>. The <max_buffer_size> and - // <relative_timeout> are used to determine at what point to flush - // the <mq>. By default, there's no buffering at all. The - // <relative_timeout> value is interpreted to be in a unit that's - // relative to the current time returned by <ACE_OS::gettimeofday>. - - virtual ~ACE_Buffered_Svc_Handler (void); - // Destructor, which calls <flush>. - - virtual int put (ACE_Message_Block *message_block, - ACE_Time_Value *timeout = 0); - // Insert the <ACE_Message_Block> chain rooted at <message_block> - // into the <ACE_Message_Queue> with the designated <timeout>. The - // <flush> method will be called if this <put> causes the number of - // bytes to exceed the maximum buffer size or if the timeout period - // has elapsed. - - virtual int flush (void); - // Flush the <ACE_Message_Queue>, which writes all the queued - // <ACE_Message_Block>s to the <PEER_STREAM>. - - virtual int handle_timeout (const ACE_Time_Value &time, - const void *); - // This method is not currently implemented -- this is where the - // integration with the <Reactor> would occur. - - void dump (void) const; - // Dump the state of an object. - -protected: - size_t maximum_buffer_size_; - // Maximum size the <Message_Queue> can be before we have to flush - // the buffer. - - size_t current_buffer_size_; - // Current size in bytes of the <Message_Queue> contents. - - ACE_Time_Value next_timeout_; - // Timeout value used to control when the buffer is flushed. - - ACE_Time_Value interval_; - // Interval of the timeout. - - ACE_Time_Value *timeoutp_; - // Timeout pointer. + // ACT to be used to when talking to the recycler. }; #if defined (__ACE_INLINE__) diff --git a/ace/Synch.cpp b/ace/Synch.cpp index ed9e6b821c1..1d2e8421c74 100644 --- a/ace/Synch.cpp +++ b/ace/Synch.cpp @@ -993,14 +993,12 @@ ACE_RW_Thread_Mutex::dump (void) const template class ACE_Guard<ACE_Thread_Mutex>; template class ACE_Guard<ACE_RW_Thread_Mutex>; template class ACE_Read_Guard<ACE_RW_Thread_Mutex>; -template class ACE_Read_Guard<ACE_Thread_Mutex>; template class ACE_Write_Guard<ACE_RW_Thread_Mutex>; #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) // These are only specialized with ACE_HAS_THREADS. #pragma instantiate ACE_Guard<ACE_Thread_Mutex> #pragma instantiate ACE_Guard<ACE_RW_Thread_Mutex> #pragma instantiate ACE_Read_Guard<ACE_RW_Thread_Mutex> -#pragma instantiate ACE_Read_Guard<ACE_Thread_Mutex> #pragma instantiate ACE_Write_Guard<ACE_RW_Thread_Mutex> #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/ace/Synch_T.cpp b/ace/Synch_T.cpp index 5946d443182..4984d772f13 100644 --- a/ace/Synch_T.cpp +++ b/ace/Synch_T.cpp @@ -410,18 +410,16 @@ ACE_TSS<TYPE>::ACE_TSS (TYPE *ts_obj) { if (this->ts_init () == -1) { - // Save/restore errno. - ACE_Errno_Guard error (errno); + int errnum = errno; // What should we do if this call fails?! #if defined (ACE_HAS_WINCE) - ::MessageBox (NULL, - L"ACE_Thread::keycreate() failed!", - L"ACE_TSS::ACE_TSS", - MB_OK); + ::MessageBox (NULL, L"ACE_Thread::keycreate() failed!", + L"ACE_TSS::ACE_TSS", MB_OK); #else ACE_OS::fprintf (stderr, "ACE_Thread::keycreate() failed!"); #endif /* ACE_HAS_WINCE */ + errno = errnum; return; } diff --git a/ace/Template_Instantiations.cpp b/ace/Template_Instantiations.cpp index c21501d45e3..f881982b6e4 100644 --- a/ace/Template_Instantiations.cpp +++ b/ace/Template_Instantiations.cpp @@ -87,9 +87,8 @@ template class ACE_Cleanup_Adapter<ACE_SYNCH_RW_MUTEX>; template class ACE_Cleanup_Adapter<ACE_Thread_Mutex>; template class ACE_Double_Linked_List<ACE_Thread_Descriptor>; -template class ACE_Double_Linked_List_Iterator_Base<ACE_Thread_Descriptor>; template class ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor>; -template class ACE_Double_Linked_List_Reverse_Iterator<ACE_Thread_Descriptor>; + // ACE_SYNCH_RECURSIVE_MUTEX is defined in Synch_T.h template class ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>; diff --git a/ace/Thread_Manager.cpp b/ace/Thread_Manager.cpp index b4210955aa6..337a378dbd2 100644 --- a/ace/Thread_Manager.cpp +++ b/ace/Thread_Manager.cpp @@ -6,7 +6,6 @@ #include "ace/Dynamic.h" #include "ace/Object_Manager.h" #include "ace/Singleton.h" -#include "ace/Auto_Ptr.h" #if !defined (__ACE_INLINE__) #include "ace/Thread_Manager.i" @@ -603,7 +602,7 @@ ACE_Thread_Manager::spawn_i (ACE_THR_FUNC func, // Create a new thread running <func>. *Must* be called with the // <lock_> held... #if 1 - auto_ptr<ACE_Thread_Descriptor> new_thr_desc (this->thread_desc_freelist_.remove ()); + ACE_Thread_Descriptor *new_thr_desc = this->thread_desc_freelist_.remove (); new_thr_desc->thr_state_ = ACE_THR_IDLE; // Get a "new" Thread Descriptor from the freelist. @@ -619,31 +618,25 @@ ACE_Thread_Manager::spawn_i (ACE_THR_FUNC func, -1); #endif /* 1 */ - ACE_Thread_Adapter *thread_args = 0; -# if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) - ACE_NEW_RETURN (thread_args, - ACE_Thread_Adapter (func, - args, - (ACE_THR_C_FUNC) ace_thread_adapter, - this, - new_thr_desc.get (), - ACE_LOG_MSG->seh_except_selector(), - ACE_LOG_MSG->seh_except_handler()), - -1); + ACE_Thread_Adapter *thread_args = + new ACE_Thread_Adapter (func, + args, +#if defined(ACE_USE_THREAD_MANAGER_ADAPTER) + (ACE_THR_C_FUNC) ace_thread_manager_adapter, #else - ACE_NEW_RETURN (thread_args, - ACE_Thread_Adapter (func, - args, - (ACE_THR_C_FUNC) ace_thread_adapter, - this, - new_thr_desc.get ()), - -1); + (ACE_THR_C_FUNC) ace_thread_adapter, +#endif + this, + new_thr_desc +# if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) + , ACE_LOG_MSG->seh_except_selector() + , ACE_LOG_MSG->seh_except_handler() # endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ + ); - // @@ Memory leak if the previous new failed, need an auto pointer here. if (thread_args == 0) { - this->thr_list_.insert_head (new_thr_desc.release ()); + delete new_thr_desc; return -1; } @@ -719,7 +712,7 @@ ACE_Thread_Manager::spawn_i (ACE_THR_FUNC func, grp_id, task, flags, - new_thr_desc.release ()); + new_thr_desc); } } @@ -1164,12 +1157,13 @@ ACE_Thread_Manager::kill_thr (ACE_Thread_Descriptor *td, int signum) return -1; \ } \ int result = OP (ptr, ARG); \ - ACE_Errno_Guard error (errno); \ + int error = errno; \ while (! this->thr_to_be_removed_.is_empty ()) { \ ACE_Thread_Descriptor *td; \ this->thr_to_be_removed_.dequeue_head (td); \ this->remove_thr (td, 1); \ } \ + errno = error; \ return result // Suspend a single thread. @@ -1355,13 +1349,12 @@ ACE_Thread_Manager::apply_grp (int grp_id, if (! this->thr_to_be_removed_.is_empty ()) { - // Save/restore errno. - ACE_Errno_Guard error (errno); - - for (ACE_Thread_Descriptor *td; - this->thr_to_be_removed_.dequeue_head (td) != -1; - ) + // Preserve errno! + int error = errno; + ACE_Thread_Descriptor *td; + while (this->thr_to_be_removed_.dequeue_head (td) != -1) this->remove_thr (td, 1); + errno = error; } return result; @@ -1426,13 +1419,12 @@ ACE_Thread_Manager::apply_all (ACE_THR_MEMBER_FUNC func, int arg) if (! this->thr_to_be_removed_.is_empty ()) { - // Save/restore errno. - ACE_Errno_Guard error (errno); - - for (ACE_Thread_Descriptor *td; - this->thr_to_be_removed_.dequeue_head (td) != -1; - ) + // Preserve errno! + int error = errno; + ACE_Thread_Descriptor *td; + while (this->thr_to_be_removed_.dequeue_head (td) != -1) this->remove_thr (td, 1); + errno = error; } return result; @@ -1872,13 +1864,12 @@ ACE_Thread_Manager::apply_task (ACE_Task_Base *task, if (! this->thr_to_be_removed_.is_empty ()) { - // Save/restore errno. - ACE_Errno_Guard error (errno); - - for (ACE_Thread_Descriptor *td; - this->thr_to_be_removed_.dequeue_head (td) != -1; - ) + // Preserve errno! + int error = errno; + ACE_Thread_Descriptor *td; + while (this->thr_to_be_removed_.dequeue_head (td) != -1) this->remove_thr (td, 1); + errno = error; } return result; @@ -2366,13 +2357,9 @@ ACE_Thread_Control::exit (void *exit_status, int do_thr_exit) } #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) - template class ACE_Auto_Basic_Ptr<ACE_Thread_Descriptor>; - template class auto_ptr<ACE_Thread_Descriptor>; template class ACE_Double_Linked_List<ACE_Thread_Descriptor_Base>; - template class ACE_Double_Linked_List_Iterator_Base<ACE_Thread_Descriptor_Base>; template class ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor_Base>; template class ACE_Double_Linked_List<ACE_Thread_Descriptor>; - template class ACE_Double_Linked_List_Iterator_Base<ACE_Thread_Descriptor>; template class ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor>; template class ACE_Node<ACE_Thread_Descriptor*>; template class ACE_Unbounded_Queue<ACE_Thread_Descriptor*>; @@ -2385,13 +2372,9 @@ ACE_Thread_Control::exit (void *exit_status, int do_thr_exit) template class ACE_TSS<ACE_Thread_Exit>; # endif /* ACE_HAS_THREADS && (ACE_HAS_THREAD_SPECIFIC_STORAGE || ACE_HAS_TSS_EMULATION) */ #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) - #pragma instantiate ACE_Auto_Basic_Ptr<ACE_Thread_Descriptor> - #pragma instantiate auto_ptr<ACE_Thread_Descriptor> #pragma instantiate ACE_Double_Linked_List<ACE_Thread_Descriptor_Base> - #pragma instantiate ACE_Double_Linked_List_Iterator_Base<ACE_Thread_Descriptor_Base> #pragma instantiate ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor_Base> #pragma instantiate ACE_Double_Linked_List<ACE_Thread_Descriptor> - #pragma instantiate ACE_Double_Linked_List_Iterator_Base<ACE_Thread_Descriptor> #pragma instantiate ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor> #pragma instantiate ACE_Node<ACE_Thread_Descriptor*> #pragma instantiate ACE_Unbounded_Queue<ACE_Thread_Descriptor*> diff --git a/ace/Thread_Manager.h b/ace/Thread_Manager.h index cfe72b4122d..105a52e0c72 100644 --- a/ace/Thread_Manager.h +++ b/ace/Thread_Manager.h @@ -156,10 +156,8 @@ class ACE_Thread_Descriptor_Base : public ACE_OS_Thread_Descriptor friend class ACE_Thread_Manager; friend class ACE_Double_Linked_List<ACE_Thread_Descriptor_Base>; - friend class ACE_Double_Linked_List_Iterator_Base<ACE_Thread_Descriptor_Base>; friend class ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor_Base>; friend class ACE_Double_Linked_List<ACE_Thread_Descriptor>; - friend class ACE_Double_Linked_List_Iterator_Base<ACE_Thread_Descriptor>; friend class ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor>; public: ACE_Thread_Descriptor_Base (void); diff --git a/ace/Timer_Queue.i b/ace/Timer_Queue.i deleted file mode 100644 index 41e4324e61e..00000000000 --- a/ace/Timer_Queue.i +++ /dev/null @@ -1,22 +0,0 @@ -/* -*- C++ -*- */ - -template <class TYPE, class FUNCTOR> ACE_INLINE void -ACE_Timer_Queue_T<TYPE, FUNCTOR>::timer_skew (const ACE_Time_Value &skew) -{ - timer_skew_ = skew; -} - -template <class TYPE, class FUNCTOR> ACE_INLINE const ACE_Time_Value & -ACE_Timer_Queue_T<TYPE, FUNCTOR>::timer_skew (void) const -{ - return timer_skew_; -} - -template <class TYPE, class FUNCTOR> ACE_INLINE int -ACE_Timer_Queue_T<TYPE, FUNCTOR>::expire (void) -{ - if (!this->is_empty ()) - return this->expire (this->gettimeofday () + timer_skew_); - else - return 0; -} diff --git a/ace/Token_Collection.cpp b/ace/Token_Collection.cpp index e275942ea22..c1d4ab17e15 100644 --- a/ace/Token_Collection.cpp +++ b/ace/Token_Collection.cpp @@ -88,16 +88,13 @@ ACE_Token_Collection::acquire (int notify, iterator.advance ()) { if (debug_) - ACE_DEBUG ((LM_DEBUG, - ASYS_TEXT ("collection acquiring %s\n"), + ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("collection acquiring %s\n"), temp->int_id_->name ())); - if (temp->int_id_->acquire (notify, - sleep_hook, - options) == -1) + if (temp->int_id_->acquire (notify, sleep_hook, options) == -1) { - // Save/restore errno. - ACE_Errno_Guard error (errno); + int error = errno; this->release (); + errno = error; ACE_RETURN (-1); } } diff --git a/ace/Version.h b/ace/Version.h index d995936b89d..73a4cf3341e 100644 --- a/ace/Version.h +++ b/ace/Version.h @@ -3,5 +3,5 @@ #define ACE_MAJOR_VERSION 4 #define ACE_MINOR_VERSION 6 -#define ACE_BETA_VERSION 41 -#define ACE_VERSION "4.6.41" +#define ACE_BETA_VERSION 40 +#define ACE_VERSION "4.6.40" diff --git a/ace/config-aix-4.x.h b/ace/config-aix-4.x.h index cac8478bca0..dd18973d49b 100644 --- a/ace/config-aix-4.x.h +++ b/ace/config-aix-4.x.h @@ -29,7 +29,6 @@ # define ACE_HAS_STRING_CLASS // Denotes that GNU has cstring.h as standard, to redefine memchr(). # define ACE_HAS_GNU_CSTRING_H -# define ACE_HAS_SSIZE_T # define ACE_MALLOC_ALIGN 8 # if !defined (ACE_MT_SAFE) || ACE_MT_SAFE != 0 @@ -150,7 +149,6 @@ #define ACE_HAS_TIMOD_H #define ACE_HAS_TIUSER_H #define ACE_HAS_TLI -#define ACE_HAS_BROKEN_T_ERROR #define ACE_HAS_TLI_PROTOTYPES #define ACE_TLI_TCP_DEVICE "/dev/xti/tcp" diff --git a/ace/config-g++-common.h b/ace/config-g++-common.h index 46de4084b34..d3d1bd384da 100644 --- a/ace/config-g++-common.h +++ b/ace/config-g++-common.h @@ -11,11 +11,21 @@ #if __GNUC__ > 2 || ( __GNUC__ == 2 && __GNUC_MINOR__ >= 8) // egcs or g++ >= 2.8.0 -# define ACE_HAS_ANSI_CASTS -# define ACE_HAS_CPLUSPLUS_HEADERS -# define ACE_HAS_STDCPP_STL_INCLUDES -# define ACE_HAS_TEMPLATE_TYPEDEFS -# define ACE_HAS_TYPENAME_KEYWORD +# if __GNUC__ == 2 && __GNUC_MINOR__ >= 90 + // egcs or really modern g++. Do these work with g++ 2.8.0? +# define ACE_HAS_ANSI_CASTS +# define ACE_HAS_CPLUSPLUS_HEADERS +# define ACE_HAS_STDCPP_STL_INCLUDES +# define ACE_HAS_TEMPLATE_TYPEDEFS +# define ACE_HAS_TYPENAME_KEYWORD +# else + // Let's find out +# define ACE_HAS_ANSI_CASTS +# define ACE_HAS_CPLUSPLUS_HEADERS +# define ACE_HAS_STDCPP_STL_INCLUDES +# define ACE_HAS_TEMPLATE_TYPEDEFS +# define ACE_HAS_TYPENAME_KEYWORD +# endif /* __GNUC__ >= 2.90 */ # if __GNUC__ == 2 && __GNUC_MINOR__ >= 91 # define ACE_HAS_USING_KEYWORD @@ -42,10 +52,6 @@ # define ACE_HAS_EXCEPTIONS # endif /* __EXCEPTIONS && ! ACE_HAS_EXCEPTIONS */ -# if defined (ACE_HAS_EXCEPTIONS) -# define ACE_NEW_THROWS_EXCEPTIONS -# endif /* ACE_HAS_EXCEPTIONS */ - #else /* ! egcs */ // Plain old g++. # define ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES @@ -59,10 +65,10 @@ #if defined (i386) || defined (__i386__) // If running an Intel, assume that it's a Pentium so that - // ACE_OS::gethrtime () can use the RDTSC instruction. If running a - // 486 or lower, be sure to comment this out. (If not running an - // Intel CPU, this #define will not be seen because of the i386 - // protection, so it can be ignored.) + // ACE_OS::gethrtime () can use the RDTSC instruction. If + // running a 486 or lower, be sure to comment this out. + // (If not running an Intel CPU, this #define will not be seen + // because of the i386 protection, so it can be ignored.) # define ACE_HAS_PENTIUM #endif /* i386 */ diff --git a/ace/config-hpux-10.x-hpc++.h b/ace/config-hpux-10.x-hpc++.h index f43e757d156..11c525d72bd 100644 --- a/ace/config-hpux-10.x-hpc++.h +++ b/ace/config-hpux-10.x-hpc++.h @@ -59,10 +59,6 @@ // Compiler enforces the "One Definition Rule" # define ACE_HAS_ONE_DEFINITION_RULE -// Compiler enforces need for 'template<>" when specializing templates -# define ACE_HAS_STD_TEMPLATE_SPECIALIZATION - -// Compiler enforces proper use of 'typename' # define ACE_HAS_TYPENAME_KEYWORD // Compiler implements templates that support typedefs inside of classes diff --git a/ace/config-hpux-10.x.h b/ace/config-hpux-10.x.h index 4ac7f03d324..27a575b60e9 100644 --- a/ace/config-hpux-10.x.h +++ b/ace/config-hpux-10.x.h @@ -159,9 +159,6 @@ extern int h_errno; /* This isn't declared in a header file on HP-UX */ // Platform supports ACE_TLI, including SVR4 facilities. #define ACE_HAS_TLI - -// t_error's arg is char *, not const char * -#define ACE_HAS_BROKEN_T_ERROR // ACE_HAS_SVR4_TLI should work on HP-UX, but doesn't yet. Riverace // problem ID P27. //#define ACE_HAS_SVR4_TLI diff --git a/ace/config-linux-lxpthreads.h b/ace/config-linux-lxpthreads.h index a3a491587c5..d6b42ba31c9 100644 --- a/ace/config-linux-lxpthreads.h +++ b/ace/config-linux-lxpthreads.h @@ -28,6 +28,10 @@ #ifndef ACE_CONFIG_H #define ACE_CONFIG_H +// AIO Stuff is present here. Eventhough I could nt get the +// $ACE_ROOT/examples/Reactor/Proactor/<anything> to work. +#define ACE_HAS_AIO_CALLS + #include "ace/config-linux-common.h" #define ACE_HAS_SVR4_DYNAMIC_LINKING diff --git a/ace/config-mvs.h b/ace/config-mvs.h index 4eb1f8bdd33..985760cdedd 100644 --- a/ace/config-mvs.h +++ b/ace/config-mvs.h @@ -23,7 +23,6 @@ // Optimize ACE_Handle_Set for select(). #define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT -#define ACE_HAS_NONCONST_SELECT_TIMEVAL // See the README file in this directory // for a description of the following ACE_ macros @@ -104,8 +103,8 @@ #endif /* ACE_NTRACE */ #define ACE_SIZEOF_FLOAT 4 -#define ACE_SIZEOF_DOUBLE 8 -#define ACE_SIZEOF_LONG_DOUBLE 16 +#define ACE_SIZEOF_DOUBLE 4 +#define ACE_SIZEOF_LONG_DOUBLE 4 #define ACE_HAS_DIRENT #define ACE_LACKS_READDIR_R diff --git a/ace/config-psos-diab-ppc.h b/ace/config-psos-diab-ppc.h index 8bc6f9cf027..551d99cbda5 100644 --- a/ace/config-psos-diab-ppc.h +++ b/ace/config-psos-diab-ppc.h @@ -89,8 +89,6 @@ #define ACE_HAS_NONSTATIC_OBJECT_MANAGER -#define ACE_HAS_NONCONST_SELECT_TIMEVAL - #define ACE_LACKS_SEMBUF_T #define ACE_LACKS_EXEC diff --git a/ace/config-qnx-neutrino.h b/ace/config-qnx-neutrino.h deleted file mode 100644 index cea218e345b..00000000000 --- a/ace/config-qnx-neutrino.h +++ /dev/null @@ -1,126 +0,0 @@ -// $Id$ - -// The following configuration file is designed to work for Neutrino -// 2.0 (Beta) with GNU C++ and the POSIX (pthread) threads package. - -#ifndef ACE_CONFIG_H -#define ACE_CONFIG_H - -// gcc can do inline -#if __GNUC__ > 2 || ( __GNUC__ == 2 && __GNUC_MINOR__ >= 8) -# if !defined (__ACE_INLINE__) -# define __ACE_INLINE__ -# endif /* ! __ACE_INLINE__ */ -#endif - -#include "ace/config-g++-common.h" - -// The following defines the Neutrino compiler. -// gcc should know to call g++ as necessary -#ifdef __GNUC__ -# define ACE_CC_NAME "gcc" -#else -# define ACE_CC_NAME "NTO compiler ??" -#endif - -// /usr/nto/include/float.h defines -// FLT_MAX_EXP 127 -// DBL_MAX_EXP 1023 -// ace expects 128 & 1024 respectively -// to set the following macros in ace/Basic_Types.h -// These macros are: -#define ACE_SIZEOF_DOUBLE 8 -#define ACE_SIZEOF_FLOAT 4 - -#define ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R -#define ACE_HAS_4_4BSD_SENDMSG_RECVMSG -#define ACE_HAS_ALLOCA -#define ACE_HAS_ALLOCA_H -#define ACE_HAS_AUTOMATIC_INIT_FINI -#define ACE_HAS_CLOCK_GETTIME -#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES -#define ACE_HAS_DIRENT -#define ACE_HAS_GETPAGESIZE -#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT -#define ACE_HAS_NONSTATIC_OBJECT_MANAGER -#define ACE_HAS_IDTYPE_T -#define ACE_HAS_INLINED_OSCALLS -#define ACE_HAS_IP_MULTICAST -#define ACE_HAS_MINIMUM_IOSTREAMH_INCLUSION -#define ACE_HAS_MSG -#define ACE_HAS_MT_SAFE_MKTIME -#define ACE_HAS_NONCONST_SELECT_TIMEVAL -#define ACE_HAS_POSIX_SEM -#define ACE_HAS_POSIX_TIME -#define ACE_HAS_PTHREADS -#define ACE_HAS_PTHREADS_STD -#define ACE_HAS_PTHREAD_SIGMASK -#define ACE_HAS_P_READ_WRITE -#define ACE_HAS_REENTRANT_FUNCTIONS -#define ACE_HAS_SELECT_H -#define ACE_HAS_SIGINFO_T -#define ACE_HAS_SIGWAIT -#define ACE_HAS_SIG_ATOMIC_T -#define ACE_HAS_SIG_MACROS -#define ACE_HAS_SIN_LEN -#define ACE_HAS_SIZET_SOCKET_LEN -#define ACE_HAS_SSIZE_T -#define ACE_HAS_STRERROR -#define ACE_HAS_SVR4_GETTIMEOFDAY -#define ACE_HAS_TERM_IOCTLS -#define ACE_HAS_THREADS -#define ACE_HAS_THREAD_SPECIFIC_STORAGE -#define ACE_HAS_THR_C_DEST -#define ACE_HAS_THR_C_FUNC -#define ACE_HAS_TIMEZONE_GETTIMEOFDAY -#define ACE_HAS_UALARM -#define ACE_HAS_UCONTEXT_T -#define ACE_HAS_VOIDPTR_MMAP -#define ACE_HAS_VOIDPTR_SOCKOPT -#define ACE_LACKS_CMSG_DATA_MEMBER -#define ACE_LACKS_CONDATTR_PSHARED -#define ACE_LACKS_CONST_TIMESPEC_PTR -#define ACE_LACKS_FORK -#define ACE_LACKS_LINEBUFFERED_STREAMBUF -#define ACE_LACKS_MADVISE -#define ACE_LACKS_MSGBUF_T -#define ACE_LACKS_MUTEXATTR_PSHARED -#define ACE_LACKS_NAMED_POSIX_SEM -#define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS -#define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS -#define ACE_LACKS_PTHREAD_THR_SIGSETMASK -#define ACE_LACKS_RLIMIT -#define ACE_LACKS_RLIMIT_PROTOTYPE -#define ACE_LACKS_RPC_H -#define ACE_LACKS_RTTI -#define ACE_LACKS_RWLOCK_T -#define ACE_LACKS_SBRK -#define ACE_LACKS_SEEKDIR -#define ACE_LACKS_SOCKETPAIR -#define ACE_LACKS_SOME_POSIX_PROTOTYPES -#define ACE_LACKS_STREAM_MODULES -#define ACE_LACKS_STRRECVFD -#define ACE_LACKS_SYSCALL -#define ACE_LACKS_SYSTIME_H -#define ACE_LACKS_SYSV_MSG_H -#define ACE_LACKS_SYSV_SHMEM -#define ACE_LACKS_TCP_NODELAY -#define ACE_LACKS_TELLDIR -#define ACE_LACKS_TIMESPEC_T -#define ACE_LACKS_TRUNCATE -#define ACE_LACKS_T_ERRNO -#define ACE_LACKS_UALARM_PROTOTYPE -#define ACE_LACKS_UCONTEXT_H -#define ACE_LACKS_UNIX_DOMAIN_SOCKETS -#define ACE_LACKS_U_LONGLONG_T -#define ACE_MT_SAFE 1 -#define ACE_NEEDS_FUNC_DEFINITIONS -#define ACE_NEEDS_HUGE_THREAD_STACKSIZE 64000 -#define ACE_TEMPLATES_REQUIRE_SOURCE -#define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB - -#if !defined (ACE_NTRACE) -# define ACE_NTRACE 1 -#endif /* ACE_NTRACE */ - -#endif /* ACE_CONFIG_H */ diff --git a/ace/config-sunos5.5.h b/ace/config-sunos5.5.h index ca9cbe52d16..f6d7acdf9f5 100644 --- a/ace/config-sunos5.5.h +++ b/ace/config-sunos5.5.h @@ -32,11 +32,6 @@ # define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB 1 # define ACE_USES_OLD_IOSTREAMS 1 # define ACE_HAS_THR_C_DEST - -# if !defined (ACE_HAS_EXCEPTIONS) - // See /opt/SUNWspro_5.0/SC5.0/include/CC/stdcomp.h: -# define _RWSTD_NO_EXCEPTIONS 1 -# endif /* ! ACE_HAS_EXCEPTIONS */ # endif /* __SUNPRO_CC >= 0x500 */ # endif /* __SUNPRO_CC >= 0x420 */ @@ -60,12 +55,13 @@ // default. It can be enabled by adding "exceptions=1" to the "make" // invocation. See include/makeinclude/platform_sunos5_sunc++.GNU // for details. + // #define ACE_HAS_EXCEPTIONS # if defined (ACE_HAS_EXCEPTIONS) // If exceptions are enabled and we are using Sun/CC then // <operator new> throws an exception instead of returning 0. # define ACE_NEW_THROWS_EXCEPTIONS -# endif /* ACE_HAS_EXCEPTIONS */ +# endif /* ACE_NEW_THROWS_EXCEPTIONS */ /* If you want to disable threading with Sun CC, remove -mt from your CFLAGS, e.g., using make threads=0. */ diff --git a/ace/config-sunos5.6-sunc++-4.x.h b/ace/config-sunos5.6-sunc++-4.x.h deleted file mode 100644 index 7f63838fb78..00000000000 --- a/ace/config-sunos5.6-sunc++-4.x.h +++ /dev/null @@ -1,23 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -// The following configuration file is designed to work for SunOS 5.6 -// platforms using the SunC++ 4.x compiler. - -#if !defined (ACE_CONFIG_H) - -// ACE_CONFIG_H is defined by the following #included header. - -// At this point, there's no difference between our SunOS 5.5 and 5.6 -// configurations. -#if defined (__SUNPRO_CC) -# include "ace/config-sunos5.5-sunc++-4.x.h" -#elif defined (__GNUG__) -# include "ace/config-sunos5.5-g++.h" -#else /* ! __SUNPRO_CC__ && ! __GNUG__ */ -# error unsupported compiler in ace/config-sunos5.6.h -#endif /* ! __SUNPRO_CC__ && ! __GNUG__ */ - -// Additional SunOS 5.6 capabilities . . . -#define ACE_HAS_AIO_CALLS -#endif /* ACE_CONFIG_H */ |