Classes | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes

threadsafe_multimap< K, T > Class Template Reference
[Threadsafe Collection API]

A very simple map object that is safe for multiple threads to use at the same time. More...

#include <threadsafe_multimap.h>

Collaboration diagram for threadsafe_multimap< K, T >:
Collaboration graph
[legend]

List of all members.

Classes

struct  iterator_t
struct  real_iter_t

Public Member Functions

int size (void)
 how many elements in the map
int count (const K &key)
 how many elements with the given key
void insert (const K &key, const T &t)
 insert the given object at the given key value
void remove (const K &key)
 remove (erase) all elements with this key
void clear (void)
 clear out (erase) the entire map
void getIterator (iterator_t &i)
 get an iterator (points to the first element in the map)
void getIterator (const K &key, iterator_t &i)
 get an iterator just for a particular key
bool getNextElement (iterator_t &i, K &k, T &t)
 get next element in map and increment iterator
T * getNextElementUnsafe (iterator_t &i, K &k)
 get next element without getting a local copy.

Static Public Member Functions

static int getRealIteratorSize (void) throw ()
 for debugging/validation only

Private Types

typedef std::multimap< K, T > base_map_t
typedef std::multimap< K, T >
::iterator 
base_iterator_t
typedef std::pair
< base_iterator_t,
base_iterator_t
iter_pair_t

Private Member Functions

T * getNextElementInternal (real_iter_t *ri, K &k)

Static Private Member Functions

static real_iter_tgetRealIterator (iterator_t &i) throw ()

Private Attributes

smart_mutex m_mutex
dword_t m_rvn

Detailed Description

template<class K, class T>
class threadsafe_multimap< K, T >

A very simple map object that is safe for multiple threads to use at the same time.

There is a single mutex protecting the entire map.

You can iterate using getIterator()/getNextElement(). However, that is not guaranteed iteration. Your iterator will be invalidated (and getNextElement() will return false) if another thread has since updated the map.

Definition at line 58 of file threadsafe_multimap.h.


Member Typedef Documentation

template<class K, class T>
typedef std::multimap<K,T> threadsafe_multimap< K, T >::base_map_t [private]

Reimplemented in Datahash.

Definition at line 61 of file threadsafe_multimap.h.

template<class K, class T>
typedef std::multimap<K,T>::iterator threadsafe_multimap< K, T >::base_iterator_t [private]

Definition at line 62 of file threadsafe_multimap.h.

template<class K, class T>
typedef std::pair<base_iterator_t, base_iterator_t> threadsafe_multimap< K, T >::iter_pair_t [private]

Definition at line 63 of file threadsafe_multimap.h.


Member Function Documentation

template<class K, class T>
int threadsafe_multimap< K, T >::size ( void   )  [inline]

how many elements in the map

Definition at line 81 of file threadsafe_multimap.h.

template<class K, class T>
int threadsafe_multimap< K, T >::count ( const K &  key  )  [inline]

how many elements with the given key

Definition at line 88 of file threadsafe_multimap.h.

template<class K, class T>
void threadsafe_multimap< K, T >::insert ( const K &  key,
const T &  t 
) [inline]

insert the given object at the given key value

Reimplemented in Datahash.

Definition at line 94 of file threadsafe_multimap.h.

template<class K, class T>
void threadsafe_multimap< K, T >::remove ( const K &  key  )  [inline]

remove (erase) all elements with this key

Definition at line 101 of file threadsafe_multimap.h.

template<class K, class T>
void threadsafe_multimap< K, T >::clear ( void   )  [inline]

clear out (erase) the entire map

Definition at line 109 of file threadsafe_multimap.h.

template<class K, class T>
void threadsafe_multimap< K, T >::getIterator ( iterator_t i  )  [inline]

get an iterator (points to the first element in the map)

Definition at line 116 of file threadsafe_multimap.h.

template<class K, class T>
void threadsafe_multimap< K, T >::getIterator ( const K &  key,
iterator_t i 
) [inline]

get an iterator just for a particular key

Definition at line 125 of file threadsafe_multimap.h.

template<class K, class T>
bool threadsafe_multimap< K, T >::getNextElement ( iterator_t i,
K &  k,
T &  t 
) [inline]

get next element in map and increment iterator

Definition at line 135 of file threadsafe_multimap.h.

template<class K, class T>
T* threadsafe_multimap< K, T >::getNextElementUnsafe ( iterator_t i,
K &  k 
) [inline]

get next element without getting a local copy.

Caller had better be sure that the element won't be removed after this call!

Definition at line 148 of file threadsafe_multimap.h.

template<class K, class T>
static int threadsafe_multimap< K, T >::getRealIteratorSize ( void   )  throw () [inline, static]

for debugging/validation only

Definition at line 155 of file threadsafe_multimap.h.

template<class K, class T>
static real_iter_t* threadsafe_multimap< K, T >::getRealIterator ( iterator_t i  )  throw () [inline, static, private]

Definition at line 161 of file threadsafe_multimap.h.

template<class K, class T>
T* threadsafe_multimap< K, T >::getNextElementInternal ( real_iter_t ri,
K &  k 
) [inline, private]

Definition at line 165 of file threadsafe_multimap.h.


Member Data Documentation

template<class K, class T>
smart_mutex threadsafe_multimap< K, T >::m_mutex [private]

Definition at line 181 of file threadsafe_multimap.h.

template<class K, class T>
dword_t threadsafe_multimap< K, T >::m_rvn [private]

Definition at line 182 of file threadsafe_multimap.h.


The documentation for this class was generated from the following file: