AWS SDK for C++
AWS SDK for C++
Loading...
Searching...
No Matches
WinConnectionPoolMgr.h
Go to the documentation of this file.
1
6#pragma once
7
9
13
14#include <utility>
15
16namespace Aws
17{
18 namespace Http
19 {
20
21 class WinHttpSyncHttpClient;
27 {
28 public:
29 /*
30 * Constructs instance, using iOpenHandle from InternetOpen api call, and maxConnectionsPerHost.
31 */
32 WinConnectionPoolMgr(void* iOpenHandle, unsigned maxConnectionsPerHost, long requestTimeout, long connectTimeout);
33 WinConnectionPoolMgr(void* iOpenHandle, unsigned maxConnectionsPerHost, long requestTimeout, long connectTimeout, bool enableTcpKeepAlive, unsigned long tcpKeepAliveIntervalMs);
34
35 /*
36 * Cleans up all connections that have been allocated (might take a while).
37 */
39
40 /*
41 * Acquires a connection for host and port from pool, or adds connections to pool until pool has reached max size
42 * If no connections are available and the pool is at its maximum size, then this call will block until connections
43 * become available.
44 */
45 void* AcquireConnectionForHost(const Aws::String& host, uint16_t port);
46
47 /*
48 * Releases a connection to host and port back to the pool, if another thread is blocked in Acquire, then the top queued item
49 * will be returned a connection and signaled to continue.
50 */
51 void ReleaseConnectionForHost(const Aws::String& host, unsigned port, void* connection);
52
56 virtual const char* GetLogTag() const { return "ConnectionPoolMgr"; }
60 virtual void DoCloseHandle(void* handle) const = 0;
61
62 protected:
67 {
68 public:
69 uint16_t port;
72 };
73
77 void* GetOpenHandle() const { return m_iOpenHandle; }
78
82 long GetRequestTimeout() const { return m_requestTimeoutMs; }
86 long GetConnectTimeout() const { return m_connectTimeoutMs; }
90 bool GetEnableTcpKeepAlive() const { return m_enableTcpKeepAlive; }
94 unsigned long GetTcpKeepAliveInterval() const { return m_tcpKeepAliveIntervalMs; }
95
99 void DoCleanup();
100
101 private:
102
103 virtual void* CreateNewConnection(const Aws::String& host, HostConnectionContainer& connectionContainer) const = 0;
104
106 const WinConnectionPoolMgr& operator = (const WinConnectionPoolMgr&) = delete;
108 const WinConnectionPoolMgr& operator = (const WinConnectionPoolMgr&&) = delete;
109
110 bool CheckAndGrowPool(const Aws::String& host, HostConnectionContainer& connectionContainer);
111
112 void* m_iOpenHandle;
114 std::mutex m_hostConnectionsMutex;
115 unsigned m_maxConnectionsPerHost;
116 long m_requestTimeoutMs;
117 long m_connectTimeoutMs;
118 bool m_enableTcpKeepAlive;
119 unsigned long m_tcpKeepAliveIntervalMs;
120 std::mutex m_containerLock;
121
123 };
124
125 } // namespace Http
126} // namespace Aws
#define AWS_CORE_API
Definition: Core_EXPORTS.h:26
Aws::Utils::ExclusiveOwnershipResourceManager< void * > hostConnections
virtual void DoCloseHandle(void *handle) const =0
void ReleaseConnectionForHost(const Aws::String &host, unsigned port, void *connection)
WinConnectionPoolMgr(void *iOpenHandle, unsigned maxConnectionsPerHost, long requestTimeout, long connectTimeout)
unsigned long GetTcpKeepAliveInterval() const
void * AcquireConnectionForHost(const Aws::String &host, uint16_t port)
WinConnectionPoolMgr(void *iOpenHandle, unsigned maxConnectionsPerHost, long requestTimeout, long connectTimeout, bool enableTcpKeepAlive, unsigned long tcpKeepAliveIntervalMs)
virtual const char * GetLogTag() const
std::map< K, V, std::less< K >, Aws::Allocator< std::pair< const K, V > > > Map
Definition: AWSMap.h:19
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String
Definition: AWSString.h:97