ACE_INet  6.3.3
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
ACE::INet::ConnectionCache Class Reference

#include <ConnectionCache.h>

Collaboration diagram for ACE::INet::ConnectionCache:
Collaboration graph

Public Types

typedef ConnectionHolder connection_type
typedef ConnectionFactory factory_type
typedef ACE_Hash_Map_Manager_Ex< ConnectionCacheKey, ConnectionCacheValue, ACE_Hash< ConnectionCacheKey >, ACE_Equal_To< ConnectionCacheKey >, ACE_SYNCH_NULL_MUTEXmap_type
typedef map_type::iterator map_iter_type
typedef ACE_Hash_Map_Entry< ConnectionCacheKey, ConnectionCacheValuemap_entry_type

Public Member Functions

 ConnectionCache (size_t size=ACE_DEFAULT_MAP_SIZE)
 Constructor. More...
 ~ConnectionCache ()
 Destructor. More...
bool claim_connection (const ConnectionKey &key, connection_type *&connection, const factory_type &connection_factory, bool wait=true)
bool release_connection (const ConnectionKey &key, connection_type *connection)
bool close_connection (const ConnectionKey &key, connection_type *connection)
bool has_connection (const ConnectionKey &key)
void close_all_connections ()
 Unconditionally closes all active connections. More...
size_t current_size () const
 Returns the number of registered cache entries (including CLOSED). More...

Private Member Functions

bool set_connection (const ConnectionKey &key, const ConnectionCacheValue &cacheval)
 Updates cache entry state. More...
bool claim_existing_connection (const ConnectionKey &key, connection_type *&connection, ConnectionCacheValue::State &state)
bool find_connection (const ConnectionKey &key, ConnectionCacheValue &cacheval)

Private Attributes

map_type cache_map_

Member Typedef Documentation

Constructor & Destructor Documentation

ACE::INet::ConnectionCache::ConnectionCache ( size_t  size = ACE_DEFAULT_MAP_SIZE)


ACE::INet::ConnectionCache::~ConnectionCache ( )


Member Function Documentation

bool ACE::INet::ConnectionCache::claim_connection ( const ConnectionKey key,
connection_type *&  connection,
const factory_type connection_factory,
bool  wait = true 

Claim a connection from the cache. Creates a new connection using <connection_factory> if the cache does not contain a matching entry for <key>. If <wait> is true and the state of the matching connection is BUSY the method will block waiting for connection to become available. Returns true if a connection could be successfully claimed and sets <connection> to the claimed connection. Returns false otherwise.

bool ACE::INet::ConnectionCache::claim_existing_connection ( const ConnectionKey key,
connection_type *&  connection,
ConnectionCacheValue::State state 

Attempts to claim an existing connection. Returns true and sets connection if successful. Returns false otherwise. Does not wait when no connection available.

void ACE::INet::ConnectionCache::close_all_connections ( )

Unconditionally closes all active connections.

bool ACE::INet::ConnectionCache::close_connection ( const ConnectionKey key,
connection_type connection 

Close a previously claimed connection. Deletes the actual connection object and marks the cache entry as CLOSED. Returns true is the connection was successfully closed.

size_t ACE::INet::ConnectionCache::current_size ( ) const

Returns the number of registered cache entries (including CLOSED).

bool ACE::INet::ConnectionCache::find_connection ( const ConnectionKey key,
ConnectionCacheValue cacheval 

Looks up a matching cache entry for key and updates <cacheval> with the entry state if found. Returns true if found, false otherwise.

bool ACE::INet::ConnectionCache::has_connection ( const ConnectionKey key)

Returns true if the cache contains a connection matching <key>. Cache entries with state CLOSED are not considered. Returns false otherwise.

bool ACE::INet::ConnectionCache::release_connection ( const ConnectionKey key,
connection_type connection 

Release a previously claimed connection making it available for renewed claiming. Returns true if the connection was successfully released.

bool ACE::INet::ConnectionCache::set_connection ( const ConnectionKey key,
const ConnectionCacheValue cacheval 

Updates cache entry state.

Member Data Documentation

map_type ACE::INet::ConnectionCache::cache_map_
ACE_SYNCH_CONDITION ACE::INet::ConnectionCache::condition_
ACE_SYNCH_MUTEX ACE::INet::ConnectionCache::lock_

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