1717#include < condition_variable>
1818#include < mutex>
1919
20+ struct aws_http_connection_manager ;
21+
2022namespace Aws
2123{
2224 namespace Crt
@@ -26,10 +28,10 @@ namespace Aws
2628 /* *
2729 * Invoked when a connection from the pool is available. If a connection was successfully obtained
2830 * the connection shared_ptr can be seated into your own copy of connection. If it failed, errorCode
29- * will be non-zero. It is your responsibility to release the connection when you are finished with it.
31+ * will be non-zero.
3032 */
3133 using OnClientConnectionAvailable =
32- std::function<void (std::shared_ptr<HttpClientConnection> connection , int errorCode)>;
34+ std::function<void (std::shared_ptr<HttpClientConnection>, int errorCode)>;
3335
3436 struct HttpClientConnectionManagerOptions
3537 {
@@ -54,17 +56,11 @@ namespace Aws
5456 /* *
5557 * Acquires a connection from the pool. onClientConnectionAvailable will be invoked upon an available
5658 * connection. Returns true if the connection request was successfully pooled, returns false if it
57- * failed. On failure, onClientConnectionAvailable will not be invoked. After receiving a connection,
58- * you must invoke ReleaseConnection() .
59+ * failed. On failure, onClientConnectionAvailable will not be invoked. After receiving a connection, it
60+ * will automatically be cleaned up when your last reference to the shared_ptr is released .
5961 */
6062 bool AcquireConnection (const OnClientConnectionAvailable &onClientConnectionAvailable) noexcept ;
6163
62- /* *
63- * Releases a connection back to the pool. This will cause queued consumers to be serviced, or the
64- * connection will be pooled waiting on another call to AcquireConnection
65- */
66- void ReleaseConnection (std::shared_ptr<HttpClientConnection> connection) noexcept ;
67-
6864 int LastError () const noexcept { return m_lastError; }
6965 explicit operator bool () const noexcept { return m_good; }
7066
@@ -77,26 +73,20 @@ namespace Aws
7773 const HttpClientConnectionManagerOptions &connectionManagerOptions,
7874 Allocator *allocator = DefaultAllocator()) noexcept ;
7975
80- Vector<std::shared_ptr<HttpClientConnection>> m_connections ;
81- List<OnClientConnectionAvailable> m_pendingConnectionRequests;
76+ aws_http_connection_manager *m_connectionManager ;
77+
8278 Allocator *m_allocator;
8379 Io::ClientBootstrap *m_bootstrap;
84- size_t m_initialWindowSize;
85- Io::SocketOptions m_socketOptions;
8680 Io::TlsConnectionOptions m_tlsConnOptions;
87- String m_hostName;
88- uint16_t m_port;
8981 bool m_good;
9082 int m_lastError;
91- size_t m_maxSize;
92- size_t m_outstandingVendedConnections;
93- size_t m_pendingConnections;
94- std::mutex m_connectionsLock;
9583
96- void onConnectionSetup (const std::shared_ptr<HttpClientConnection> &connection, int errorCode) noexcept ;
97- void onConnectionShutdown (HttpClientConnection &connection, int errorCode) noexcept ;
98- bool createConnection () noexcept ;
99- void poolOrVendConnection (std::shared_ptr<HttpClientConnection> connection, bool isRelease) noexcept ;
84+ static void s_onConnectionSetup (
85+ aws_http_connection *connection,
86+ int errorCode,
87+ void *userData) noexcept ;
88+
89+ friend class ManagedConnection ;
10090 };
10191 } // namespace Http
10292 } // namespace Crt
0 commit comments