decaf::util::concurrent::ConcurrentMap< K, V > Class Template Reference

Interface for a Map type that provides additional atomic putIfAbsent, remove, and replace methods alongside the already available Map interface. More...

#include <src/main/decaf/util/concurrent/ConcurrentMap.h>

Inheritance diagram for decaf::util::concurrent::ConcurrentMap< K, V >:
Inheritance graph
[legend]

Public Member Functions

virtual ~ConcurrentMap ()
virtual bool putIfAbsent (const K &key, const V &value)=0
 If the specified key is not already associated with a value, associate it with the given value.
virtual bool remove (const K &key, const V &value)=0
 Remove entry for key only if currently mapped to given value.
virtual bool replace (const K &key, const V &oldValue, const V &newValue)=0
 Replace entry for key only if currently mapped to given value.
virtual V replace (const K &key, const V &value)=0
 Replace entry for key only if currently mapped to some value.

Detailed Description

template<typename K, typename V>
class decaf::util::concurrent::ConcurrentMap< K, V >

Interface for a Map type that provides additional atomic putIfAbsent, remove, and replace methods alongside the already available Map interface.

Since:
1.0

Constructor & Destructor Documentation

template<typename K, typename V>
virtual decaf::util::concurrent::ConcurrentMap< K, V >::~ConcurrentMap (  )  [inline, virtual]

Member Function Documentation

template<typename K, typename V>
virtual bool decaf::util::concurrent::ConcurrentMap< K, V >::putIfAbsent ( const K &  key,
const V &  value 
) [pure virtual]

If the specified key is not already associated with a value, associate it with the given value.

This is equivalent to

     if( !map.containsKey( key ) ) {
         map.put( key, value );
         return true;
     } else {
         return false;
     }
 

except that the action is performed atomically.

Parameters:
key The key to map the value to.
value The value to map to the given key.
Returns:
true if the put operation was performed otherwise return false which indicates there was a value previously mapped to the key.
Exceptions:
UnsupportedOperationException if the put operation is not supported by this map

Implemented in decaf::util::concurrent::ConcurrentStlMap< K, V, COMPARATOR >, decaf::util::concurrent::ConcurrentStlMap< Pointer< ConsumerId >, Pointer< ConsumerState >, ConsumerId::COMPARATOR >, decaf::util::concurrent::ConcurrentStlMap< Pointer< SessionId >, Pointer< SessionState >, SessionId::COMPARATOR >, decaf::util::concurrent::ConcurrentStlMap< Pointer< LocalTransactionId >, Pointer< TransactionState >, LocalTransactionId::COMPARATOR >, and decaf::util::concurrent::ConcurrentStlMap< Pointer< ProducerId >, Pointer< ProducerState >, ProducerId::COMPARATOR >.

template<typename K, typename V>
virtual bool decaf::util::concurrent::ConcurrentMap< K, V >::remove ( const K &  key,
const V &  value 
) [pure virtual]

Remove entry for key only if currently mapped to given value.

Acts as

 if( ( map.containsKey( key ) && ( map.get( key ) == value ) ) ) {
     map.remove( key );
     return true;
 } else {
     return false;
 }
 

except that the action is performed atomically.

Parameters:
key key with which the specified value is associated.
value value associated with the specified key.
Returns:
true if the value was removed, false otherwise

Implemented in decaf::util::concurrent::ConcurrentStlMap< K, V, COMPARATOR >, decaf::util::concurrent::ConcurrentStlMap< Pointer< ConsumerId >, Pointer< ConsumerState >, ConsumerId::COMPARATOR >, decaf::util::concurrent::ConcurrentStlMap< Pointer< SessionId >, Pointer< SessionState >, SessionId::COMPARATOR >, decaf::util::concurrent::ConcurrentStlMap< Pointer< LocalTransactionId >, Pointer< TransactionState >, LocalTransactionId::COMPARATOR >, and decaf::util::concurrent::ConcurrentStlMap< Pointer< ProducerId >, Pointer< ProducerState >, ProducerId::COMPARATOR >.

template<typename K, typename V>
virtual V decaf::util::concurrent::ConcurrentMap< K, V >::replace ( const K &  key,
const V &  value 
) [pure virtual]

Replace entry for key only if currently mapped to some value.

Acts as

 if( ( map.containsKey( key ) ) {
     return map.put( key, value );
 } else {
     throw NoSuchElementException(...);
 };
 

except that the action is performed atomically.

Parameters:
key key with which the specified value is associated.
value value to be associated with the specified key.
Returns:
copy of the previous value associated with specified key, or throws an NoSuchElementException if there was no mapping for key.
Exceptions:
NoSuchElementException if there was no previous mapping.

Implemented in decaf::util::concurrent::ConcurrentStlMap< K, V, COMPARATOR >, decaf::util::concurrent::ConcurrentStlMap< Pointer< ConsumerId >, Pointer< ConsumerState >, ConsumerId::COMPARATOR >, decaf::util::concurrent::ConcurrentStlMap< Pointer< SessionId >, Pointer< SessionState >, SessionId::COMPARATOR >, decaf::util::concurrent::ConcurrentStlMap< Pointer< LocalTransactionId >, Pointer< TransactionState >, LocalTransactionId::COMPARATOR >, and decaf::util::concurrent::ConcurrentStlMap< Pointer< ProducerId >, Pointer< ProducerState >, ProducerId::COMPARATOR >.

template<typename K, typename V>
virtual bool decaf::util::concurrent::ConcurrentMap< K, V >::replace ( const K &  key,
const V &  oldValue,
const V &  newValue 
) [pure virtual]

Replace entry for key only if currently mapped to given value.

Acts as

 if( ( map.containsKey( key ) && ( map.get( key ) == oldValue  ) ) {
     map.put( key, newValue );
     return true;
 } else {
     return false;
 }
 

except that the action is performed atomically.

Parameters:
key key with which the specified value is associated.
oldValue value expected to be associated with the specified key.
newValue value to be associated with the specified key.
Returns:
true if the value was replaced

Implemented in decaf::util::concurrent::ConcurrentStlMap< K, V, COMPARATOR >, decaf::util::concurrent::ConcurrentStlMap< Pointer< ConsumerId >, Pointer< ConsumerState >, ConsumerId::COMPARATOR >, decaf::util::concurrent::ConcurrentStlMap< Pointer< SessionId >, Pointer< SessionState >, SessionId::COMPARATOR >, decaf::util::concurrent::ConcurrentStlMap< Pointer< LocalTransactionId >, Pointer< TransactionState >, LocalTransactionId::COMPARATOR >, and decaf::util::concurrent::ConcurrentStlMap< Pointer< ProducerId >, Pointer< ProducerState >, ProducerId::COMPARATOR >.


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

Generated on 1 Dec 2014 for activemq-cpp-3.8.2 by  doxygen 1.6.1