Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ACE_Map_Manager Class Template Reference

Define a map abstraction that associates <EXT_ID>s with <INT_ID>s. More...

#include <Map_Manager.h>

Inheritance diagram for ACE_Map_Manager:

Inheritance graph
[legend]
Collaboration diagram for ACE_Map_Manager:

Collaboration graph
[legend]
List of all members.

Public Types

typedef EXT_ID KEY
typedef INT_ID VALUE
typedef ACE_Map_Entry< EXT_ID,
INT_ID > 
ENTRY
typedef ACE_Map_Iterator<
EXT_ID, INT_ID, ACE_LOCK > 
ITERATOR
typedef ACE_Map_Const_Iterator<
EXT_ID, INT_ID, ACE_LOCK > 
CONST_ITERATOR
typedef ACE_Map_Reverse_Iterator<
EXT_ID, INT_ID, ACE_LOCK > 
REVERSE_ITERATOR
typedef ACE_Map_Iterator<
EXT_ID, INT_ID, ACE_LOCK > 
iterator
typedef ACE_Map_Const_Iterator<
EXT_ID, INT_ID, ACE_LOCK > 
const_iterator
typedef ACE_Map_Reverse_Iterator<
EXT_ID, INT_ID, ACE_LOCK > 
reverse_iterator

Public Methods

 ACE_Map_Manager (ACE_Allocator *alloc=0)
 Initialize a ACE_Map_Manager with the ACE_DEFAULT_MAP_SIZE. More...

 ACE_Map_Manager (size_t size, ACE_Allocator *alloc=0)
 Initialize a ACE_Map_Manager with size entries. More...

int open (size_t length=ACE_DEFAULT_MAP_SIZE, ACE_Allocator *alloc=0)
 Initialize a ACE_Map_Manager with size length. More...

int close (void)
 Close down a ACE_Map_Manager and release dynamically allocated resources. More...

 ~ACE_Map_Manager (void)
 Close down a ACE_Map_Manager and release dynamically allocated resources. More...

int bind (const EXT_ID &ext_id, const INT_ID &int_id)
int rebind (const EXT_ID &ext_id, const INT_ID &int_id, EXT_ID &old_ext_id, INT_ID &old_int_id)
int rebind (const EXT_ID &ext_id, const INT_ID &int_id, INT_ID &old_int_id)
int rebind (const EXT_ID &ext_id, const INT_ID &int_id)
 Reassociate ext_id with int_id. Old values in the map are ignored. More...

int trybind (const EXT_ID &ext_id, INT_ID &int_id)
int find (const EXT_ID &ext_id, INT_ID &int_id) const
int find (const EXT_ID &ext_id) const
 Returns 0 if the <ext_id> is in the mapping, otherwise -1. More...

int unbind (const EXT_ID &ext_id)
int unbind (const EXT_ID &ext_id, INT_ID &int_id)
void unbind_all (void)
size_t current_size (void) const
 Return the current size of the map. More...

size_t total_size (void) const
 Return the total size of the map. More...

ACE_LOCK & mutex (void)
void dump (void) const
 Dump the state of an object. More...

ACE_Map_Iterator< EXT_ID,
INT_ID, ACE_LOCK > 
begin (void)
 Return forward iterator. More...

ACE_Map_Iterator< EXT_ID,
INT_ID, ACE_LOCK > 
end (void)
ACE_Map_Reverse_Iterator<
EXT_ID, INT_ID, ACE_LOCK > 
rbegin (void)
 Return reverse iterator. More...

ACE_Map_Reverse_Iterator<
EXT_ID, INT_ID, ACE_LOCK > 
rend (void)

Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks. More...


Protected Types

enum  { MAX_EXPONENTIAL = 64 * 1024, LINEAR_INCREASE = 32 * 1024 }

Protected Methods

int bind_i (const EXT_ID &ext_id, const INT_ID &int_id)
 Performs the binding of <ext_id> to <int_id>. Must be called with locks held. More...

int shared_bind (const EXT_ID &ext_id, const INT_ID &int_id)
 Bind an entry (without finding first). Must be called with locks held. More...

int rebind_i (const EXT_ID &ext_id, const INT_ID &int_id, EXT_ID &old_ext_id, INT_ID &old_int_id)
 Performs a rebinding of <ext_it> to <int_id>. Also, recovers old values. Must be called with locks held. More...

int rebind_i (const EXT_ID &ext_id, const INT_ID &int_id, INT_ID &old_int_id)
 Performs a rebinding of <ext_it> to <int_id>. Also, recovers old values. Must be called with locks held. More...

int rebind_i (const EXT_ID &ext_id, const INT_ID &int_id)
 Performs a rebinding of <ext_it> to <int_id>. Must be called with locks held. More...

int trybind_i (const EXT_ID &ext_id, INT_ID &int_id)
 Performs a conditional bind of <int_id> using <ext_id> as the key. Must be called with locks held. More...

int find_i (const EXT_ID &ext_id, INT_ID &int_id)
 Performs a find of <int_id> using <ext_id> as the key. Must be called with locks held. More...

int find_and_return_index (const EXT_ID &ext_id, ACE_UINT32 &slot)
 Performs a find using <ext_id> as the key. Must be called with locks held. More...

int unbind_i (const EXT_ID &ext_id, INT_ID &int_id)
 Performs an unbind of <int_id> using <ext_id> as the key. Must be called with locks held. More...

int unbind_i (const EXT_ID &ext_id)
 Performs an unbind using <ext_id> as the key. Must be called with locks held. More...

int unbind_and_return_index (const EXT_ID &ext_id, ACE_UINT32 &slot)
 Performs an unbind using <ext_id> as the key. Must be called with locks held. More...

void unbind_slot (ACE_UINT32 slot)
 Unbind <slot>. More...

int resize_i (ACE_UINT32 size)
 Resize the map. Must be called with locks held. More...

int close_i (void)
 Close down a <Map_Manager>. Must be called with locks held. More...

int equal (const EXT_ID &id1, const EXT_ID &id2)
 Returns 1 if <id1> == <id2>, else 0. This is defined as a separate method to facilitate template specialization. More...

ACE_UINT32 new_size (void)
 This function returns the new size of the Map Manager. This function is called when we run out of room and need to resize. More...

void free_search_structure (void)
 Explicitly call the destructors and free up the <search_structure_>. More...

ACE_UINT32 free_list_id (void) const
 Id of the free list sentinel. More...

ACE_UINT32 occupied_list_id (void) const
 Id of the occupied list sentinel. More...

int next_free (ACE_UINT32 &slot)
 Finds the next free slot. More...

void move_from_free_list_to_occupied_list (ACE_UINT32 slot)
 Move from free list to occupied list. More...

void move_from_occupied_list_to_free_list (ACE_UINT32 slot)
 Move from occupied list to free list. More...

void shared_move (ACE_UINT32 slot, ACE_Map_Entry< EXT_ID, INT_ID > &current_list, ACE_UINT32 current_list_id, ACE_Map_Entry< EXT_ID, INT_ID > &new_list, ACE_UINT32 new_list_id)
 Move helper. More...


Protected Attributes

ACE_Allocatorallocator_
 Pointer to a memory allocator. More...

ACE_LOCK lock_
 Synchronization variable for the MT_SAFE <ACE_Map_Manager>. More...

ACE_Map_Entry< EXT_ID, INT_ID > * search_structure_
 Implement the Map as a resizeable array of <ACE_Map_Entry>. More...

ACE_UINT32 total_size_
 Total number of elements in this->search_structure_. More...

ACE_UINT32 cur_size_
 Current size of the map. More...

ACE_Map_Entry< EXT_ID, INT_ID > free_list_
 Free list. More...

ACE_Map_Entry< EXT_ID, INT_ID > occupied_list_
 Occupied list. More...


Private Methods

void operator= (const ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK > &)
 ACE_Map_Manager (const ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK > &)

Friends

class ACE_Map_Iterator_Base< EXT_ID, INT_ID, ACE_LOCK >
class ACE_Map_Const_Iterator_Base< EXT_ID, INT_ID, ACE_LOCK >
class ACE_Map_Iterator< EXT_ID, INT_ID, ACE_LOCK >
class ACE_Map_Const_Iterator< EXT_ID, INT_ID, ACE_LOCK >
class ACE_Map_Reverse_Iterator< EXT_ID, INT_ID, ACE_LOCK >

Detailed Description

template<class EXT_ID, class INT_ID, class ACE_LOCK>
class ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >

Define a map abstraction that associates <EXT_ID>s with <INT_ID>s.

The <EXT_ID> must support <operator==>. This constraint can be alleviated via template specialization, as shown in the $ACE_ROOT/tests/Conn_Test.cpp test. This class uses an <ACE_Allocator> to allocate memory. The user can make this a persistant class by providing an <ACE_Allocator> with a persistable memory pool. This implementation of a map uses an array, which is searched linearly. For more efficient searching you should use the <ACE_Hash_Map_Manager>.

Definition at line 124 of file Map_Manager.h.


Member Typedef Documentation

template<class EXT_ID, class INT_ID, class ACE_LOCK>
typedef ACE_Map_Const_Iterator<EXT_ID, INT_ID, ACE_LOCK> ACE_Map_Manager::const_iterator
 

Definition at line 142 of file Map_Manager.h.

template<class EXT_ID, class INT_ID, class ACE_LOCK>
typedef ACE_Map_Const_Iterator<EXT_ID, INT_ID, ACE_LOCK> ACE_Map_Manager::CONST_ITERATOR
 

Definition at line 138 of file Map_Manager.h.

template<class EXT_ID, class INT_ID, class ACE_LOCK>
typedef ACE_Map_Entry<EXT_ID, INT_ID> ACE_Map_Manager::ENTRY
 

Reimplemented in ACE_Active_Map_Manager.

Definition at line 136 of file Map_Manager.h.

Referenced by resize_i.

template<class EXT_ID, class INT_ID, class ACE_LOCK>
typedef ACE_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK> ACE_Map_Manager::iterator
 

Reimplemented in ACE_Active_Map_Manager.

Definition at line 141 of file Map_Manager.h.

template<class EXT_ID, class INT_ID, class ACE_LOCK>
typedef ACE_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK> ACE_Map_Manager::ITERATOR
 

Reimplemented in ACE_Active_Map_Manager.

Definition at line 137 of file Map_Manager.h.

template<class EXT_ID, class INT_ID, class ACE_LOCK>
typedef EXT_ID ACE_Map_Manager::KEY
 

Definition at line 134 of file Map_Manager.h.

template<class EXT_ID, class INT_ID, class ACE_LOCK>
typedef ACE_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK> ACE_Map_Manager::reverse_iterator
 

Reimplemented in ACE_Active_Map_Manager.

Definition at line 143 of file Map_Manager.h.

template<class EXT_ID, class INT_ID, class ACE_LOCK>
typedef ACE_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK> ACE_Map_Manager::REVERSE_ITERATOR
 

Reimplemented in ACE_Active_Map_Manager.

Definition at line 139 of file Map_Manager.h.

template<class EXT_ID, class INT_ID, class ACE_LOCK>
typedef INT_ID ACE_Map_Manager::VALUE
 

Definition at line 135 of file Map_Manager.h.


Member Enumeration Documentation

template<class EXT_ID, class INT_ID, class ACE_LOCK>
anonymous enum [protected]
 

Enumeration values:
MAX_EXPONENTIAL  Grow map exponentially up to 64K.
LINEAR_INCREASE  Afterwards grow in chunks of 32K.

Definition at line 424 of file Map_Manager.h.

00425   {
00426     /// Grow map exponentially up to 64K
00427     MAX_EXPONENTIAL = 64 * 1024,
00428 
00429     /// Afterwards grow in chunks of 32K
00430     LINEAR_INCREASE = 32 * 1024
00431   };


Constructor & Destructor Documentation

template<class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_INLINE ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::ACE_Map_Manager ACE_Allocator   alloc = 0
 

Initialize a ACE_Map_Manager with the ACE_DEFAULT_MAP_SIZE.

Definition at line 49 of file Map_Manager.i.

References ACE_DEFAULT_MAP_SIZE, ACE_ERROR, ACE_LIB_TEXT, LM_ERROR, and open.

00050   : allocator_ (0),
00051     search_structure_ (0),
00052     total_size_ (0),
00053     cur_size_ (0)
00054 {
00055   if (this->open (ACE_DEFAULT_MAP_SIZE, alloc) == -1)
00056     ACE_ERROR ((LM_ERROR, ACE_LIB_TEXT ("ACE_Map_Manager\n")));
00057 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_INLINE ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::ACE_Map_Manager size_t    size,
ACE_Allocator   alloc = 0
 

Initialize a ACE_Map_Manager with size entries.

Definition at line 37 of file Map_Manager.i.

References ACE_ERROR, ACE_LIB_TEXT, LM_ERROR, and open.

00039   : allocator_ (0),
00040     search_structure_ (0),
00041     total_size_ (0),
00042     cur_size_ (0)
00043 {
00044   if (this->open (size, alloc) == -1)
00045     ACE_ERROR ((LM_ERROR, ACE_LIB_TEXT ("ACE_Map_Manager\n")));
00046 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_INLINE ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::~ACE_Map_Manager void   
 

Close down a ACE_Map_Manager and release dynamically allocated resources.

Definition at line 68 of file Map_Manager.i.

References close.

00069 {
00070   this->close ();
00071 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::ACE_Map_Manager const ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK > &    [private]
 


Member Function Documentation

template<class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_INLINE ACE_Map_Iterator< EXT_ID, INT_ID, ACE_LOCK > ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::begin void   
 

Return forward iterator.

Reimplemented in ACE_Active_Map_Manager.

Definition at line 241 of file Map_Manager.i.

00242 {
00243   return ACE_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK> (*this);
00244 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_INLINE int ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::bind const EXT_ID &    ext_id,
const INT_ID &    int_id
 

Associate ext_id with int_id. If ext_id is already in the map then the ACE_Map_Entry is not changed.

Return values:
0  If a new entry is bound successfully.
1  If an attempt is made to bind an existing entry.
-1  If failures occur.

Definition at line 74 of file Map_Manager.i.

References ACE_WRITE_GUARD_RETURN, and bind_i.

00076 {
00077   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00078 
00079   return this->bind_i (ext_id,
00080                        int_id);
00081 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
int ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::bind_i const EXT_ID &    ext_id,
const INT_ID &    int_id
[protected]
 

Performs the binding of <ext_id> to <int_id>. Must be called with locks held.

Definition at line 90 of file Map_Manager.cpp.

References find_and_return_index, and shared_bind.

Referenced by bind, and trybind_i.

00092 {
00093   // Try to find the key.
00094   ACE_UINT32 slot = 0;
00095   int result = this->find_and_return_index (ext_id,
00096                                             slot);
00097 
00098   if (result == 0)
00099     // We found the key. Nothing to change.
00100     return 1;
00101   else
00102     // We didn't find the key.
00103     return this->shared_bind (ext_id,
00104                               int_id);
00105 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_INLINE int ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::close void   
 

Close down a ACE_Map_Manager and release dynamically allocated resources.

Reimplemented in ACE_Active_Map_Manager.

Definition at line 60 of file Map_Manager.i.

References ACE_WRITE_GUARD_RETURN, and close_i.

Referenced by ~ACE_Map_Manager.

00061 {
00062   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00063 
00064   return this->close_i ();
00065 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
int ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::close_i void    [protected]
 

Close down a <Map_Manager>. Must be called with locks held.

Definition at line 69 of file Map_Manager.cpp.

References cur_size_, free_list_, free_search_structure, occupied_list_, and total_size_.

Referenced by close, and open.

00070 {
00071   // Free entries.
00072   this->free_search_structure ();
00073 
00074   // Reset sizes.
00075   this->total_size_ = 0;
00076   this->cur_size_ = 0;
00077 
00078   // Reset circular free list.
00079   this->free_list_.next (this->free_list_id ());
00080   this->free_list_.prev (this->free_list_id ());
00081 
00082   // Reset circular occupied list.
00083   this->occupied_list_.next (this->occupied_list_id ());
00084   this->occupied_list_.prev (this->occupied_list_id ());
00085 
00086   return 0;
00087 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_INLINE size_t ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::current_size void    const
 

Return the current size of the map.

Reimplemented in ACE_Active_Map_Manager.

Definition at line 178 of file Map_Manager.i.

References ACE_WRITE_GUARD_RETURN, and cur_size_.

Referenced by new_size.

00179 {
00180   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, ACE_const_cast (ACE_LOCK &, this->lock_), ACE_static_cast (size_t, -1));
00181   return this->cur_size_;
00182 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
void ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::dump void    const
 

Dump the state of an object.

Reimplemented in ACE_Active_Map_Manager.

Definition at line 616 of file Map_Manager.cpp.

References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, allocator_, ACE_Allocator::dump, LM_DEBUG, and lock_.

00617 {
00618   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00619   ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("total_size_ = %d"), this->total_size_));
00620   ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("\ncur_size_ = %d"), this->cur_size_));
00621   this->allocator_->dump ();
00622   this->lock_.dump ();
00623   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00624 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_INLINE ACE_Map_Iterator< EXT_ID, INT_ID, ACE_LOCK > ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::end void   
 

Reimplemented in ACE_Active_Map_Manager.

Definition at line 248 of file Map_Manager.i.

00249 {
00250   return ACE_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK> (*this, 1);
00251 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_INLINE int ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::equal const EXT_ID &    id1,
const EXT_ID &    id2
[protected]
 

Returns 1 if <id1> == <id2>, else 0. This is defined as a separate method to facilitate template specialization.

Definition at line 218 of file Map_Manager.i.

Referenced by find_and_return_index.

00220 {
00221   return id1 == id2;
00222 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_INLINE int ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::find const EXT_ID &    ext_id const
 

Returns 0 if the <ext_id> is in the mapping, otherwise -1.

Reimplemented in ACE_Active_Map_Manager.

Definition at line 130 of file Map_Manager.i.

References ACE_READ_GUARD_RETURN, find_and_return_index, and lock_.

00131 {
00132   ACE_Map_Manager<EXT_ID, INT_ID, ACE_LOCK> *nc_this =
00133     (ACE_Map_Manager<EXT_ID, INT_ID, ACE_LOCK> *) this;
00134   ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, nc_this->lock_, -1);
00135 
00136   ACE_UINT32 slot = 0;
00137   return nc_this->find_and_return_index (ext_id, slot);
00138 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_INLINE int ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::find const EXT_ID &    ext_id,
INT_ID &    int_id
const
 

Locate <ext_id> and pass out parameter via <int_id>.

Return values:
0  If found.
-1  If not found.

Reimplemented in ACE_Active_Map_Manager.

Definition at line 141 of file Map_Manager.i.

References ACE_READ_GUARD_RETURN, find_i, and lock_.

00143 {
00144   ACE_Map_Manager<EXT_ID, INT_ID, ACE_LOCK> *nc_this =
00145     (ACE_Map_Manager<EXT_ID, INT_ID, ACE_LOCK> *) this;
00146   ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, nc_this->lock_, -1);
00147 
00148   return nc_this->find_i (ext_id, int_id);
00149 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
int ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::find_and_return_index const EXT_ID &    ext_id,
ACE_UINT32 &    slot
[protected]
 

Performs a find using <ext_id> as the key. Must be called with locks held.

Definition at line 370 of file Map_Manager.cpp.

References equal, occupied_list_, occupied_list_id, and search_structure_.

Referenced by bind_i, find, find_i, rebind_i, trybind_i, and unbind_and_return_index.

00372 {
00373   // Go through the entire occupied list looking for the key.
00374   for (ACE_UINT32 i = this->occupied_list_.next ();
00375        i != this->occupied_list_id ();
00376        i = this->search_structure_[i].next ())
00377     {
00378 #if defined (ACE_HAS_LAZY_MAP_MANAGER)
00379       if (this->search_structure_[i].free_)
00380         continue;
00381 #endif /* ACE_HAS_LAZY_MAP_MANAGER */
00382 
00383       if (this->equal (this->search_structure_[i].ext_id_,
00384                        ext_id))
00385         {
00386           // If found, return slot.
00387           slot = i;
00388           return 0;
00389         }
00390     }
00391 
00392   // Key was not found.
00393   return -1;
00394 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
int ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::find_i const EXT_ID &    ext_id,
INT_ID &    int_id
[protected]
 

Performs a find of <int_id> using <ext_id> as the key. Must be called with locks held.

Definition at line 431 of file Map_Manager.cpp.

References find_and_return_index, and search_structure_.

Referenced by find.

00433 {
00434   // Try to find the key.
00435   ACE_UINT32 slot = 0;
00436   int result = this->find_and_return_index (ext_id,
00437                                             slot);
00438   if (result == 0)
00439     // Key was found.  Make a copy of value.
00440     int_id = this->search_structure_[slot].int_id_;
00441 
00442   return result;
00443 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_INLINE ACE_UINT32 ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::free_list_id void    const [protected]
 

Id of the free list sentinel.

Definition at line 225 of file Map_Manager.i.

Referenced by move_from_occupied_list_to_free_list, next_free, and resize_i.

00226 {
00227   // If you change ~0, please change
00228   // ACE_Active_Map_Manager_Key::ACE_Active_Map_Manager_Key()
00229   // accordingly.
00230   return (ACE_UINT32) ~0;
00231 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
void ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::free_search_structure void    [protected]
 

Explicitly call the destructors and free up the <search_structure_>.

Definition at line 580 of file Map_Manager.cpp.

References ACE_DES_FREE_TEMPLATE2, ACE_NOOP, allocator_, ACE_Allocator::free, search_structure_, and total_size_.

Referenced by close_i, and resize_i.

00581 {
00582   // Free up the structure.
00583   if (this->search_structure_ != 0)
00584     {
00585       for (ACE_UINT32 i = 0; i < this->total_size_; i++)
00586         // Explicitly call the destructor.
00587         {
00588           ENTRY *ss = &this->search_structure_[i];
00589           // The "if" second argument results in a no-op instead of
00590           // deallocation.
00591           ACE_DES_FREE_TEMPLATE2 (ss, ACE_NOOP,
00592                                   ACE_Map_Entry, EXT_ID, INT_ID);
00593         }
00594 
00595       // Actually free the memory.
00596       this->allocator_->free (this->search_structure_);
00597       this->search_structure_ = 0;
00598     }
00599 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_INLINE void ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::move_from_free_list_to_occupied_list ACE_UINT32    slot [protected]
 

Move from free list to occupied list.

Definition at line 198 of file Map_Manager.i.

References occupied_list_, occupied_list_id, and shared_move.

Referenced by shared_bind.

00199 {
00200   this->shared_move (slot,
00201                      this->free_list_,
00202                      this->free_list_id (),
00203                      this->occupied_list_,
00204                      this->occupied_list_id ());
00205 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_INLINE void ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::move_from_occupied_list_to_free_list ACE_UINT32    slot [protected]
 

Move from occupied list to free list.

Definition at line 208 of file Map_Manager.i.

References free_list_, free_list_id, and shared_move.

Referenced by unbind_slot.

00209 {
00210   this->shared_move (slot,
00211                      this->occupied_list_,
00212                      this->occupied_list_id (),
00213                      this->free_list_,
00214                      this->free_list_id ());
00215 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_INLINE ACE_LOCK & ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::mutex void   
 

Returns a reference to the underlying <ACE_LOCK>. This makes it possible to acquire the lock explicitly, which can be useful in some cases if you instantiate the <ACE_Atomic_Op> with an <ACE_Recursive_Mutex> or <ACE_Process_Mutex>, or if you need to guard the state of an iterator. NOTE: the right name would be <lock>, but HP/C++ will choke on that!

Definition at line 192 of file Map_Manager.i.

References lock_.

00193 {
00194   return this->lock_;
00195 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_UINT32 ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::new_size void    [protected]
 

This function returns the new size of the Map Manager. This function is called when we run out of room and need to resize.

Definition at line 563 of file Map_Manager.cpp.

References current_size, LINEAR_INCREASE, MAX_EXPONENTIAL, and total_size_.

Referenced by resize_i.

00564 {
00565   // Calculate the new size.
00566   ACE_UINT32 current_size = this->total_size_;
00567 
00568   if (current_size < MAX_EXPONENTIAL)
00569     // Exponentially increase if we haven't reached MAX_EXPONENTIAL.
00570     current_size *= 2;
00571   else
00572     // Linear increase if we have reached MAX_EXPONENTIAL.
00573     current_size += LINEAR_INCREASE;
00574 
00575   // This should be the new size.
00576   return current_size;
00577 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
int ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::next_free ACE_UINT32 &    slot [protected]
 

Finds the next free slot.

Definition at line 108 of file Map_Manager.cpp.

References free_list_, free_list_id, and resize_i.

Referenced by shared_bind.

00109 {
00110   // Look in the free list for an empty slot.
00111   free_slot = this->free_list_.next ();
00112 
00113   // If we do find a free slot, return successfully.
00114   if (free_slot != this->free_list_id ())
00115     return 0;
00116 
00117 #if defined (ACE_HAS_LAZY_MAP_MANAGER)
00118 
00119   // Move any free slots from occupied list to free list.
00120   this->move_all_free_slots_from_occupied_list ();
00121 
00122   // Try again in case we found any free slots in the occupied list.
00123   free_slot = this->free_list_.next ();
00124 
00125   // If we do find a free slot, return successfully.
00126   if (free_slot != this->free_list_id ())
00127     return 0;
00128 
00129 #endif /* ACE_HAS_LAZY_MAP_MANAGER */
00130 
00131   // Resize the map.
00132   int result = this->resize_i (this->new_size ());
00133 
00134   // Check for errors.
00135   if (result == 0)
00136     // New free slot.
00137     free_slot = this->free_list_.next ();
00138 
00139   return result;
00140 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_INLINE ACE_UINT32 ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::occupied_list_id void    const [protected]
 

Id of the occupied list sentinel.

Definition at line 234 of file Map_Manager.i.

Referenced by find_and_return_index, move_from_free_list_to_occupied_list, resize_i, and unbind_all.

00235 {
00236   return (ACE_UINT32) ~1;
00237 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
int ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::open size_t    length = ACE_DEFAULT_MAP_SIZE,
ACE_Allocator   alloc = 0
 

Initialize a ACE_Map_Manager with size length.

Reimplemented in ACE_Active_Map_Manager.

Definition at line 36 of file Map_Manager.cpp.

References ACE_ASSERT, ACE_UINT32_MAX, ACE_WRITE_GUARD_RETURN, allocator_, close_i, ACE_Allocator::instance, and resize_i.

Referenced by ACE_Map_Manager.

00038 {
00039   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00040 
00041   // Close old map (if any).
00042   this->close_i ();
00043 
00044   // Use the user specified allocator or the default singleton one.
00045   if (alloc == 0)
00046     alloc = ACE_Allocator::instance ();
00047 
00048   this->allocator_ = alloc;
00049 
00050   // This assertion is here to help track a situation that shouldn't
00051   // happen.
00052   ACE_ASSERT (size != 0);
00053 
00054   // Active_Map_Manager depends on the <slot_index_> being of fixed
00055   // size. It cannot be size_t because size_t is 64-bits on 64-bit
00056   // platform and 32-bits on 32-bit platforms. Size of the <slot_index_>
00057   // has to be consistent across platforms. ACE_UIN32 is chosen as
00058   // ACE_UIN32_MAX is big enough. The assert is to ensure that the user
00059   // doesn't open the ACE_Map_Manager with a bigger size than we can
00060   // handle.
00061   ACE_ASSERT (size <= ACE_UINT32_MAX);
00062 
00063   // Resize from 0 to <size>.  Note that this will also set up the
00064   // circular free list.
00065   return this->resize_i ((ACE_UINT32) size);
00066 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
void ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::operator= const ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK > &    [private]
 

template<class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_INLINE ACE_Map_Reverse_Iterator< EXT_ID, INT_ID, ACE_LOCK > ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::rbegin void   
 

Return reverse iterator.

Reimplemented in ACE_Active_Map_Manager.

Definition at line 255 of file Map_Manager.i.

00256 {
00257   return ACE_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK> (*this);
00258 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_INLINE int ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::rebind const EXT_ID &    ext_id,
const INT_ID &    int_id
 

Reassociate ext_id with int_id. Old values in the map are ignored.

Reimplemented in ACE_Active_Map_Manager.

Definition at line 110 of file Map_Manager.i.

References ACE_WRITE_GUARD_RETURN, and rebind_i.

00112 {
00113   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00114 
00115   return this->rebind_i (ext_id,
00116                          int_id);
00117 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_INLINE int ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::rebind const EXT_ID &    ext_id,
const INT_ID &    int_id,
INT_ID &    old_int_id
 

Reassociate ext_id with int_id. If <ext_id> is not in the map then behaves just like <bind>. Otherwise, store the old values of <int_id> into the "out" parameter and rebind the new parameters.

Return values:
0  If a new entry is bound successfully.
1  If an existing entry was rebound.
-1  If failures occur.

Reimplemented in ACE_Active_Map_Manager.

Definition at line 98 of file Map_Manager.i.

References ACE_WRITE_GUARD_RETURN, and rebind_i.

00101 {
00102   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00103 
00104   return this->rebind_i (ext_id,
00105                          int_id,
00106                          old_int_id);
00107 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_INLINE int ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::rebind const EXT_ID &    ext_id,
const INT_ID &    int_id,
EXT_ID &    old_ext_id,
INT_ID &    old_int_id
 

Reassociate ext_id with int_id. If ext_id is not in the map then behaves just like bind(). Otherwise, store the old values of <ext_id> and <int_id> into the "out" parameters and rebind the new parameters. This is very useful if you need to have an atomic way of updating <Map_Entries> and you also need full control over memory allocation.

Return values:
0  If a new entry is bound successfully.
1  If an existing entry was rebound.
-1  If failures occur.

Reimplemented in ACE_Active_Map_Manager.

Definition at line 84 of file Map_Manager.i.

References ACE_WRITE_GUARD_RETURN, and rebind_i.

00088 {
00089   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00090 
00091   return this->rebind_i (ext_id,
00092                          int_id,
00093                          old_ext_id,
00094                          old_int_id);
00095 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
int ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::rebind_i const EXT_ID &    ext_id,
const INT_ID &    int_id
[protected]
 

Performs a rebinding of <ext_it> to <int_id>. Must be called with locks held.

Definition at line 323 of file Map_Manager.cpp.

References allocator_, ACE_Map_Entry::ext_id_, find_and_return_index, ACE_Map_Entry::int_id_, search_structure_, shared_bind, and ACE_Allocator::sync.

00325 {
00326   // First try to find the key.
00327   ACE_UINT32 slot = 0;
00328   int result = this->find_and_return_index (ext_id,
00329                                             slot);
00330   if (result == 0)
00331     {
00332       // We found it, so rebind current entries.
00333       ENTRY &ss = this->search_structure_[slot];
00334       ss.ext_id_ = ext_id;
00335       ss.int_id_ = int_id;
00336 
00337       // Sync changed entry.
00338       this->allocator_->sync (&ss, sizeof ss);
00339 
00340       return 1;
00341     }
00342   else
00343     // We didn't find it, so let's add it.
00344     return this->shared_bind (ext_id,
00345                               int_id);
00346 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
int ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::rebind_i const EXT_ID &    ext_id,
const INT_ID &    int_id,
INT_ID &    old_int_id
[protected]
 

Performs a rebinding of <ext_it> to <int_id>. Also, recovers old values. Must be called with locks held.

Definition at line 294 of file Map_Manager.cpp.

References allocator_, ACE_Map_Entry::ext_id_, find_and_return_index, ACE_Map_Entry::int_id_, search_structure_, shared_bind, and ACE_Allocator::sync.

00297 {
00298   // First try to find the key.
00299   ACE_UINT32 slot = 0;
00300   int result = this->find_and_return_index (ext_id,
00301                                             slot);
00302   if (result == 0)
00303     {
00304       // We found it, so make copies of the old entries and rebind
00305       // current entries.
00306       ENTRY &ss = this->search_structure_[slot];
00307       old_int_id = ss.int_id_;
00308       ss.ext_id_ = ext_id;
00309       ss.int_id_ = int_id;
00310 
00311       // Sync changed entry.
00312       this->allocator_->sync (&ss, sizeof ss);
00313 
00314       return 1;
00315     }
00316   else
00317     // We didn't find it, so let's add it.
00318     return this->shared_bind (ext_id,
00319                               int_id);
00320 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
int ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::rebind_i const EXT_ID &    ext_id,
const INT_ID &    int_id,
EXT_ID &    old_ext_id,
INT_ID &    old_int_id
[protected]
 

Performs a rebinding of <ext_it> to <int_id>. Also, recovers old values. Must be called with locks held.

Definition at line 263 of file Map_Manager.cpp.

References allocator_, ACE_Map_Entry::ext_id_, find_and_return_index, ACE_Map_Entry::int_id_, search_structure_, shared_bind, and ACE_Allocator::sync.

Referenced by rebind.

00267 {
00268   // First try to find the key.
00269   ACE_UINT32 slot = 0;
00270   int result = this->find_and_return_index (ext_id,
00271                                             slot);
00272   if (result == 0)
00273     {
00274       // We found it, so make copies of the old entries and rebind
00275       // current entries.
00276       ENTRY &ss = this->search_structure_[slot];
00277       old_ext_id = ss.ext_id_;
00278       old_int_id = ss.int_id_;
00279       ss.ext_id_ = ext_id;
00280       ss.int_id_ = int_id;
00281 
00282       // Sync changed entry.
00283       this->allocator_->sync (&ss, sizeof ss);
00284 
00285       return 1;
00286     }
00287   else
00288     // We didn't find it, so let's add it.
00289     return this->shared_bind (ext_id,
00290                               int_id);
00291 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_INLINE ACE_Map_Reverse_Iterator< EXT_ID, INT_ID, ACE_LOCK > ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::rend void   
 

Reimplemented in ACE_Active_Map_Manager.

Definition at line 262 of file Map_Manager.i.

00263 {
00264   return ACE_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK> (*this, 1);
00265 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
int ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::resize_i ACE_UINT32    size [protected]
 

Resize the map. Must be called with locks held.

Definition at line 500 of file Map_Manager.cpp.

References ACE_ALLOCATOR_RETURN, ENTRY, free_list_, free_list_id, free_search_structure, new_size, ACE_Map_Entry::next, occupied_list_, occupied_list_id, ACE_Map_Entry::prev, search_structure_, and total_size_.

Referenced by next_free, and open.

00501 {
00502   ACE_UINT32 i;
00503   ENTRY *temp = 0;
00504 
00505   // Allocate new memory.
00506   ACE_ALLOCATOR_RETURN (temp,
00507                         (ENTRY *) this->allocator_->malloc (new_size * sizeof (ENTRY)),
00508                         -1);
00509 
00510   // Copy over the occupied entires.
00511   for (i = this->occupied_list_.next ();
00512        i != this->occupied_list_id ();
00513        i = this->search_structure_[i].next ())
00514     // Call the copy constructor using operator placement new.
00515     new (&(temp[i])) ENTRY (this->search_structure_[i]);
00516 
00517   // Copy over the free entires.
00518   for (i = this->free_list_.next ();
00519        i != this->free_list_id ();
00520        i = this->search_structure_[i].next ())
00521     // Call the copy constructor using operator placement new.
00522     new (&(temp[i])) ENTRY (this->search_structure_[i]);
00523 
00524   // Construct the new elements.
00525   for (i = this->total_size_; i < new_size; i++)
00526     {
00527       // Call the constructor for each element in the array using
00528       // operator placement new.  Note that this requires a default
00529       // constructor for <EXT_ID> and <INT_ID>.
00530       new (&(temp[i])) ENTRY;
00531       temp[i].next (i + 1);
00532       temp[i].prev (i - 1);
00533 
00534 #if defined (ACE_HAS_LAZY_MAP_MANAGER)
00535 
00536       // Even though this slot is initially free, we need the <free_>
00537       // flag to be zero so that we don't have to set it when the slot
00538       // is moved to the occupied list.  In addition, this flag has no
00539       // meaning while this slot is in the free list.
00540       temp[i].free_ = 0;
00541 
00542 #endif /* ACE_HAS_LAZY_MAP_MANAGER */
00543 
00544     }
00545 
00546   // Add new entries to the free list.
00547   this->free_list_.next (this->total_size_);
00548   this->free_list_.prev (new_size - 1);
00549   temp[new_size - 1].next (this->free_list_id ());
00550   temp[this->total_size_].prev (this->free_list_id ());
00551 
00552   // Remove/free old elements, update the new totoal size.
00553   this->free_search_structure ();
00554   this->total_size_ = new_size;
00555 
00556   // Start using new elements.
00557   this->search_structure_ = temp;
00558 
00559   return 0;
00560 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
int ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::shared_bind const EXT_ID &    ext_id,
const INT_ID &    int_id
[protected]
 

Bind an entry (without finding first). Must be called with locks held.

Definition at line 236 of file Map_Manager.cpp.

References cur_size_, move_from_free_list_to_occupied_list, next_free, and search_structure_.

Referenced by bind_i, and rebind_i.

00238 {
00239   // This function assumes that the find() has already been done, and
00240   // therefore, simply adds to the map.
00241 
00242   // Find an empty slot.
00243   ACE_UINT32 slot = 0;
00244   int result = this->next_free (slot);
00245 
00246   if (result == 0)
00247     {
00248       // Copy key and value.
00249       this->search_structure_[slot].int_id_ = int_id;
00250       this->search_structure_[slot].ext_id_ = ext_id;
00251 
00252       // Move from free list to occupied list
00253       this->move_from_free_list_to_occupied_list (slot);
00254 
00255       // Update the current size.
00256       ++this->cur_size_;
00257     }
00258 
00259   return result;
00260 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
void ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::shared_move ACE_UINT32    slot,
ACE_Map_Entry< EXT_ID, INT_ID > &    current_list,
ACE_UINT32    current_list_id,
ACE_Map_Entry< EXT_ID, INT_ID > &    new_list,
ACE_UINT32    new_list_id
[protected]
 

Move helper.

Definition at line 191 of file Map_Manager.cpp.

References ACE_Map_Entry::next, ACE_Map_Entry::prev, and search_structure_.

Referenced by move_from_free_list_to_occupied_list, and move_from_occupied_list_to_free_list.

00196 {
00197   // Grab the entry.
00198   ENTRY &entry = this->search_structure_[slot];
00199 
00200   // Remove from current list.
00201 
00202   // Fix the entry before us.
00203   ACE_UINT32 current_list_prev = entry.prev ();
00204 
00205   if (current_list_prev == current_list_id)
00206     current_list.next (entry.next ());
00207   else
00208     this->search_structure_[current_list_prev].next (entry.next ());
00209 
00210   // Fix the entry after us.
00211   ACE_UINT32 current_list_next = entry.next ();
00212 
00213   if (current_list_next == current_list_id)
00214     current_list.prev (entry.prev ());
00215   else
00216     this->search_structure_[current_list_next].prev (entry.prev ());
00217 
00218   // Add to new list.
00219 
00220   // Fix us.
00221   ACE_UINT32 new_list_next = new_list.next ();
00222   entry.next (new_list_next);
00223   entry.prev (new_list_id);
00224 
00225   // Fix entry before us.
00226   new_list.next (slot);
00227 
00228   // Fix entry after us.
00229   if (new_list_next == new_list_id)
00230     new_list.prev (slot);
00231   else
00232     this->search_structure_[new_list_next].prev (slot);
00233 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_INLINE size_t ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::total_size void    const
 

Return the total size of the map.

Reimplemented in ACE_Active_Map_Manager.

Definition at line 185 of file Map_Manager.i.

References ACE_WRITE_GUARD_RETURN, and total_size_.

00186 {
00187   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, ACE_const_cast (ACE_LOCK &, this->lock_), ACE_static_cast (size_t, -1));
00188   return this->total_size_;
00189 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_INLINE int ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::trybind const EXT_ID &    ext_id,
INT_ID &    int_id
 

Associate <ext_id> with <int_id> if and only if <ext_id> is not in the map. If <ext_id> is already in the map then the <int_id> parameter is overwritten with the existing value in the map

Return values:
0  If a new entry is bound successfully.
1  If an attempt is made to bind an existing entry.
-1  If failures occur.

Definition at line 120 of file Map_Manager.i.

References ACE_WRITE_GUARD_RETURN, and trybind_i.

00122 {
00123   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00124 
00125   return this->trybind_i (ext_id,
00126                           int_id);
00127 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
int ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::trybind_i const EXT_ID &    ext_id,
INT_ID &    int_id
[protected]
 

Performs a conditional bind of <int_id> using <ext_id> as the key. Must be called with locks held.

Definition at line 349 of file Map_Manager.cpp.

References bind_i, find_and_return_index, and search_structure_.

Referenced by trybind.

00351 {
00352   // Try to find the key.
00353   ACE_UINT32 slot = 0;
00354   int result = this->find_and_return_index (ext_id,
00355                                             slot);
00356   if (result == 0)
00357     {
00358       // Key was found.  Make a copy of value, but *don't* update
00359       // anything in the map!
00360       int_id = this->search_structure_[slot].int_id_;
00361       return 1;
00362     }
00363   else
00364     // We didn't find it, so let's bind it!
00365     return this->bind_i (ext_id,
00366                          int_id);
00367 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_INLINE int ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::unbind const EXT_ID &    ext_id,
INT_ID &    int_id
 

Break any association of <ext_id>. Returns the value of <int_id> in case the caller needs to deallocate memory. Returns 0 if successful, else -1.

Reimplemented in ACE_Active_Map_Manager.

Definition at line 161 of file Map_Manager.i.

References ACE_WRITE_GUARD_RETURN, and unbind_i.

00163 {
00164   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00165 
00166   return this->unbind_i (ext_id,
00167                          int_id);
00168 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_INLINE int ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::unbind const EXT_ID &    ext_id
 

Unbind (remove) the <ext_id> from the map. Don't return the <int_id> to the caller (this is useful for collections where the <int_id>s are *not* dynamically allocated...) Returns 0 if successful, else -1.

Reimplemented in ACE_Active_Map_Manager.

Definition at line 171 of file Map_Manager.i.

References ACE_WRITE_GUARD_RETURN, and unbind_i.

00172 {
00173   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00174   return this->unbind_i (ext_id);
00175 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
void ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::unbind_all void   
 

Unbind all entires.

Definition at line 397 of file Map_Manager.cpp.

References ACE_Map_Entry::next, occupied_list_, occupied_list_id, search_structure_, and unbind_slot.

00398 {
00399   // Go through the entire occupied list.
00400   for (ACE_UINT32 i = this->occupied_list_.next ();
00401        i != this->occupied_list_id ();
00402        )
00403     {
00404       //
00405       // Note the trick used here: Information about the current slot
00406       // is first noted; <i> then moves to the next occupied slot;
00407       // only after this is the slot (potentially) moved from the
00408       // occupied list to the free list.  This order of things, i.e.,
00409       // moving <i> before moving the free slot is necessary,
00410       // otherwise we'll forget which our next occupied slot is.
00411       //
00412 
00413       // Note information about current slot.
00414       ACE_Map_Entry<EXT_ID, INT_ID> &current_slot =
00415         this->search_structure_[i];
00416       ACE_UINT32 position_of_current_slot = i;
00417 
00418       // Move <i> to next occupied slot.
00419       i = current_slot.next ();
00420 
00421 #if defined (ACE_HAS_LAZY_MAP_MANAGER)
00422       if (current_slot.free_)
00423         continue;
00424 #endif /* ACE_HAS_LAZY_MAP_MANAGER */
00425 
00426       this->unbind_slot (position_of_current_slot);
00427     }
00428 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
int ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::unbind_and_return_index const EXT_ID &    ext_id,
ACE_UINT32 &    slot
[protected]
 

Performs an unbind using <ext_id> as the key. Must be called with locks held.

Definition at line 446 of file Map_Manager.cpp.

References find_and_return_index, and unbind_slot.

Referenced by unbind_i.

00448 {
00449   // Try to find the key.
00450   int result = this->find_and_return_index (ext_id,
00451                                             slot);
00452 
00453   if (result == 0)
00454     this->unbind_slot (slot);
00455 
00456   return result;
00457 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_INLINE int ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::unbind_i const EXT_ID &    ext_id [protected]
 

Performs an unbind using <ext_id> as the key. Must be called with locks held.

Definition at line 152 of file Map_Manager.i.

References unbind_and_return_index.

00153 {
00154   // Unbind the entry.
00155   ACE_UINT32 slot = 0;
00156   return this->unbind_and_return_index (ext_id,
00157                                         slot);
00158 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
int ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::unbind_i const EXT_ID &    ext_id,
INT_ID &    int_id
[protected]
 

Performs an unbind of <int_id> using <ext_id> as the key. Must be called with locks held.

Definition at line 485 of file Map_Manager.cpp.

References search_structure_, and unbind_and_return_index.

Referenced by unbind.

00487 {
00488   // Unbind the entry.
00489   ACE_UINT32 slot = 0;
00490   int result = this->unbind_and_return_index (ext_id,
00491                                               slot);
00492   if (result == 0)
00493     // If found, copy the value.
00494     int_id = this->search_structure_[slot].int_id_;
00495 
00496   return result;
00497 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
void ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::unbind_slot ACE_UINT32    slot [protected]
 

Unbind <slot>.

Definition at line 460 of file Map_Manager.cpp.

References cur_size_, move_from_occupied_list_to_free_list, and search_structure_.

Referenced by unbind_all, and unbind_and_return_index.

00461 {
00462 
00463 #if defined (ACE_HAS_LAZY_MAP_MANAGER)
00464 
00465   //
00466   // In the case of lazy map managers, the movement of free slots
00467   // from the occupied list to the free list is delayed until we
00468   // run out of free slots in the free list.
00469   //
00470 
00471   this->search_structure_[slot].free_ = 1;
00472 
00473 #else
00474 
00475   // Move from occupied list to free list.
00476   this->move_from_occupied_list_to_free_list (slot);
00477 
00478 #endif /* ACE_HAS_LAZY_MAP_MANAGER */
00479 
00480   // Update the current size.
00481   --this->cur_size_;
00482 }


Friends And Related Function Documentation

template<class EXT_ID, class INT_ID, class ACE_LOCK>
friend class ACE_Map_Const_Iterator< EXT_ID, INT_ID, ACE_LOCK > [friend]
 

Definition at line 130 of file Map_Manager.h.

template<class EXT_ID, class INT_ID, class ACE_LOCK>
friend class ACE_Map_Const_Iterator_Base< EXT_ID, INT_ID, ACE_LOCK > [friend]
 

Definition at line 128 of file Map_Manager.h.

template<class EXT_ID, class INT_ID, class ACE_LOCK>
friend class ACE_Map_Iterator< EXT_ID, INT_ID, ACE_LOCK > [friend]
 

Definition at line 129 of file Map_Manager.h.

template<class EXT_ID, class INT_ID, class ACE_LOCK>
friend class ACE_Map_Iterator_Base< EXT_ID, INT_ID, ACE_LOCK > [friend]
 

Definition at line 127 of file Map_Manager.h.

template<class EXT_ID, class INT_ID, class ACE_LOCK>
friend class ACE_Map_Reverse_Iterator< EXT_ID, INT_ID, ACE_LOCK > [friend]
 

Definition at line 131 of file Map_Manager.h.


Member Data Documentation

template<class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_Map_Manager::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Reimplemented in ACE_Active_Map_Manager.

Definition at line 282 of file Map_Manager.h.

template<class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_Allocator* ACE_Map_Manager::allocator_ [protected]
 

Pointer to a memory allocator.

Definition at line 404 of file Map_Manager.h.

Referenced by dump, free_search_structure, open, and rebind_i.

template<class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_UINT32 ACE_Map_Manager::cur_size_ [protected]
 

Current size of the map.

Definition at line 416 of file Map_Manager.h.

Referenced by close_i, current_size, shared_bind, and unbind_slot.

template<class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_Map_Entry<EXT_ID, INT_ID> ACE_Map_Manager::free_list_ [protected]
 

Free list.

Definition at line 419 of file Map_Manager.h.

Referenced by close_i, move_from_occupied_list_to_free_list, next_free, and resize_i.

template<class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_LOCK ACE_Map_Manager::lock_ [protected]
 

Synchronization variable for the MT_SAFE <ACE_Map_Manager>.

Definition at line 407 of file Map_Manager.h.

Referenced by dump, find, and mutex.

template<class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_Map_Entry<EXT_ID, INT_ID> ACE_Map_Manager::occupied_list_ [protected]
 

Occupied list.

Definition at line 422 of file Map_Manager.h.

Referenced by close_i, find_and_return_index, move_from_free_list_to_occupied_list, resize_i, and unbind_all.

template<class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_Map_Entry<EXT_ID, INT_ID>* ACE_Map_Manager::search_structure_ [protected]
 

Implement the Map as a resizeable array of <ACE_Map_Entry>.

Definition at line 410 of file Map_Manager.h.

Referenced by find_and_return_index, find_i, free_search_structure, rebind_i, resize_i, shared_bind, shared_move, trybind_i, unbind_all, unbind_i, and unbind_slot.

template<class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_UINT32 ACE_Map_Manager::total_size_ [protected]
 

Total number of elements in this->search_structure_.

Definition at line 413 of file Map_Manager.h.

Referenced by close_i, free_search_structure, new_size, resize_i, and total_size.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:50:07 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002