EXT_ID
s with INT_ID
s.
#include <ace/Hash_Purgable_Map_Manager_T.h>
template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> class ACE_Hash_Purgable_Map_Manager_Ex : public ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> {
public:
typedef ACE_Hash_Purgable_Map_Entry<EXT_ID, INT_ID> PURGABLE_ENTRY;ACE_Hash_Purgable_Map_Manager_Ex (ACE_Allocator *alloc = 0);
ACE_Hash_Purgable_Map_Manager_Ex ( size_t size, ACE_Allocator *alloc = 0 );
~ACE_Hash_Purgable_Map_Manager_Ex (void);
int purge (int num);
protected:
int purge_i (int num);
int shared_find ( const EXT_ID &ext_id, ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&entry, u_long &loc );
ACE_Hash_Map_Entry<EXT_ID, INT_ID> *create_entry ( ACE_Hash_Map_Entry<EXT_ID, INT_ID> *next = 0, ACE_Hash_Map_Entry<EXT_ID, INT_ID> *prev = 0 );
ACE_Hash_Map_Entry<EXT_ID, INT_ID> *create_entry ( const EXT_ID &ext_id, const INT_ID &int_id, ACE_Hash_Map_Entry<EXT_ID, INT_ID> *next = 0, ACE_Hash_Map_Entry<EXT_ID, INT_ID> *prev = 0 );
int purge (void);
u_long timer_;
};
This implementation of a map uses a purgable hash table. Key hashing is achieved through the HASH_KEY object and key comparison is achieved through the COMPARE_KEYS object.
This class provides the feature of purging the entries on need based on the purging algorithm followed. By default the Least Recently Used algorithm is applied for purging "k" entires from the map.
The Least Recently used algorithm is used to decide on the entry to purge. For this a timesatmp is used per entry with a virtual timer providing the timestamp-value. On a lookup or use of an entry, its timestamp value is updated proving that the entry has been used recently. When the map gets full and some entries need to be purged, the "K" entries with minimum timestamp are removed.
ACE_Hash_Purgable_Map_Manager_Ex (ACE_Allocator *alloc = 0);
Hash_Purgable_Map_Manager_Ex
with default size.
ACE_Hash_Purgable_Map_Manager_Ex (
size_t size,
ACE_Allocator *alloc = 0
);
Hash_Purgable_Map_Manager_Ex
with size length
.
~ACE_Hash_Purgable_Map_Manager_Ex (void);
Hash_Purgable_Map_Manager_Ex
with size length
.
int purge (int num);
num
of entries specified are removed form the map based on
the purging algorithm used. By default Least Recently Used
algorithm is applied. Returns 0 on success and -1 on
failure. This method is called with locks held.
kirthika@cs.wustl.edu