diff options
author | jxh <jxh@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-03-17 09:29:41 +0000 |
---|---|---|
committer | jxh <jxh@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-03-17 09:29:41 +0000 |
commit | 8c7ce0b04790b91b087e59aab7ea1b28bb59a5a2 (patch) | |
tree | ec477087f2b5ade5a9af791241a4976bbdd42904 /apps/JAWS/PROTOTYPE/JAWS/Cache_Hash_T.h | |
parent | a3a59247ea1dfbf32b8e03e2d1652357910d5892 (diff) | |
download | ATCD-8c7ce0b04790b91b087e59aab7ea1b28bb59a5a2.tar.gz |
Added Cache files here. Altered IO.cpp to match fix in JAWS classic
indicated by Bill Rizzi. Altered Makefile to match.
Diffstat (limited to 'apps/JAWS/PROTOTYPE/JAWS/Cache_Hash_T.h')
-rw-r--r-- | apps/JAWS/PROTOTYPE/JAWS/Cache_Hash_T.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/apps/JAWS/PROTOTYPE/JAWS/Cache_Hash_T.h b/apps/JAWS/PROTOTYPE/JAWS/Cache_Hash_T.h new file mode 100644 index 00000000000..1d8a0a2c4ae --- /dev/null +++ b/apps/JAWS/PROTOTYPE/JAWS/Cache_Hash_T.h @@ -0,0 +1,61 @@ +/* -*- c++ -*- */ +// $Id$ + +#ifndef ACE_CACHE_HASH_T_H +#define ACE_CACHE_HASH_T_H + +#include "ace/OS.h" +#include "JAWS/Cache_Object.h" + +// Forward declaration +template <class EXT_ID, class INT_ID, class EQ_FUNC> +class ACE_Hash_Bucket_Manager; + +template <class EXT_ID, class HASH_FUNC, class EQ_FUNC> +class ACE_Cache_Hash +{ +public: + + typedef ACE_Hash_Bucket_Manager<EXT_ID, ACE_Cache_Object *, EQ_FUNC> + CACHE_BUCKET_MANAGER; + + ACE_Cache_Hash (ACE_Allocator *alloc = 0, size_t size = 521); + // 521 == smallest number > 512 that is prime. Why is a prime + // number important? I am trying to maximize scattering when using + // mod on the hashed value. This might be bogus though. + + virtual ~ACE_Cache_Hash (void); + + int find (const EXT_ID &ext_id) const; + int find (const EXT_ID &ext_id, ACE_Cache_Object *&int_id) const; + int bind (const EXT_ID &ext_id, ACE_Cache_Object *const &int_id); + int trybind (const EXT_ID &ext_id, ACE_Cache_Object *&int_id); + int rebind (const EXT_ID &ext_id, ACE_Cache_Object *const &int_id, + EXT_ID &old_ext_id, ACE_Cache_Object *&old_int_id); + + int unbind (const EXT_ID &ext_id); + int unbind (const EXT_ID &ext_id, ACE_Cache_Object *&int_id); + + size_t size (void) const; + +protected: + + virtual unsigned long hash (const EXT_ID &ext_id) const; + int isprime (unsigned long number) const; + int new_cachebucket (size_t idx); + +private: + + ACE_Allocator *allocator_; + size_t size_; + + ACE_SYNCH_MUTEX lock_; + CACHE_BUCKET_MANAGER **hashtable_; + +}; + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "JAWS/Cache_Hash_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#endif /* ACE_CACHE_HASH_T_H */ |