ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK > Class Template Reference

Define a map abstraction that associates s with s. More...

#include <Map_Manager.h>

Collaboration diagram for ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >:

Collaboration graph
[legend]
List of all members.

Public Types

typedef EXT_ID KEY
typedef INT_ID VALUE
typedef ACE_LOCK lock_type
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 Member Functions

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

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

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

int close (void)
 ~ACE_Map_Manager (void)
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)
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 is in the mapping, otherwise -1.

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.

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

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

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

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.

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

Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.


Protected Types

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

Protected Member Functions

int bind_i (const EXT_ID &ext_id, const INT_ID &int_id)
int shared_bind (const EXT_ID &ext_id, const INT_ID &int_id)
int rebind_i (const EXT_ID &ext_id, const INT_ID &int_id, EXT_ID &old_ext_id, INT_ID &old_int_id)
int rebind_i (const EXT_ID &ext_id, const INT_ID &int_id, INT_ID &old_int_id)
int rebind_i (const EXT_ID &ext_id, const INT_ID &int_id)
int trybind_i (const EXT_ID &ext_id, INT_ID &int_id)
int find_i (const EXT_ID &ext_id, INT_ID &int_id)
int find_and_return_index (const EXT_ID &ext_id, ACE_UINT32 &slot)
int unbind_i (const EXT_ID &ext_id, INT_ID &int_id)
int unbind_i (const EXT_ID &ext_id)
int unbind_and_return_index (const EXT_ID &ext_id, ACE_UINT32 &slot)
void unbind_slot (ACE_UINT32 slot)
 Unbind .

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

int close_i (void)
 Close down a . Must be called with locks held.

int equal (const EXT_ID &id1, const EXT_ID &id2)
ACE_UINT32 new_size (void)
void free_search_structure (void)
ACE_UINT32 free_list_id (void) const
 Id of the free list sentinel.

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

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

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

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

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.


Protected Attributes

ACE_Allocatorallocator_
 Pointer to a memory allocator.

ACE_LOCK lock_
 Synchronization variable for the MT_SAFE .

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

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

ACE_UINT32 cur_size_
 Current size of the map.

ACE_Map_Entry< EXT_ID, INT_ID > free_list_
 Free list.

ACE_Map_Entry< EXT_ID, INT_ID > occupied_list_
 Occupied list.


Private Member Functions

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 s with s.

The 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 .

Definition at line 127 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< EXT_ID, INT_ID, ACE_LOCK >::const_iterator
 

Definition at line 146 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< EXT_ID, INT_ID, ACE_LOCK >::CONST_ITERATOR
 

Definition at line 142 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< EXT_ID, INT_ID, ACE_LOCK >::ENTRY
 

Reimplemented in ACE_Active_Map_Manager< T >, and ACE_Active_Map_Manager< ACE_Pair< KEY, VALUE > >.

Definition at line 140 of file Map_Manager.h.

Referenced by ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::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< EXT_ID, INT_ID, ACE_LOCK >::iterator
 

Reimplemented in ACE_Active_Map_Manager< T >, and ACE_Active_Map_Manager< ACE_Pair< KEY, VALUE > >.

Definition at line 145 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< EXT_ID, INT_ID, ACE_LOCK >::ITERATOR
 

Reimplemented in ACE_Active_Map_Manager< T >, and ACE_Active_Map_Manager< ACE_Pair< KEY, VALUE > >.

Definition at line 141 of file Map_Manager.h.

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

Definition at line 137 of file Map_Manager.h.

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

Definition at line 139 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< EXT_ID, INT_ID, ACE_LOCK >::reverse_iterator
 

Reimplemented in ACE_Active_Map_Manager< T >, and ACE_Active_Map_Manager< ACE_Pair< KEY, VALUE > >.

Definition at line 147 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< EXT_ID, INT_ID, ACE_LOCK >::REVERSE_ITERATOR
 

Reimplemented in ACE_Active_Map_Manager< T >, and ACE_Active_Map_Manager< ACE_Pair< KEY, VALUE > >.

Definition at line 143 of file Map_Manager.h.

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

Definition at line 138 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 428 of file Map_Manager.h.

00429   {
00430     /// Grow map exponentially up to 64K
00431     MAX_EXPONENTIAL = 64 * 1024,
00432 
00433     /// Afterwards grow in chunks of 32K
00434     LINEAR_INCREASE = 32 * 1024
00435   };


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 55 of file Map_Manager.inl.

References ACE_DEFAULT_MAP_SIZE, ACE_ERROR, ACE_LIB_TEXT, LM_ERROR, and ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::open().

00056   : allocator_ (0),
00057     search_structure_ (0),
00058     total_size_ (0),
00059     cur_size_ (0)
00060 {
00061   if (this->open (ACE_DEFAULT_MAP_SIZE, alloc) == -1)
00062     ACE_ERROR ((LM_ERROR, ACE_LIB_TEXT ("ACE_Map_Manager\n")));
00063 }

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 43 of file Map_Manager.inl.

References ACE_ERROR, ACE_LIB_TEXT, LM_ERROR, and ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::open().

00045   : allocator_ (0),
00046     search_structure_ (0),
00047     total_size_ (0),
00048     cur_size_ (0)
00049 {
00050   if (this->open (size, alloc) == -1)
00051     ACE_ERROR ((LM_ERROR, ACE_LIB_TEXT ("ACE_Map_Manager\n")));
00052 }

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 74 of file Map_Manager.inl.

References ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::close().

00075 {
00076   this->close ();
00077 }

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< T >, and ACE_Active_Map_Manager< ACE_Pair< KEY, VALUE > >.

Definition at line 247 of file Map_Manager.inl.

Referenced by ACE_QtReactor::~ACE_QtReactor().

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

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 80 of file Map_Manager.inl.

References ACE_WRITE_GUARD_RETURN, and ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::bind_i().

Referenced by ACE_QtReactor::create_notifiers_for_handle(), ACE_Token_Invariant_Manager::get_mutex(), ACE_Token_Invariant_Manager::get_rwlock(), and ACE_Token_Collection::insert().

00082 {
00083   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00084 
00085   return this->bind_i (ext_id,
00086                        int_id);
00087 }

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 to . Must be called with locks held.

Definition at line 83 of file Map_Manager.cpp.

References ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::find_and_return_index(), and ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::shared_bind().

Referenced by ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::bind(), and ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::trybind_i().

00085 {
00086   // Try to find the key.
00087   ACE_UINT32 slot = 0;
00088   int result = this->find_and_return_index (ext_id,
00089                                             slot);
00090 
00091   if (result == 0)
00092     // We found the key. Nothing to change.
00093     return 1;
00094   else
00095     // We didn't find the key.
00096     return this->shared_bind (ext_id,
00097                               int_id);
00098 }

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< T >, and ACE_Active_Map_Manager< ACE_Pair< KEY, VALUE > >.

Definition at line 66 of file Map_Manager.inl.

References ACE_WRITE_GUARD_RETURN, and ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::close_i().

Referenced by ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::~ACE_Map_Manager().

00067 {
00068   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00069 
00070   return this->close_i ();
00071 }

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 . Must be called with locks held.

Definition at line 62 of file Map_Manager.cpp.

References ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::free_search_structure(), and ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::occupied_list_.

Referenced by ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::close(), and ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::open().

00063 {
00064   // Free entries.
00065   this->free_search_structure ();
00066 
00067   // Reset sizes.
00068   this->total_size_ = 0;
00069   this->cur_size_ = 0;
00070 
00071   // Reset circular free list.
00072   this->free_list_.next (this->free_list_id ());
00073   this->free_list_.prev (this->free_list_id ());
00074 
00075   // Reset circular occupied list.
00076   this->occupied_list_.next (this->occupied_list_id ());
00077   this->occupied_list_.prev (this->occupied_list_id ());
00078 
00079   return 0;
00080 }

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< T >, and ACE_Active_Map_Manager< ACE_Pair< KEY, VALUE > >.

Definition at line 184 of file Map_Manager.inl.

References ACE_WRITE_GUARD_RETURN.

00185 {
00186   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, static_cast<size_t> (-1));
00187   return this->cur_size_;
00188 }

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< T >, and ACE_Active_Map_Manager< ACE_Pair< KEY, VALUE > >.

Definition at line 611 of file Map_Manager.cpp.

References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, ACE_Allocator::dump(), and LM_DEBUG.

Referenced by ACE_Token_Invariant_Manager::dump(), and ACE_Token_Collection::dump().

00612 {
00613 #if defined (ACE_HAS_DUMP)
00614   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00615   ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("total_size_ = %d"), this->total_size_));
00616   ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("\ncur_size_ = %d"), this->cur_size_));
00617   this->allocator_->dump ();
00618   this->lock_.dump ();
00619   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00620 #endif /* ACE_HAS_DUMP */
00621 }

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< T >, and ACE_Active_Map_Manager< ACE_Pair< KEY, VALUE > >.

Definition at line 254 of file Map_Manager.inl.

Referenced by ACE_QtReactor::~ACE_QtReactor().

00255 {
00256   return ACE_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK> (*this, 1);
00257 }

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 == , else 0. This is defined as a separate method to facilitate template specialization.

Definition at line 224 of file Map_Manager.inl.

Referenced by ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::find_and_return_index().

00226 {
00227   return id1 == id2;
00228 }

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 is in the mapping, otherwise -1.

Reimplemented in ACE_Active_Map_Manager< T >, and ACE_Active_Map_Manager< ACE_Pair< KEY, VALUE > >.

Definition at line 136 of file Map_Manager.inl.

References ACE_READ_GUARD_RETURN, ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::find_and_return_index(), and ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::lock_.

00137 {
00138   ACE_Map_Manager<EXT_ID, INT_ID, ACE_LOCK> *nc_this =
00139     (ACE_Map_Manager<EXT_ID, INT_ID, ACE_LOCK> *) this;
00140   ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, nc_this->lock_, -1);
00141 
00142   ACE_UINT32 slot = 0;
00143   return nc_this->find_and_return_index (ext_id, slot);
00144 }

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 and pass out parameter via .

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

Reimplemented in ACE_Active_Map_Manager< T >, and ACE_Active_Map_Manager< ACE_Pair< KEY, VALUE > >.

Definition at line 147 of file Map_Manager.inl.

References ACE_READ_GUARD_RETURN, ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::find_i(), and ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::lock_.

Referenced by ACE_Token_Collection::acquire(), ACE_QtReactor::create_notifiers_for_handle(), ACE_QtReactor::destroy_notifiers_for_handle(), ACE_QtReactor::exception_event(), ACE_Token_Invariant_Manager::get_mutex(), ACE_Token_Invariant_Manager::get_rwlock(), ACE_Token_Collection::insert(), ACE_Token_Collection::is_member(), ACE_QtReactor::read_event(), ACE_Token_Collection::release(), ACE_Token_Collection::renew(), ACE_QtReactor::set_enable_flag_by_mask(), ACE_Token_Collection::tryacquire(), and ACE_QtReactor::write_event().

00149 {
00150   ACE_Map_Manager<EXT_ID, INT_ID, ACE_LOCK> *nc_this =
00151     (ACE_Map_Manager<EXT_ID, INT_ID, ACE_LOCK> *) this;
00152   ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, nc_this->lock_, -1);
00153 
00154   return nc_this->find_i (ext_id, int_id);
00155 }

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 as the key. Must be called with locks held.

Definition at line 363 of file Map_Manager.cpp.

References ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::equal(), ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::occupied_list_, and ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::occupied_list_id().

Referenced by ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::bind_i(), ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::find(), ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::find_i(), ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::rebind_i(), ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::trybind_i(), and ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::unbind_and_return_index().

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

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 using as the key. Must be called with locks held.

Definition at line 424 of file Map_Manager.cpp.

References ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::find_and_return_index().

Referenced by ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::find().

00426 {
00427   // Try to find the key.
00428   ACE_UINT32 slot = 0;
00429   int result = this->find_and_return_index (ext_id,
00430                                             slot);
00431   if (result == 0)
00432     // Key was found.  Make a copy of value.
00433     int_id = this->search_structure_[slot].int_id_;
00434 
00435   return result;
00436 }

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 231 of file Map_Manager.inl.

Referenced by ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::move_from_occupied_list_to_free_list(), ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::next_free(), and ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::resize_i().

00232 {
00233   // If you change ~0, please change
00234   // ACE_Active_Map_Manager_Key::ACE_Active_Map_Manager_Key()
00235   // accordingly.
00236   return (ACE_UINT32) ~0;
00237 }

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 .

Definition at line 573 of file Map_Manager.cpp.

References ACE_DES_FREE_TEMPLATE2, ACE_NOOP, and ACE_Allocator::free().

Referenced by ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::close_i(), and ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::resize_i().

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

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 204 of file Map_Manager.inl.

References ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::occupied_list_, ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::occupied_list_id(), and ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::shared_move().

Referenced by ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::shared_bind().

00205 {
00206   this->shared_move (slot,
00207                      this->free_list_,
00208                      this->free_list_id (),
00209                      this->occupied_list_,
00210                      this->occupied_list_id ());
00211 }

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 214 of file Map_Manager.inl.

References ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::free_list_id(), and ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::shared_move().

Referenced by ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::unbind_slot().

00215 {
00216   this->shared_move (slot,
00217                      this->occupied_list_,
00218                      this->occupied_list_id (),
00219                      this->free_list_,
00220                      this->free_list_id ());
00221 }

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 . 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 , but HP/C++ will choke on that!

Definition at line 198 of file Map_Manager.inl.

00199 {
00200   return this->lock_;
00201 }

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 556 of file Map_Manager.cpp.

References ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::LINEAR_INCREASE, and ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::MAX_EXPONENTIAL.

00557 {
00558   // Calculate the new size.
00559   ACE_UINT32 current_size = this->total_size_;
00560 
00561   if (current_size < MAX_EXPONENTIAL)
00562     // Exponentially increase if we haven't reached MAX_EXPONENTIAL.
00563     current_size *= 2;
00564   else
00565     // Linear increase if we have reached MAX_EXPONENTIAL.
00566     current_size += LINEAR_INCREASE;
00567 
00568   // This should be the new size.
00569   return current_size;
00570 }

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 101 of file Map_Manager.cpp.

References ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::free_list_id(), and ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::resize_i().

Referenced by ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::shared_bind().

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

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 240 of file Map_Manager.inl.

Referenced by ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::find_and_return_index(), ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::move_from_free_list_to_occupied_list(), ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::resize_i(), and ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::unbind_all().

00241 {
00242   return (ACE_UINT32) ~1;
00243 }

template<class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_BEGIN_VERSIONED_NAMESPACE_DECL 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< T >, and ACE_Active_Map_Manager< ACE_Pair< KEY, VALUE > >.

Definition at line 29 of file Map_Manager.cpp.

References ACE_ASSERT, ACE_UINT32_MAX, ACE_WRITE_GUARD_RETURN, ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::close_i(), ACE_Allocator::instance(), and ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::resize_i().

Referenced by ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::ACE_Map_Manager().

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

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< T >, and ACE_Active_Map_Manager< ACE_Pair< KEY, VALUE > >.

Definition at line 261 of file Map_Manager.inl.

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

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< T >, and ACE_Active_Map_Manager< ACE_Pair< KEY, VALUE > >.

Definition at line 116 of file Map_Manager.inl.

References ACE_WRITE_GUARD_RETURN, and ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::rebind_i().

00118 {
00119   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00120 
00121   return this->rebind_i (ext_id,
00122                          int_id);
00123 }

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 is not in the map then behaves just like . Otherwise, store the old values of 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< T >, and ACE_Active_Map_Manager< ACE_Pair< KEY, VALUE > >.

Definition at line 104 of file Map_Manager.inl.

References ACE_WRITE_GUARD_RETURN, and ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::rebind_i().

00107 {
00108   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00109 
00110   return this->rebind_i (ext_id,
00111                          int_id,
00112                          old_int_id);
00113 }

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 and into the "out" parameters and rebind the new parameters. This is very useful if you need to have an atomic way of updating 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< T >, and ACE_Active_Map_Manager< ACE_Pair< KEY, VALUE > >.

Definition at line 90 of file Map_Manager.inl.

References ACE_WRITE_GUARD_RETURN, and ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::rebind_i().

00094 {
00095   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00096 
00097   return this->rebind_i (ext_id,
00098                          int_id,
00099                          old_ext_id,
00100                          old_int_id);
00101 }

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 to . Must be called with locks held.

Definition at line 316 of file Map_Manager.cpp.

References ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::find_and_return_index(), ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::shared_bind(), and ACE_Allocator::sync().

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

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 to . Also, recovers old values. Must be called with locks held.

Definition at line 287 of file Map_Manager.cpp.

References ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::find_and_return_index(), ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::shared_bind(), and ACE_Allocator::sync().

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

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 to . Also, recovers old values. Must be called with locks held.

Definition at line 256 of file Map_Manager.cpp.

References ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::find_and_return_index(), ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::shared_bind(), and ACE_Allocator::sync().

Referenced by ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::rebind().

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

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< T >, and ACE_Active_Map_Manager< ACE_Pair< KEY, VALUE > >.

Definition at line 268 of file Map_Manager.inl.

00269 {
00270   return ACE_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK> (*this, 1);
00271 }

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 493 of file Map_Manager.cpp.

References ACE_ALLOCATOR_RETURN, ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::ENTRY, ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::free_list_id(), ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::free_search_structure(), ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::occupied_list_, and ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::occupied_list_id().

Referenced by ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::next_free(), and ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::open().

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

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 229 of file Map_Manager.cpp.

References ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::move_from_free_list_to_occupied_list(), and ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::next_free().

Referenced by ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::bind_i(), and ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::rebind_i().

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

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 184 of file Map_Manager.cpp.

References ACE_Map_Entry< EXT_ID, INT_ID >::next(), and ACE_Map_Entry< EXT_ID, INT_ID >::prev().

Referenced by ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::move_from_free_list_to_occupied_list(), and ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::move_from_occupied_list_to_free_list().

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

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< T >, and ACE_Active_Map_Manager< ACE_Pair< KEY, VALUE > >.

Definition at line 191 of file Map_Manager.inl.

References ACE_WRITE_GUARD_RETURN.

00192 {
00193   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, static_cast<size_t> (-1));
00194   return this->total_size_;
00195 }

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 with if and only if is not in the map. If is already in the map then the 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 126 of file Map_Manager.inl.

References ACE_WRITE_GUARD_RETURN, and ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::trybind_i().

00128 {
00129   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00130 
00131   return this->trybind_i (ext_id,
00132                           int_id);
00133 }

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 using as the key. Must be called with locks held.

Definition at line 342 of file Map_Manager.cpp.

References ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::bind_i(), and ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::find_and_return_index().

Referenced by ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::trybind().

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

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 . Returns the value of in case the caller needs to deallocate memory. Returns 0 if successful, else -1.

Reimplemented in ACE_Active_Map_Manager< T >, and ACE_Active_Map_Manager< ACE_Pair< KEY, VALUE > >.

Definition at line 167 of file Map_Manager.inl.

References ACE_WRITE_GUARD_RETURN, and ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::unbind_i().

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

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 from the map. Don't return the to the caller (this is useful for collections where the s are *not* dynamically allocated...) Returns 0 if successful, else -1.

Reimplemented in ACE_Active_Map_Manager< T >, and ACE_Active_Map_Manager< ACE_Pair< KEY, VALUE > >.

Definition at line 177 of file Map_Manager.inl.

References ACE_WRITE_GUARD_RETURN, and ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::unbind_i().

Referenced by ACE_QtReactor::destroy_notifiers_for_handle(), and ACE_Token_Collection::extract().

00178 {
00179   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00180   return this->unbind_i (ext_id);
00181 }

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 390 of file Map_Manager.cpp.

References ACE_Map_Entry< EXT_ID, INT_ID >::next(), ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::occupied_list_, ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::occupied_list_id(), and ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::unbind_slot().

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

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 as the key. Must be called with locks held.

Definition at line 439 of file Map_Manager.cpp.

References ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::find_and_return_index(), and ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::unbind_slot().

Referenced by ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::unbind_i().

00441 {
00442   // Try to find the key.
00443   int result = this->find_and_return_index (ext_id,
00444                                             slot);
00445 
00446   if (result == 0)
00447     this->unbind_slot (slot);
00448 
00449   return result;
00450 }

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 as the key. Must be called with locks held.

Definition at line 158 of file Map_Manager.inl.

References ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::unbind_and_return_index().

00159 {
00160   // Unbind the entry.
00161   ACE_UINT32 slot = 0;
00162   return this->unbind_and_return_index (ext_id,
00163                                         slot);
00164 }

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 using as the key. Must be called with locks held.

Definition at line 478 of file Map_Manager.cpp.

References ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::unbind_and_return_index().

Referenced by ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::unbind().

00480 {
00481   // Unbind the entry.
00482   ACE_UINT32 slot = 0;
00483   int result = this->unbind_and_return_index (ext_id,
00484                                               slot);
00485   if (result == 0)
00486     // If found, copy the value.
00487     int_id = this->search_structure_[slot].int_id_;
00488 
00489   return result;
00490 }

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 .

Definition at line 453 of file Map_Manager.cpp.

References ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::move_from_occupied_list_to_free_list().

Referenced by ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::unbind_all(), and ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::unbind_and_return_index().

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


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 133 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 131 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 132 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 130 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 134 of file Map_Manager.h.


Member Data Documentation

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

Declare the dynamic allocation hooks.

Reimplemented in ACE_Active_Map_Manager< T >, and ACE_Active_Map_Manager< ACE_Pair< KEY, VALUE > >.

Definition at line 286 of file Map_Manager.h.

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

Pointer to a memory allocator.

Definition at line 408 of file Map_Manager.h.

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

Current size of the map.

Definition at line 420 of file Map_Manager.h.

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

Free list.

Definition at line 423 of file Map_Manager.h.

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

Synchronization variable for the MT_SAFE .

Definition at line 411 of file Map_Manager.h.

Referenced by ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::find().

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

Occupied list.

Definition at line 426 of file Map_Manager.h.

Referenced by ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::close_i(), ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::find_and_return_index(), ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::move_from_free_list_to_occupied_list(), ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::resize_i(), and ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::unbind_all().

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

Implement the Map as a resizeable array of .

Definition at line 414 of file Map_Manager.h.

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

Total number of elements in this->search_structure_.

Definition at line 417 of file Map_Manager.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:24:29 2006 for ACE by doxygen 1.3.6