ACE_INet  6.1.0
Public Types | Public Member Functions | Private Member Functions | Private Attributes
ACE::INet::ConnectionCache Class Reference

#include <ConnectionCache.h>

Collaboration diagram for ACE::INet::ConnectionCache:
Collaboration graph
[legend]

List of all members.

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_MUTEX
map_type
typedef map_type::iterator map_iter_type
typedef ACE_Hash_Map_Entry
< ConnectionCacheKey,
ConnectionCacheValue
map_entry_type

Public Member Functions

 ConnectionCache (size_t size=ACE_DEFAULT_MAP_SIZE)
 Constructor.
 ~ConnectionCache ()
 Destructor.
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.
size_t current_size () const
 Returns the number of registered cache entries (including CLOSED).

Private Member Functions

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

Private Attributes

ACE_SYNCH_MUTEX lock_
ACE_SYNCH_CONDITION condition_
map_type cache_map_

Member Typedef Documentation


Constructor & Destructor Documentation

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

Constructor.

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

Destructor.


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 
) [private]

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 [inline]

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

bool ACE::INet::ConnectionCache::find_connection ( const ConnectionKey key,
ConnectionCacheValue cacheval 
) [private]

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 
) [private]

Updates cache entry state.


Member Data Documentation


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines