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

ACE_RMCast_Copy_On_Write Class Template Reference

Implement a copy on write wrapper for a map-like collection. More...

#include <RMCast_Copy_On_Write.h>

Inheritance diagram for ACE_RMCast_Copy_On_Write:

Inheritance graph
[legend]
Collaboration diagram for ACE_RMCast_Copy_On_Write:

Collaboration graph
[legend]
List of all members.

Public Types

typedef ACE_RMCast_Copy_On_Write_Read_Guard<
COLLECTION, ITERATOR > 
Read_Guard
 The Read_Guard trait. More...

typedef ACE_RMCast_Copy_On_Write_Write_Guard<
COLLECTION, ITERATOR > 
Write_Guard
 The Write_Guard trait. More...

typedef ACE_RMCast_Copy_On_Write_Collection<
COLLECTION, ITERATOR > 
Collection
 The underlying collection type. More...


Public Methods

 ACE_RMCast_Copy_On_Write (void)
 Constructor. More...

 ~ACE_RMCast_Copy_On_Write (void)
 Destructor. More...

int for_each (ACE_RMCast_Worker< KEY, ITEM > *worker)
 Iterate over all the elements invoking
Parameters:
worker  on each one.
More...


KEY first_key (void)
 Get the first key. More...

int empty (void)
 Return non-zero if the collection is empty. More...

int bind (KEY const &key, ITEM const &item)
 Add a new element. More...

int unbind (KEY const &key)
 Remove an element. More...

int bind_i (Write_Guard &guard, KEY const &key, ITEM const &item)
 Bind assuming the Write_Guard is held. More...

int unbind_i (Write_Guard &guard, KEY const &key)
 Unbind assuming the Write_Guard is held. More...


Detailed Description

template<class KEY, class ITEM, class COLLECTION, class ITERATOR>
class ACE_RMCast_Copy_On_Write< KEY, ITEM, COLLECTION, ITERATOR >

Implement a copy on write wrapper for a map-like collection.

Definition at line 159 of file RMCast_Copy_On_Write.h.


Member Typedef Documentation

template<class KEY, class ITEM, class COLLECTION, class ITERATOR>
typedef ACE_RMCast_Copy_On_Write_Collection<COLLECTION,ITERATOR> ACE_RMCast_Copy_On_Write::Collection
 

The underlying collection type.

Reimplemented from ACE_RMCast_Copy_On_Write_Container.

Definition at line 169 of file RMCast_Copy_On_Write.h.

template<class KEY, class ITEM, class COLLECTION, class ITERATOR>
typedef ACE_RMCast_Copy_On_Write_Read_Guard<COLLECTION,ITERATOR> ACE_RMCast_Copy_On_Write::Read_Guard
 

The Read_Guard trait.

Definition at line 163 of file RMCast_Copy_On_Write.h.

template<class KEY, class ITEM, class COLLECTION, class ITERATOR>
typedef ACE_RMCast_Copy_On_Write_Write_Guard<COLLECTION,ITERATOR> ACE_RMCast_Copy_On_Write::Write_Guard
 

The Write_Guard trait.

Definition at line 166 of file RMCast_Copy_On_Write.h.


Constructor & Destructor Documentation

template<class KEY, class ITEM, class COLLECTION, class ITERATOR>
ACE_RMCast_Copy_On_Write< KEY, ITEM, COLLECTION, ITERATOR >::ACE_RMCast_Copy_On_Write void   
 

Constructor.

Definition at line 41 of file RMCast_Copy_On_Write.cpp.

template<class KEY, class ITEM, class COLLECTION, class ITERATOR>
ACE_RMCast_Copy_On_Write< KEY, ITEM, COLLECTION, ITERATOR >::~ACE_RMCast_Copy_On_Write void   
 

Destructor.

Definition at line 48 of file RMCast_Copy_On_Write.cpp.

References ACE_RMCast_Copy_On_Write_Collection::_decr_refcnt, ACE_GUARD, ACE_SYNCH_MUTEX, ACE_RMCast_Copy_On_Write_Container::collection_, ACE_RMCast_Copy_On_Write_Container::cond_, and ACE_RMCast_Copy_On_Write_Container::pending_writes_.

00049 {
00050   ACE_GUARD (ACE_SYNCH_MUTEX, ace_mon, this->mutex_);
00051 
00052   while (this->pending_writes_ != 0)
00053     this->cond_.wait ();
00054 
00055   this->collection_->_decr_refcnt ();
00056   this->collection_ = 0;
00057 }


Member Function Documentation

template<class KEY, class ITEM, class C, class I>
int ACE_RMCast_Copy_On_Write< KEY, ITEM, C, I >::bind KEY const &    key,
ITEM const &    item
 

Add a new element.

Definition at line 101 of file RMCast_Copy_On_Write.cpp.

References bind_i.

00103 {
00104   Write_Guard ace_mon (*this);
00105 
00106   return this->bind_i (ace_mon, k, i);
00107 }

template<class KEY, class ITEM, class C, class I>
int ACE_RMCast_Copy_On_Write< KEY, ITEM, C, I >::bind_i Write_Guard   guard,
KEY const &    key,
ITEM const &    item
 

Bind assuming the Write_Guard is held.

Definition at line 118 of file RMCast_Copy_On_Write.cpp.

References ACE_RMCast_Copy_On_Write_Collection::collection, and ACE_RMCast_Copy_On_Write_Write_Guard::copy.

Referenced by bind.

00121 {
00122   return ace_mon.copy->collection.bind (k, i);
00123 }

template<class KEY, class ITEM, class C, class ITERATOR>
int ACE_RMCast_Copy_On_Write< KEY, ITEM, C, ITERATOR >::empty void   
 

Return non-zero if the collection is empty.

Definition at line 91 of file RMCast_Copy_On_Write.cpp.

References ACE_RMCast_Copy_On_Write_Collection::collection, and ACE_RMCast_Copy_On_Write_Read_Guard::collection.

00092 {
00093   Read_Guard ace_mon (*this);
00094   ITERATOR end = ace_mon.collection->collection.end ();
00095   ITERATOR begin = ace_mon.collection->collection.begin ();
00096 
00097   return end == begin;
00098 }

template<class KEY, class ITEM, class C, class ITERATOR>
KEY ACE_RMCast_Copy_On_Write< KEY, ITEM, C, ITERATOR >::first_key void   
 

Get the first key.

Definition at line 78 of file RMCast_Copy_On_Write.cpp.

References ACE_RMCast_Copy_On_Write_Collection::collection, and ACE_RMCast_Copy_On_Write_Read_Guard::collection.

00079 {
00080   Read_Guard ace_mon (*this);
00081   ITERATOR end = ace_mon.collection->collection.end ();
00082   ITERATOR begin = ace_mon.collection->collection.begin ();
00083   if (begin == end)
00084     {
00085       return KEY ();
00086     }
00087   return (*begin).key ();
00088 }

template<class KEY, class ITEM, class COLLECTION, class ITERATOR>
int ACE_RMCast_Copy_On_Write< KEY, ITEM, COLLECTION, ITERATOR >::for_each ACE_RMCast_Worker< KEY, ITEM > *    worker
 

Iterate over all the elements invoking

Parameters:
worker  on each one.

Definition at line 61 of file RMCast_Copy_On_Write.cpp.

References ACE_RMCast_Copy_On_Write_Collection::collection, ACE_RMCast_Copy_On_Write_Read_Guard::collection, and ACE_RMCast_Worker::work.

00062 {
00063   Read_Guard ace_mon (*this);
00064 
00065   ITERATOR end = ace_mon.collection->collection.end ();
00066   for (ITERATOR i = ace_mon.collection->collection.begin (); i != end; ++i)
00067     {
00068       int r = worker->work ((*i).key (), (*i).item ());
00069       if (r == 1)
00070         return 0; // Abort loop, but no error
00071       if (r == -1)
00072         return -1;
00073     }
00074   return 0;
00075 }

template<class KEY, class ITEM, class C, class I>
int ACE_RMCast_Copy_On_Write< KEY, ITEM, C, I >::unbind KEY const &    key
 

Remove an element.

Definition at line 110 of file RMCast_Copy_On_Write.cpp.

References unbind_i.

00111 {
00112   Write_Guard ace_mon (*this);
00113 
00114   return this->unbind_i (ace_mon, k);
00115 }

template<class KEY, class ITEM, class C, class I>
int ACE_RMCast_Copy_On_Write< KEY, ITEM, C, I >::unbind_i Write_Guard   guard,
KEY const &    key
 

Unbind assuming the Write_Guard is held.

Definition at line 126 of file RMCast_Copy_On_Write.cpp.

References ACE_RMCast_Copy_On_Write_Collection::collection, and ACE_RMCast_Copy_On_Write_Write_Guard::copy.

Referenced by unbind.

00128 {
00129   return ace_mon.copy->collection.unbind (k);
00130 }


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