ACE_INet
6.2.0
|
#include <ConnectionCache.h>
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. 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 | |
ACE_SYNCH_MUTEX | lock_ |
ACE_SYNCH_CONDITION | condition_ |
map_type | cache_map_ |
typedef ACE_Hash_Map_Entry<ConnectionCacheKey, ConnectionCacheValue> ACE::INet::ConnectionCache::map_entry_type |
typedef ACE_Hash_Map_Manager_Ex<ConnectionCacheKey, ConnectionCacheValue, ACE_Hash<ConnectionCacheKey>, ACE_Equal_To<ConnectionCacheKey>, ACE_SYNCH_NULL_MUTEX> ACE::INet::ConnectionCache::map_type |
ACE::INet::ConnectionCache::ConnectionCache | ( | size_t | size = ACE_DEFAULT_MAP_SIZE | ) |
Constructor.
ACE::INet::ConnectionCache::~ConnectionCache | ( | ) |
Destructor.
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.
|
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.
|
inline |
Returns the number of registered cache entries (including CLOSED).
|
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.
|
private |
Updates cache entry state.
|
private |
|
private |
|
mutableprivate |