diff options
author | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-05-19 18:13:56 +0000 |
---|---|---|
committer | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-05-19 18:13:56 +0000 |
commit | 22dfe70627ba814740c066777bad6f0c927255e5 (patch) | |
tree | 4a630a8708324ad721e607970c1c3c772fb9dffe | |
parent | 6615ab6e01996fd61401a97f10264bf9dc86696a (diff) | |
download | ATCD-22dfe70627ba814740c066777bad6f0c927255e5.tar.gz |
*** empty log message ***
-rw-r--r-- | examples/Web_Crawler/Cached_Connect_Strategy_T.cpp | 113 | ||||
-rw-r--r-- | examples/Web_Crawler/Caching_Strategies_T.cpp | 80 | ||||
-rw-r--r-- | examples/Web_Crawler/Caching_Strategies_T.h | 151 | ||||
-rw-r--r-- | examples/Web_Crawler/Optimal_Cache_Map_Manager_T.cpp | 282 | ||||
-rw-r--r-- | examples/Web_Crawler/Optimal_Cache_Map_Manager_T.h | 118 | ||||
-rw-r--r-- | examples/Web_Crawler/Optimal_Cache_Map_Manager_T.i | 88 |
6 files changed, 463 insertions, 369 deletions
diff --git a/examples/Web_Crawler/Cached_Connect_Strategy_T.cpp b/examples/Web_Crawler/Cached_Connect_Strategy_T.cpp index 4a8e9ec6311..bdb7047736e 100644 --- a/examples/Web_Crawler/Cached_Connect_Strategy_T.cpp +++ b/examples/Web_Crawler/Cached_Connect_Strategy_T.cpp @@ -4,7 +4,7 @@ #define CACHED_CONNECT_STRATEGY_T_C #if !defined (ACE_LACKS_PRAGMA_ONCE) -#define ACE_LACKS_PRAGMA_ONCE +#define ACE_LACKS_PRAGMA_ONCE #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/ACE.h" @@ -230,7 +230,7 @@ ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATE ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::CONNECTION_CACHE_ENTRY *&entry, int &found) { - + ACE::set_handle_limit (OPTIONS::instance ()->handle_limit ()); //ACE_DEBUG ((LM_DEBUG, "MAX handles %d \n", ACE::max_handles ())); // Explicit type conversion @@ -246,24 +246,9 @@ ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATE // Create a new svc_handler if (this->make_svc_handler (sh) == -1) return -1; - - // Actively establish the connection. This is a timed blocking - // connect. - if (this->CONNECT_STRATEGY::connect_svc_handler (sh, - remote_addr, - timeout, - local_addr, - reuse_addr, - flags, - perms) == -1) + + if (this->connect (...) == -1) { - // If connect() failed because of timeouts, we have to - // reject the connection entirely. This is necessary since - // currently there is no way for the non-blocking connects - // to complete and for the <Connector> to notify the cache - // of the completion of connect(). - if (errno == EWOULDBLOCK) - errno = ENOTSUP; return -1; } else @@ -282,17 +267,65 @@ ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATE { // Set the flag found = 1; - + // Get the cached <svc_handler> sh = entry->int_id_.first (); - + // Tell the <svc_handler> that it should prepare itself for // being recycled. this->prepare_for_recycling (sh); } - + return 0; - + +} + +connect () +{ + // Actively establish the connection. This is a timed blocking + // connect. + if (this->CONNECT_STRATEGY::connect_svc_handler (sh, + remote_addr, + timeout, + local_addr, + reuse_addr, + flags, + perms) == -1) + { + // If connect() failed because of timeouts, we have to reject + // the connection entirely. This is necessary since currently + // there is no way for the non-blocking connects to complete and + // for the <Connector> to notify the cache of the completion of + // connect(). + if (errno == EWOULDBLOCK) + errno = ENOTSUP; + else if (errno == EMFILE) + { + // @@purge here... + + // Try connecting again. + if (this->CONNECT_STRATEGY::connect_svc_handler (sh, + remote_addr, + timeout, + local_addr, + reuse_addr, + flags, + perms) == -1) + { + if (errno == EWOULDBLOCK) + errno = ENOTSUP; + return -1; + } + } + else + { + return -1; + } + } + else + { + return 0; + } } template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> int @@ -328,7 +361,7 @@ ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATE found); if (result != 0) return result; - + } // If it is a new connection, activate it. @@ -417,7 +450,7 @@ ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATE // Check if the user passed a hint svc_handler if (sh != 0) { - + int result = this->check_hint_i (sh, remote_addr, timeout, @@ -427,7 +460,9 @@ ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATE perms, entry, found); + // @@ Remove debugging ACE_DEBUG ((LM_DEBUG, "ACE_Cached_Connect_Strategy_Ex::connect_svc_handler_i CHECK_HINT_I result = %d\n", result)); + if (result != 0) return result; } @@ -444,19 +479,22 @@ ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATE perms, entry, found); - + + // @@ Purging here is not correct... + if (result != 0) { - // If the connect failed due to the process running out of file descriptors then, - // auto_purging of some connections are done from the CONNECTION_CACHE. This frees - // the descriptors which get used in the connect process and hence the same method is - // called again! + // If the connect failed due to the process running out of + // file descriptors then, auto_purging of some connections + // are done from the CONNECTION_CACHE. This frees the + // descriptors which get used in the connect process and + // hence the same method is called again! if (errno == EMFILE) { int result = this->connection_cache_.purge (); if (result == -1) return result; - + if (this->find_or_create_svc_handler_i (sh, remote_addr, timeout, @@ -476,10 +514,10 @@ ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATE // For all successful cases: mark the <svc_handler> in the cache // as being <in_use>. Therefore recyclable is BUSY. entry->ext_id_.state (ACE_Recyclable::BUSY); - + // And increment the refcount entry->ext_id_.increment (); - + return 0; } @@ -503,7 +541,7 @@ ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATE // Mark the <svc_handler> in the cache as not being <in_use>. // Therefore recyclable is IDLE. - + entry->ext_id_.state (ACE_Recyclable::IDLE); return 0; @@ -522,11 +560,10 @@ ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATE template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> int ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::purge_i (const void *recycling_act) { - // The wonders and perils of ACT CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act; - return this->connection_cache_.unbind (entry); + return this->connection_cache_.unbind (entry); } template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class MUTEX> int @@ -543,7 +580,7 @@ template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, MUTEX>::mark_as_closed_i (const void *recycling_act) { // The wonders and perils of ACT - CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act; + CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act; // Mark the <svc_handler> in the cache as CLOSED. entry->ext_id_.state (ACE_Recyclable::CLOSED); @@ -557,7 +594,7 @@ ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATE // Excluded other threads from changing cache while we take this // entry out. ACE_GUARD_RETURN (MUTEX, ace_mon, this->lock_, -1); - + return this->cleanup_hint_i (recycling_act); } diff --git a/examples/Web_Crawler/Caching_Strategies_T.cpp b/examples/Web_Crawler/Caching_Strategies_T.cpp index 9ae98e798b7..8bb86f1f730 100644 --- a/examples/Web_Crawler/Caching_Strategies_T.cpp +++ b/examples/Web_Crawler/Caching_Strategies_T.cpp @@ -6,7 +6,7 @@ #include "Caching_Strategies_T.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) -#define ACE_LACKS_PRAGMA_ONCE +#define ACE_LACKS_PRAGMA_ONCE #endif /* ACE_LACKS_PRAGMA_ONCE */ #if !defined (__ACE_INLINE__) @@ -16,10 +16,10 @@ ACE_RCSID(Web_Crawler, Caching_Strategies_T, "$Id$") template<class CONTAINER> int -ACE_LRU_Caching_Strategy<CONTAINER>::clear_cache (CONTAINER &container) +ACE_LRU_Caching_Strategy<CONTAINER>::clear_cache (CONTAINER &container) { // Check that the purge_percent is non-zero. - if (purge_percent_ == 0) + if (this->purge_percent_ == 0) return 0; // Also whether the number of entries in the cache is just one! @@ -29,17 +29,22 @@ ACE_LRU_Caching_Strategy<CONTAINER>::clear_cache (CONTAINER &container) KEY key_to_remove; VALUE value_to_remove; - + ITEM *item = 0; - + ATTRIBUTES min = 0; // Return value. int result = 0; - // Calculate the no of entries to remove form the cache depending upon the <purge_percent>. - int no_of_entries = (this->purge_percent_/100) * this->entries_; - // If the number of entries is less than 10 with the default percent + // Calculate the no of entries to remove form the cache depending + // upon the <purge_percent>. + int no_of_entries = (this->purge_percent_ / 100) * this->entries_; + + // @@ Don't do this stuff below. Simply take the ceiling of the + // above <no_of_entries>. + + // If the number of entries is less than 10 with the default percent // being 10, the calculated no_pf_entries equals 0. So increment it // so that atleast one entry gets purged. if (no_of_entries == 0) @@ -54,9 +59,9 @@ ACE_LRU_Caching_Strategy<CONTAINER>::clear_cache (CONTAINER &container) // The iterator moves thru the container searching for the entry with the // lowest ATTRIBUTES. - + for (min = (*iter).int_id_.second (), key_to_remove = (*iter).ext_id_, value_to_remove = (*iter).int_id_; - iter.next (item) != 0 ; + iter.next (item) != 0; ++iter) { // Ah! an item with lower ATTTRIBUTES... @@ -67,23 +72,31 @@ ACE_LRU_Caching_Strategy<CONTAINER>::clear_cache (CONTAINER &container) value_to_remove = (*iter).int_id_; } } + + // @@ Remove this ACE_DEBUG ((LM_DEBUG, "AUTO_PURGE\nLRU: before unbind: current_size %d\n", container.current_size ())); - + + // @@ Remove this svc_handler specific code!! + // Delete the dynamically allocated value object. if (value_to_remove.first () != 0) { (value_to_remove.first ())->recycler (0, 0); - + result = (value_to_remove.first ())->close(); if (result == -1) return result; } - // Remove the item from cache. + // Remove the item from cache. + + // @@ What happens to this result? You should stop on failure. result = container.unbind (key_to_remove); --this->entries_; + + // @@ Remove this ACE_DEBUG ((LM_DEBUG, "LRU:after unbind: result %d current_size %d\n", result, container.current_size ())); } - return result; + return result; } //////////////////////////////////////////////////////////////////////////////////////////////// @@ -101,17 +114,17 @@ ACE_LFU_Caching_Strategy<CONTAINER>::clear_cache (CONTAINER &container) KEY key_to_remove; VALUE value_to_remove; - + ITEM *item = 0; - + ATTRIBUTES min = 0; - + // Return value. int result = 0; - + // Calculate the no of entries to remove form the cache depending upon the <purge_percent>. int no_of_entries = (this->purge_percent_/100) * this->entries_; - // If the number of entries is less than 10 with the default percent + // If the number of entries is less than 10 with the default percent // being 10, the calculated no_pf_entries equals 0. So increment it // so that atleast one entry gets purged. if (no_of_entries == 0) @@ -119,13 +132,13 @@ ACE_LFU_Caching_Strategy<CONTAINER>::clear_cache (CONTAINER &container) if (container.current_size () >= 1) no_of_entries = 1; } - + for (int i = 0; i < no_of_entries ; ++i) { ITERATOR iter (container); // The iterator moves thru the container searching for the entry with the // lowest ATTRIBUTES. - + for (min = (*iter).int_id_.second (), key_to_remove = (*iter).ext_id_, value_to_remove = (*iter).int_id_; iter.next (item) != 0 ; ++iter) @@ -139,22 +152,22 @@ ACE_LFU_Caching_Strategy<CONTAINER>::clear_cache (CONTAINER &container) } } ACE_DEBUG ((LM_DEBUG, "AUTO_PURGE\nLFU: before unbind: current_size %d\n", container.current_size ())); - + // Delete the dynamically allocated value object. if (value_to_remove.first () != 0) { (value_to_remove.first ())->recycler (0, 0); - + result = (value_to_remove.first ())->close(); if (result == -1) return result; } - // Remove the item from cache. + // Remove the item from cache. result = container.unbind (key_to_remove); --this->entries_; ACE_DEBUG ((LM_DEBUG, "LFU:after unbind: result %d current_size %d\n", result, container.current_size ())); } - return result; + return result; } @@ -173,9 +186,9 @@ ACE_FIFO_Caching_Strategy<CONTAINER>::clear_cache (CONTAINER &container) KEY key_to_remove; VALUE value_to_remove; - + ITEM *item = 0; - + ATTRIBUTES min = 0; // Return value. @@ -183,7 +196,7 @@ ACE_FIFO_Caching_Strategy<CONTAINER>::clear_cache (CONTAINER &container) // Calculate the no of entries to remove form the cache depending upon the <purge_percent>. int no_of_entries = (this->purge_percent_/100) * this->entries_; - // If the number of entries is less than 10 with the default percent + // If the number of entries is less than 10 with the default percent // being 10, the calculated no_pf_entries equals 0. So increment it // so that atleast one entry gets purged. if (no_of_entries == 0) @@ -210,23 +223,23 @@ ACE_FIFO_Caching_Strategy<CONTAINER>::clear_cache (CONTAINER &container) } } ACE_DEBUG ((LM_DEBUG, "AUTO_PURGE\nFIFO: before unbind: current_size %d\n", container.current_size ())); - + // Delete the dynamically allocated value object. if (value_to_remove.first () != 0) { (value_to_remove.first ())->recycler (0, 0); - + result = (value_to_remove.first ())->close(); if (result == -1) return result; } - // Remove the item from cache. + // Remove the item from cache. result = container.unbind (key_to_remove); --this->entries_; ACE_DEBUG ((LM_DEBUG, "FIFO:after unbind: result %d current_size %d\n", result, container.current_size ())); } - return result; - + return result; + } //////////////////////////////////////////////////////////////////////////////////////////////// @@ -244,4 +257,3 @@ 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/examples/Web_Crawler/Caching_Strategies_T.h b/examples/Web_Crawler/Caching_Strategies_T.h index d2d7b4c0f0e..f62aee5da02 100644 --- a/examples/Web_Crawler/Caching_Strategies_T.h +++ b/examples/Web_Crawler/Caching_Strategies_T.h @@ -3,7 +3,7 @@ // ============================================================================ // -// = LIBRARY +// = LIBRARY // ace // // = FILENAME @@ -13,6 +13,7 @@ // Kirthika Parameswaran <kirthika@cs.wustl.edu> // // ============================================================================ + #ifndef CACHING_STRATEGIES_H #define CACHING_STRATEGIES_H @@ -22,36 +23,35 @@ #define ACE_LACKS_PRAGMA_ONCE #endif /* ACE_LACKS_PRAGMA_ONCE */ -template<class CONTAINER> +template <class CONTAINER> class ACE_LRU_Caching_Strategy { - // = TITLE + // = TITLE // Defines a Least Recently Used strategy which will decide on // the item to be removed from the cache. // // = DESCRIPTION - // This is a strategy which makes use of a virtual timer which - // 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. - + // This is a strategy which makes use of a virtual timer which + // 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. + public: - typedef int ATTRIBUTES; // Traits. - typedef ACE_TYPENAME CONTAINER::KEY KEY; + typedef int ATTRIBUTES; + // @@ Should these be here? + typedef ACE_TYPENAME CONTAINER::KEY KEY; typedef ACE_TYPENAME CONTAINER::VALUE VALUE; - typedef ACE_TYPENAME CONTAINER::ITERATOR ITERATOR; - typedef ACE_TYPENAME CONTAINER::ENTRY ITEM; // = Initialisation and termination. ACE_LRU_Caching_Strategy (CONTAINER &container, ATTRIBUTES timer = 0, - int purge_percent = 10); + int purge_percent = 10); // The <container> is the map in which the entries reside. // The timer attribute could be initialsed as per need. // The <purge_percent> field denotes the percentage of the entries @@ -60,27 +60,26 @@ public: ~ACE_LRU_Caching_Strategy (void); // = Operations of the startegy. - + ATTRIBUTES attributes (void); // Accessor method for the timer attributes. // = Accessor methods for the percentage of entries to purge. int purge_percent (void); - void purge_percent (int percentage); - // = Strategy related Operations + // = Strategy related Operations - int notify_bind (int result, - const ATTRIBUTES &attr); + int notify_bind (int result, + const ATTRIBUTES &attr); // This method acts as a notification about the CONTAINERs bind // method call. - int notify_find (int result, + int notify_find (int result, ATTRIBUTES &attr); //This method acts as a notification about the CONTAINERs find // method call - + int notify_unbind (int result, const ATTRIBUTES &attr); //This method acts as a notification about the CONTAINERs unbind @@ -89,12 +88,12 @@ public: int notify_trybind (int result, ATTRIBUTES &attr); //This method acts as a notification about the CONTAINERs trybind - // method call + // method call - int notify_rebind (int result, + int notify_rebind (int result, const ATTRIBUTES &attr); //This method acts as a notification about the CONTAINERs rebind - // method call + // method call int clear_cache (CONTAINER &container); // This is the method which looks at each ITEM's attributes and @@ -112,18 +111,18 @@ public: CONTAINER &container_; // The container over which the purging will occur according to the // strategy. - + int purge_percent_; // The level about which the purging will happen automagically. - + int entries_; - // The no of entries bound in the cache. + // The no of entries bound in the cache. }; ////////////////////////////////////////////////////////////////////////// -template<class CONTAINER> -class ACE_LFU_Caching_Strategy +template <class CONTAINER> +class ACE_LFU_Caching_Strategy { // = TITLE // Defines a Least Frequently Used strategy for which will decide on @@ -135,36 +134,36 @@ class ACE_LFU_Caching_Strategy // the frequency of use. According to the value of the attribute // the item is removed from the CONTAINER i.e cache. public: - - typedef int ATTRIBUTES; - + // Traits. - typedef ACE_TYPENAME CONTAINER::KEY KEY; - + typedef int ATTRIBUTES; + + typedef ACE_TYPENAME CONTAINER::KEY KEY; + typedef ACE_TYPENAME CONTAINER::VALUE VALUE; - + typedef ACE_TYPENAME CONTAINER::ITERATOR ITERATOR; - + typedef ACE_TYPENAME CONTAINER::ENTRY ITEM; // = Initialisation and termination methods. - + ACE_LFU_Caching_Strategy (void); ~ACE_LFU_Caching_Strategy (void); // = Startegy methods. Most of the methods are used from the base // class itself. - + ATTRIBUTES attributes (void); // Access the attributes. - int notify_bind (int result, + int notify_bind (int result, const ATTRIBUTES &attr); // This method acts as a notification about the CONTAINERs bind // method call. - int notify_find (int result, + int notify_find (int result, ATTRIBUTES &attr); // Lookup notification. @@ -176,13 +175,13 @@ public: int notify_trybind (int result, ATTRIBUTES &attr); //This method acts as a notification about the CONTAINERs trybind - // method call + // method call - int notify_rebind (int result, + int notify_rebind (int result, const ATTRIBUTES &attr); //This method acts as a notification about the CONTAINERs rebind - // method call - + // method call + int clear_cache (CONTAINER &container); // This is the method which looks at each ITEM's attributes and // then decides on the one to remove. @@ -194,7 +193,7 @@ public: ///////////////////////////////////////////////////////////// template<class CONTAINER> -class ACE_FIFO_Caching_Strategy +class ACE_FIFO_Caching_Strategy { // = TITLE // The First In First Out startegy is implemented wherein each @@ -202,24 +201,24 @@ class ACE_FIFO_Caching_Strategy // // = 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. + // removed from the cache. The items with least order are removed. public: typedef int ATTRIBUTES; - + // Traits. typedef ACE_TYPENAME CONTAINER::KEY KEY; - - typedef ACE_TYPENAME CONTAINER::VALUE VALUE; - + + typedef ACE_TYPENAME CONTAINER::VALUE VALUE; + typedef ACE_TYPENAME CONTAINER::ITERATOR ITERATOR; - + typedef ACE_TYPENAME CONTAINER::ENTRY ITEM; - + // = Initialisation and termination. ACE_FIFO_Caching_Strategy (ATTRIBUTES order = 0); - + ~ACE_FIFO_Caching_Strategy (void); // = Startegy methods. @@ -227,15 +226,15 @@ class ACE_FIFO_Caching_Strategy ATTRIBUTES attributes (void); // Accessor method. - int notify_bind (int result, + int notify_bind (int result, const ATTRIBUTES &attr); - // Notification for an item getting bound into the cache. - - int notify_find (int result, + // Notification for an item getting bound into the cache. + + int notify_find (int result, ATTRIBUTES &attr); //This method acts as a notification about the CONTAINERs find // method call - + int notify_unbind (int result, const ATTRIBUTES &attr); //This method acts as a notification about the CONTAINERs unbind @@ -244,17 +243,17 @@ class ACE_FIFO_Caching_Strategy int notify_trybind (int result, ATTRIBUTES &attr); //This method acts as a notification about the CONTAINERs trybind - // method call + // method call - int notify_rebind (int result, + int notify_rebind (int result, const ATTRIBUTES &attr); - // Notification for an item getting bound again into the cache. + // Notification for an item getting bound again into the cache. - int clear_cache (CONTAINER &container); + int clear_cache (CONTAINER &container); // This is the method which looks at each ITEM's attributes and // then decides on the one to remove. - void dump (void) const; + void dump (void) const; // Dumps the state of the object. private: @@ -264,7 +263,7 @@ private: }; template<class CONTAINER> -class ACE_Null_Caching_Strategy +class ACE_Null_Caching_Strategy { // = TITLE // The is a special caching strategy which doesnt have the purging @@ -273,15 +272,15 @@ class ACE_Null_Caching_Strategy // = DESCRIPTION // No purging provided. To be used when purging might be too expensive // an operation. - + public: typedef int ATTRIBUTES; - + // = Initialisation and termination. ACE_Null_Caching_Strategy (void); - + ~ACE_Null_Caching_Strategy (void); // = Startegy methods. All are NO_OP methods!!! @@ -289,15 +288,15 @@ class ACE_Null_Caching_Strategy ATTRIBUTES attributes (void); // Accessor method. - int notify_bind (int result, + int notify_bind (int result, const ATTRIBUTES &attr); - // Notification for an item getting bound into the cache. - - int notify_find (int result, + // Notification for an item getting bound into the cache. + + int notify_find (int result, ATTRIBUTES &attr); //This method acts as a notification about the CONTAINERs find // method call - + int notify_unbind (int result, const ATTRIBUTES &attr); //This method acts as a notification about the CONTAINERs unbind @@ -306,20 +305,22 @@ class ACE_Null_Caching_Strategy int notify_trybind (int result, ATTRIBUTES &attr); //This method acts as a notification about the CONTAINERs trybind - // method call + // method call - int notify_rebind (int result, + int notify_rebind (int result, const ATTRIBUTES &attr); - // Notification for an item getting bound again into the cache. + // Notification for an item getting bound again into the cache. int clear_cache (CONTAINER &container); // This is the method which looks at each ITEM's attributes and // then decides on the one to remove. - void dump (void) const; + void dump (void) const; // Dumps the state of the object. + private: + // @@ Remove this ATTRIBUTES dummy_; // Just a dummy member to be able to keep up with the common interface. }; diff --git a/examples/Web_Crawler/Optimal_Cache_Map_Manager_T.cpp b/examples/Web_Crawler/Optimal_Cache_Map_Manager_T.cpp index e8b1dfa3d59..e0ca775f066 100644 --- a/examples/Web_Crawler/Optimal_Cache_Map_Manager_T.cpp +++ b/examples/Web_Crawler/Optimal_Cache_Map_Manager_T.cpp @@ -12,7 +12,6 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/Malloc.h" -#include "ace/Service_Config.h" #if !defined (__ACE_INLINE__) #include "Optimal_Cache_Map_Manager_T.i" @@ -20,36 +19,34 @@ ACE_RCSID(Web_Crawler, Optimal_Cache_Map_Manager_T, "$Id$") -ACE_ALLOC_HOOK_DEFINE(ACE_Pair) - -ACE_ALLOC_HOOK_DEFINE(ACE_Reference_Pair) - ACE_ALLOC_HOOK_DEFINE(ACE_Optimal_Cache_Map_Manager) ACE_ALLOC_HOOK_DEFINE(ACE_Optimal_Cache_Map_Iterator) ACE_ALLOC_HOOK_DEFINE(ACE_Optimal_Cache_Map_Reverse_Iterator) - + template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> int ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::bind (const KEY &key, const VALUE &value) { - // Insert a entry which has the <key> and the <cache_value> which is - // the combination of the <value> and the attributes of the caching strategy. - ACE_Pair<VALUE, ATTRIBUTES> cache_value (value, - this->caching_strategy_.attributes ()); - - int bind_result =this->map_.bind (key, - cache_value); + // Insert an entry which has the <key> and the <cache_value> which + // is the combination of the <value> and the attributes of the + // caching strategy. + CACHE_VALUE cache_value (value, + this->caching_strategy_.attributes ()); + + int bind_result = this->map_.bind (key, + cache_value); if (bind_result != -1) { - int result = this->caching_strategy_.notify_bind (bind_result, + int result = this->caching_strategy_.notify_bind (bind_result, cache_value.second ()); if (result == -1) { - this->map_.unbind (key, - cache_value); - // Unless the notification goes thru the bind operation is not complete. + this->map_.unbind (key); + + // Unless the notification goes thru the bind operation is + // not complete. bind_result = -1; } } @@ -62,23 +59,25 @@ ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATE ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::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 strategy. - ACE_Pair<VALUE, ATTRIBUTES> cache_value (value, - this->caching_strategy_.attributes ()); - - int bind_result =this->map_.bind (key, - cache_value, - entry); + // the combination of the <value> and the attributes of the caching + // strategy. + CACHE_VALUE cache_value (value, + this->caching_strategy_.attributes ()); + + int bind_result = this->map_.bind (key, + cache_value, + entry); if (bind_result != -1) { - int result = this->caching_strategy_.notify_bind (bind_result, + int result = this->caching_strategy_.notify_bind (bind_result, cache_value.second ()); if (result == -1) { - this->map_.unbind (key, - cache_value); - // Unless the notification goes thru the bind operation is not complete. + this->map_.unbind (key); + + // Unless the notification goes thru the bind operation is + // not complete. bind_result = -1; } } @@ -89,23 +88,26 @@ template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACH ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::rebind (const KEY &key, const VALUE &value) { - ACE_Pair<VALUE, ATTRIBUTES> cache_value (value, - this->caching_strategy_.attributes ()); + CACHE_VALUE cache_value (value, + this->caching_strategy_.attributes ()); + int rebind_result = this->map_.rebind (key, cache_value); if (rebind_result != -1) { - int result = this->caching_strategy_.notify_rebind (rebind_result, + int result = this->caching_strategy_.notify_rebind (rebind_result, cache_value.second ()); if (result == -1) { - this->map_.unbind (key, - cache_value); - // Unless the notification goes thru the rebind operation is not complete. + this->map_.unbind (key); + + // Unless the notification goes thru the rebind operation is + // not complete. rebind_result = -1; } } - return rebind_result; + + return rebind_result; } @@ -114,29 +116,34 @@ ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATE const VALUE &value, VALUE &old_value) { - ACE_Pair<VALUE, ATTRIBUTES> cache_value (value, - this->caching_strategy_.attributes ()); - ACE_Pair<VALUE, ATTRIBUTES> old_cache_value (old_value, - this->caching_strategy_.attributes ()); + CACHE_VALUE cache_value (value, + this->caching_strategy_.attributes ()); + + CACHE_VALUE old_cache_value (old_value, + this->caching_strategy_.attributes ()); + int rebind_result = this->map_.rebind (key, cache_value, old_cache_value); if (rebind_result != -1) { - int result = this->caching_strategy_.notify_rebind (rebind_result, + int result = this->caching_strategy_.notify_rebind (rebind_result, cache_value.second ()); - + if (result == -1) { - this->map_.unbind (key, - cache_value); - // Unless the notification goes thru the rebind operation is not complete. + this->map_.unbind (key); + + // Unless the notification goes thru the rebind operation is + // not complete. rebind_result = -1; } else - old_value = old_cache_value.first (); + { + old_value = old_cache_value.first (); + } } - return rebind_result; + return rebind_result; } template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> int @@ -145,30 +152,35 @@ ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATE KEY &old_key, VALUE &old_value) { - ACE_Pair<VALUE, ATTRIBUTES> cache_value (value, - this->caching_strategy_.attributes ()); - ACE_Pair<VALUE, ATTRIBUTES> old_cache_value (old_value, - this->caching_strategy_.attributes ()); + CACHE_VALUE cache_value (value, + this->caching_strategy_.attributes ()); + + CACHE_VALUE old_cache_value (old_value, + this->caching_strategy_.attributes ()); + int rebind_result = this->map_.rebind (key, cache_value, old_key, old_cache_value); if (rebind_result != -1) { - int result = this->caching_strategy_.notify_rebind (rebind_result, + int result = this->caching_strategy_.notify_rebind (rebind_result, cache_value.second ()); - + if (result == -1) { - this->map_.unbind (key, - cache_value); - // Unless the notification goes thru the rebind operation is not complete. + this->map_.unbind (key); + + // Unless the notification goes thru the rebind operation is + // not complete. rebind_result = -1; } else - old_value = old_cache_value.first (); + { + old_value = old_cache_value.first (); + } } - return rebind_result; + return rebind_result; } template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> int @@ -176,34 +188,38 @@ ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATE const VALUE &value, ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::CACHE_ENTRY *&entry) { - ACE_Pair<VALUE, ATTRIBUTES> cache_value (value, + CACHE_VALUE cache_value (value, this->caching_strategy_.attributes ()); + int rebind_result = this->map_.rebind (key, cache_value, entry); if (rebind_result != -1) { - int result = this->caching_strategy_.notify_rebind (rebind_result, + int result = this->caching_strategy_.notify_rebind (rebind_result, cache_value.second ()); if (result == -1) { - this->map_.unbind (key, - cache_value); - // Unless the notification goes thru the rebind operation is not complete. + this->map_.unbind (key); + + // Unless the notification goes thru the rebind operation is + // not complete. rebind_result = -1; } } - return rebind_result; + return rebind_result; } template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> int ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::trybind (const KEY &key, VALUE &value) { - ACE_Pair<VALUE, ATTRIBUTES> cache_value (value, + CACHE_VALUE cache_value (value, this->caching_strategy_.attributes ()); + int trybind_result = this->map_.trybind (key, cache_value); + if (trybind_result != -1) { int result = this->caching_strategy_.notify_trybind (trybind_result, @@ -213,8 +229,8 @@ ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATE // If the entry has got inserted into the map, it is removed // due to failure. if (trybind_result == 0) - this->map_.unbind (key, - cache_value); + this->map_.unbind (key); + trybind_result = -1; } else @@ -223,9 +239,9 @@ ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATE // is overwritten with the value from the map. if (trybind_result == 1) value = cache_value.first (); - } - + } } + return trybind_result; } template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> int @@ -233,11 +249,13 @@ ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATE VALUE &value, ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::CACHE_ENTRY *&entry) { - ACE_Pair<VALUE, ATTRIBUTES> cache_value (value, + CACHE_VALUE cache_value (value, this->caching_strategy_.attributes ()); + int trybind_result = this->map_.trybind (key, cache_value, entry); + if (trybind_result != -1) { int result = this->caching_strategy_.notify_trybind (trybind_result, @@ -247,8 +265,8 @@ ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATE // If the entry has got inserted into the map, it is removed // due to failure. if (trybind_result == 0) - this->map_.unbind (key, - cache_value); + this->map_.unbind (key); + trybind_result = -1; } else @@ -257,50 +275,53 @@ ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATE // is overwritten with the value from the map. if (trybind_result == 1) value = cache_value.first (); - } - + } } + return trybind_result; } template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> int ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::find (const KEY& key, - VALUE& value) + VALUE &value) { // Lookup the key and populate the <value>. - ACE_Pair<VALUE, ATTRIBUTES> cache_value; - + CACHE_VALUE cache_value; + int find_result = this->map_.find (key, cache_value); + if (find_result != -1) - { - int result = this->caching_strategy_.notify_find (find_result, - cache_value.second ()); - // Unless the find and notification operations go thru, this - // method is not successful. - if (result == -1) - find_result = -1; - else - { - // Since the <cache_value> has now changed after the - // notification, we need to bind to the map again. - int rebind_result = this->map_.rebind (key, - cache_value); - if (rebind_result == -1) - find_result = -1; - else - value = cache_value.first (); - } - } + { + int result = this->caching_strategy_.notify_find (find_result, + cache_value.second ()); + // Unless the find and notification operations go thru, this + // method is not successful. + + if (result == -1) + find_result = -1; + else + { + // Since the <cache_value> has now changed after the + // notification, we need to bind to the map again. + int rebind_result = this->map_.rebind (key, + cache_value); + if (rebind_result == -1) + find_result = -1; + else + value = cache_value.first (); + } + } + return find_result; } template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> int -ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::find (const KEY& key) +ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::find (const KEY &key) { // Lookup the key and populate the <value>. - ACE_Pair<VALUE, ATTRIBUTES> cache_value; - + CACHE_VALUE cache_value; + int find_result = this->map_.find (key, cache_value); if (find_result != -1) @@ -325,41 +346,44 @@ ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATE } template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> int -ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::find (const KEY& key, +ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::find (const KEY &key, ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::CACHE_ENTRY *&entry) { + // @@ No rebind in this case! + // Lookup the key and populate the <value>. int find_result = this->map_.find (key, entry); if (find_result != -1) - { - int result = this->caching_strategy_.notify_find (find_result, - entry->int_id_.second ()); - // Unless the find and notification operations go thru, this - // method is not successful. - if (result == -1) - find_result = -1; - else - { - // Since the <cache_value> has now changed after the - // notification, we need to bind to the map again. - int rebind_result = this->map_.rebind (key, - entry->int_id_); - if (rebind_result == -1) - find_result = -1; - } - } + { + int result = this->caching_strategy_.notify_find (find_result, + entry->int_id_.second ()); + // Unless the find and notification operations go thru, this + // method is not successful. + if (result == -1) + find_result = -1; + else + { + // Since the <cache_value> has now changed after the + // notification, we need to bind to the map again. + int rebind_result = this->map_.rebind (key, + entry->int_id_); + if (rebind_result == -1) + find_result = -1; + } + } return find_result; } template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> int -ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::unbind (const KEY& key) +ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::unbind (const KEY &key) { - // Remove the entry from the cache. - ACE_Pair<VALUE, ATTRIBUTES> cache_value; + // Remove the entry from the cache. + CACHE_VALUE cache_value; + int unbind_result = this->map_.unbind (key, cache_value); - + if (unbind_result != -1) { int result = this->caching_strategy_.notify_unbind (unbind_result, @@ -368,19 +392,20 @@ ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATE if (result == -1) unbind_result = -1; } - return unbind_result; + + return unbind_result; } template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> int -ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::unbind (const KEY& key, - VALUE& value) +ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::unbind (const KEY &key, + VALUE &value) { // Remove the entry from the cache. - ACE_Pair<VALUE, ATTRIBUTES> cache_value; + CACHE_VALUE cache_value; int unbind_result = this->map_.unbind (key, cache_value); - + if (unbind_result != -1) { int result = this->caching_strategy_.notify_unbind (unbind_result, @@ -390,6 +415,7 @@ ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATE else value = cache_value.first (); } + return unbind_result; } @@ -398,8 +424,7 @@ ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATE { // Remove the entry from the cache. int unbind_result = this->map_.unbind (entry); - - + if (unbind_result != -1) { int result = this->caching_strategy_.notify_unbind (unbind_result, @@ -407,9 +432,10 @@ ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATE if (result == -1) unbind_result = -1; } + return unbind_result; } - + template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> void ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::dump (void) const { diff --git a/examples/Web_Crawler/Optimal_Cache_Map_Manager_T.h b/examples/Web_Crawler/Optimal_Cache_Map_Manager_T.h index 1390f3fe255..31a707638e1 100644 --- a/examples/Web_Crawler/Optimal_Cache_Map_Manager_T.h +++ b/examples/Web_Crawler/Optimal_Cache_Map_Manager_T.h @@ -3,7 +3,7 @@ // ============================================================================ // -// = LIBRARY +// = LIBRARY // ace // // = FILENAME @@ -13,6 +13,7 @@ // Kirthika Parameswaran <kirthika@cs.wustl.edu> // // ============================================================================ + #ifndef OPTIMAL_CACHE_MAP_MANAGER_T_H #define OPTIMAL_CACHE_MAP_MANAGER_T_H @@ -27,55 +28,62 @@ // Forward declaration. class ACE_Allocator; + template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> class ACE_Optimal_Cache_Map_Iterator; + template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> class ACE_Optimal_Cache_Map_Reverse_Iterator; + template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> class ACE_Optimal_Cache_Map_Manager -{ +{ // = TITLE - // Defines a abstraction which will take care of caching of a map. + // Defines a abstraction which will purge entries from a map. // The map considered is the ACE_Hash_Map_Manager. // // = DESCRIPTION - // The Optimal_Cache_Map_Manager will prepare the map given into its - // custody for purging on demand. The strategy for caching is - // decided by the developer and provided to the Cache Manager - // who acts as a agent and communicates between the Map and the - // Strategy for purging entries from the map. - // To tap the optimal methods like find (key, value, entry) present - // in the ACE_Hash_Map_Manager, it is used as the default map. + + // The Optimal_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. To tap the optimal methods like find(key,value,entry) + // present in the ACE_Hash_Map_Manager, + // Optimal_Cache_Map_Manager provides extra functionality on top + // of the Cache_Map_Manager. // - // No locking mechanism provided since locking at this level isnt efficient. - // Locking has to be provided by the application. -public: - + // No locking mechanism provided since locking at this level + // isnt efficient. Locking has to be provided by the + // application. +public: + // = Traits. typedef KEY key_type; typedef VALUE mapped_type; - + typedef ACE_TYPENAME CACHING_STRATEGY::ATTRIBUTES ATTRIBUTES; 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. + // 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. + + typedef ACE_Hash_Map_Manager_Ex<KEY, CACHE_VALUE, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> MAP; + typedef ACE_Hash_Map_Entry<KEY, CACHE_VALUE> CACHE_ENTRY; - typedef ACE_Hash_Map_Manager_Ex<KEY, ACE_Pair<VALUE, ATTRIBUTES>, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> MAP; - typedef ACE_Hash_Map_Entry<KEY, ACE_Pair<VALUE, ATTRIBUTES> > CACHE_ENTRY; - friend class ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>; friend class ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>; // = ACE-style iterator typedefs. - typedef ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> ITERATOR; - typedef ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> REVERSE_ITERATOR; + typedef ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> ITERATOR; + typedef ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> REVERSE_ITERATOR; // = STL-style iterator typedefs. - typedef ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> iterator; - typedef ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> reverse_iterator; + typedef ITERATOR iterator; + typedef REVERSE_ITERATOR reverse_iterator; // = Initialization and termination methods. - ACE_Optimal_Cache_Map_Manager (ACE_Allocator *alloc = 0, ATTRIBUTES attributes = 0, int purge_percent = 10); @@ -90,15 +98,15 @@ public: ~ACE_Optimal_Cache_Map_Manager (void); // Close down a <Optimal_Cache_Map_Manager> and release dynamically allocated // resources. - + int open (size_t length = ACE_DEFAULT_MAP_SIZE, ACE_Allocator *alloc = 0); // Initialise a cache with size <length>. - + int close (void); // Close down a cache and release dynamically allocated resources. - - int bind (const KEY &key, + + 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 @@ -111,7 +119,7 @@ public: // Same as a normal bind, except the cache entry is also passed back // to the caller. The entry in this case will either be the newly // created entry, or the existing one. - + int find (const KEY &key, VALUE &value); // Loopkup entry<key,value> in the cache. @@ -137,10 +145,10 @@ public: // 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 rebind (const KEY &key, const VALUE &value, - KEY &old_key, + KEY &old_key, VALUE &old_value); // Reassociate <key> with <value>, storing the old key and value // into the "out" parameters <old_key> and <old_value>. The @@ -164,7 +172,7 @@ public: // 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 trybind (const KEY &key, VALUE &value, ACE_Hash_Map_Entry<KEY, ACE_Pair<VALUE, ATTRIBUTES> > *&entry); @@ -175,7 +183,7 @@ public: int unbind (const KEY &key); // Remove <key> from the cache. - int unbind (const KEY &key, + int unbind (const KEY &key, VALUE &value); // Remove <key> from the cache, and return the <value> associated with // <key>. @@ -191,7 +199,7 @@ public: size_t total_size (void); // Return the total size of the cache. - + void dump (void) const; // Dumps the state of the object. @@ -223,27 +231,27 @@ protected: template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> class ACE_Optimal_Cache_Map_Iterator { - // = TITLE + // = TITLE // Defines a iterator for the Optimal_Cache_Map_Manager. // // = DESCRIPTION // Implementation to be provided by the iterator of the map - // managed by the ACE_Optimal_Cache_Map_Manager. + // managed by the ACE_Optimal_Cache_Map_Manager. public: - + // = Traits. typedef ACE_TYPENAME CACHING_STRATEGY::ATTRIBUTES ATTRIBUTES; 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. - + typedef ACE_Reference_Pair<KEY, VALUE> value_type; typedef ACE_Hash_Map_Iterator_Ex<KEY, ACE_Pair<VALUE, ATTRIBUTES>, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> IMPLEMENTATION; // = Initialisation and termination methods. ACE_Optimal_Cache_Map_Iterator (const ACE_Hash_Map_Iterator_Ex<KEY, ACE_Pair<VALUE, ATTRIBUTES>, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> &iterator_impl); - + ACE_Optimal_Cache_Map_Iterator (const ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> &rhs); // Copy constructor. @@ -265,13 +273,13 @@ public: ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> &operator++ (void); // Prefix advance - + ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> operator++ (int); // Postfix advance. ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> &operator-- (void); - // Prefix reverse. - + // Prefix reverse. + ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> operator-- (int); // Postfix reverse. @@ -279,8 +287,8 @@ public: // Returns the iterator of the internal map in the custody of the Optimal_Cache_Map_Manager. void dump (void) const; - // Dump the state of an object. - + // Dump the state of an object. + ACE_ALLOC_HOOK_DECLARE; // Declare the dynamic allocation hooks. @@ -294,27 +302,27 @@ protected: template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> class ACE_Optimal_Cache_Map_Reverse_Iterator { - // = TITLE + // = TITLE // Defines a reverse iterator for the Optimal_Cache_Map_Manager. // // = DESCRIPTION // Implementation to be provided by the reverse iterator of the map - // managed by thr Optimal_Cache_Map_manager. + // managed by thr Optimal_Cache_Map_manager. public: - + // = Traits. typedef ACE_TYPENAME CACHING_STRATEGY::ATTRIBUTES ATTRIBUTES; 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. - + typedef ACE_Reference_Pair<KEY, VALUE> value_type; typedef ACE_Hash_Map_Reverse_Iterator_Ex<KEY, ACE_Pair<VALUE, ATTRIBUTES>, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> REVERSE_IMPLEMENTATION; // = Initialisation and termination methods. ACE_Optimal_Cache_Map_Reverse_Iterator (const REVERSE_IMPLEMENTATION &iterator_impl); - + ACE_Optimal_Cache_Map_Reverse_Iterator (const ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> &rhs); // Copy constructor. @@ -336,13 +344,13 @@ public: ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> &operator++ (void); // Prefix advance - + ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> operator++ (int); // Postfix advance. ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> &operator-- (void); - // Prefix reverse. - + // Prefix reverse. + ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> operator-- (int); // Postfix reverse. @@ -350,8 +358,8 @@ public: // Returns the iterator of the internal map in the custody of the Optimal_Cache_Map_Manager. void dump (void) const; - // Dump the state of an object. - + // Dump the state of an object. + ACE_ALLOC_HOOK_DECLARE; // Declare the dynamic allocation hooks. diff --git a/examples/Web_Crawler/Optimal_Cache_Map_Manager_T.i b/examples/Web_Crawler/Optimal_Cache_Map_Manager_T.i index d0e30c78b74..99c13e20c28 100644 --- a/examples/Web_Crawler/Optimal_Cache_Map_Manager_T.i +++ b/examples/Web_Crawler/Optimal_Cache_Map_Manager_T.i @@ -1,14 +1,16 @@ /* -*- C++ -*- */ //$Id$ -#include "Optimal_Cache_Map_Manager_T.h" - +// @@ don't inline this template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::ACE_Optimal_Cache_Map_Manager (ACE_Allocator *alloc, ATTRIBUTES attributes, int purge_percent) :map_ (alloc), + // @@ Remove attributes and purge_percent from the constructor of the caching strategy caching_strategy_ (map_, attributes, purge_percent) + + // @@ Add the ability for the user to pass in a caching strategy. { } @@ -18,12 +20,12 @@ ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRAT ACE_Allocator *alloc, ATTRIBUTES attributes, int purge_percent) - :map_ (size, + :map_ (size, alloc), caching_strategy_ (map_, attributes, purge_percent) { } - + template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::~ACE_Optimal_Cache_Map_Manager (void) { @@ -31,45 +33,49 @@ ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRAT template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE int ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::open (size_t length, - ACE_Allocator *alloc) + ACE_Allocator *alloc) { return this->map_.open (length, alloc); } -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE int +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE int ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::purge (void) { + // @@ Remove debugging statements. ACE_DEBUG ((LM_DEBUG, "ACE_Optimal_Cache_Map_Manager::PURGE\n")); + + // @@ Why does this need the map again? Didn't we pass this in the + // constructor? return this->caching_strategy ().clear_cache (this->map ()); } -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE size_t +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE size_t ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::current_size (void) { return this->map_.current_size (); } -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE size_t +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE size_t ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::total_size (void) { return this->map_.total_size (); } template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE int -ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::close (void) +ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::close (void) { return this->map_.close (); } template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::MAP & -ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::map (void) +ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::map (void) { return this->map_; } template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE CACHING_STRATEGY & -ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::caching_strategy (void) +ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::caching_strategy (void) { return this->caching_strategy_; } @@ -77,13 +83,13 @@ ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRAT template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::ITERATOR ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::begin (void) { - return ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::ITERATOR (this->map_.begin ()); + return ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::ITERATOR (this->map_.begin ()); } template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::ITERATOR ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::end (void) { - return ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::ITERATOR (this->map_.end ()); + return ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::ITERATOR (this->map_.end ()); } template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::REVERSE_ITERATOR @@ -99,13 +105,13 @@ ACE_Optimal_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRAT //////////////////////////////////////////////////////////////////////////////////////////////////////////// -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::ACE_Optimal_Cache_Map_Iterator (const ACE_Optimal_Cache_Map_Iterator <KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> &rhs) : iterator_implementation_ (rhs.iterator_implementation ()) { } -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::~ACE_Optimal_Cache_Map_Iterator (void) { } @@ -129,42 +135,44 @@ ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRAT return this->iterator_implementation_ != rhs.iterator_implementation (); } -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE ACE_Reference_Pair<KEY, VALUE> +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE ACE_Reference_Pair<KEY, VALUE> ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::operator* (void) const { value_type retv ((*this->iterator_implementation_).ext_id_, (*this->iterator_implementation_).int_id_.first ()); return retv; } -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> & ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::operator++ (void) { - this->iterator_implementation_.operator++ (); + ++this->iterator_implementation_; return *this; } -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE -ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE +ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::operator++ (int) { - this->iterator_implementation_.operator++ (1); - return *this; + ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> retn = *this; + ++this->iterator_implementation_; + return retn; } -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> & ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::operator-- (void) { - this->iterator_implementation_.operator-- (); + --this->iterator_implementation_; return *this; } -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE -ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE +ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::operator-- (int) { - this->iterator_implementation_.operator-- (1); + ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> retn = *this; + --this->iterator_implementation_; return *this; } @@ -177,10 +185,11 @@ ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRAT template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::ACE_Optimal_Cache_Map_Iterator (const ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::IMPLEMENTATION &iterator_impl) - : iterator_implementation_(iterator_impl) + : iterator_implementation_ (iterator_impl) { } +// @@ Don't pass this return value by value. Pass it back via reference. template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::IMPLEMENTATION ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::iterator_implementation (void) const { @@ -189,13 +198,15 @@ ACE_Optimal_Cache_Map_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRAT //////////////////////////////////////////////////////////////////////////////////////////////////////////// -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE +// @@ Fix reverse iterator similar to the regular iterator + +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::ACE_Optimal_Cache_Map_Reverse_Iterator (const ACE_Optimal_Cache_Map_Reverse_Iterator <KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> &rhs) : reverse_iterator_implementation_ (rhs.iterator_implementation ()) { } -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::~ACE_Optimal_Cache_Map_Reverse_Iterator (void) { } @@ -219,14 +230,14 @@ ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHI return this->reverse_iterator_implementation_ != rhs.iterator_implementation (); } -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE ACE_Reference_Pair<KEY, VALUE> +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE ACE_Reference_Pair<KEY, VALUE> ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::operator* (void) const { value_type retv ((*this->reverse_iterator_implementation_).ext_id_, (*this->reverse_iterator_implementation_).int_id_.first ()); return retv; } -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> & ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::operator++ (void) { @@ -234,15 +245,15 @@ ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHI return *this; } -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE -ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE +ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::operator++ (int) { this->reverse_iterator_implementation_.operator++ (1); return *this; } -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> & ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::operator-- (void) { @@ -250,8 +261,8 @@ ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHI return *this; } -template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE -ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> +template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE +ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY> ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::operator-- (int) { this->reverse_iterator_implementation_.operator-- (1); @@ -267,7 +278,7 @@ ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHI template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY> ACE_INLINE ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::ACE_Optimal_Cache_Map_Reverse_Iterator (const ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY>::REVERSE_IMPLEMENTATION &iterator_impl) - : reverse_iterator_implementation_(iterator_impl) + : reverse_iterator_implementation_(iterator_impl) { } @@ -276,4 +287,3 @@ ACE_Optimal_Cache_Map_Reverse_Iterator<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHI { return this->reverse_iterator_implementation_; } - |