AWS IoT Device SDK C++ v2: crt/aws-crt-cpp/include/aws/crt/http/HttpConnectionManager.h Source File

AWS IoT Device SDK C++ v2 1.14.0 AWS IoT Device SDK C++ v2

HttpConnectionManager.h
Go to the documentation of this file.
1#pragma once
6#include <aws/crt/http/HttpConnection.h>
7
8#include <atomic>
9#include <condition_variable>
10#include <future>
11#include <mutex>
12
13struct aws_http_connection_manager;
14
15namespace Aws
16{
17 namespace Crt
18 {
19 namespace Http
20 {
26 using OnClientConnectionAvailable =
27 std::function<void(std::shared_ptr<HttpClientConnection>, int errorCode)>;
28
32 class AWS_CRT_CPP_API HttpClientConnectionManagerOptions
33 {
34 public:
35 HttpClientConnectionManagerOptions() noexcept;
36 HttpClientConnectionManagerOptions(const HttpClientConnectionManagerOptions &rhs) = default;
37 HttpClientConnectionManagerOptions(HttpClientConnectionManagerOptions &&rhs) = default;
38
39 HttpClientConnectionManagerOptions &operator=(const HttpClientConnectionManagerOptions &rhs) = default;
40 HttpClientConnectionManagerOptions &operator=(HttpClientConnectionManagerOptions &&rhs) = default;
41
45 HttpClientConnectionOptions ConnectionOptions;
46
50 size_t MaxConnections;
51
59 bool EnableBlockingShutdown;
60 };
61
65 class AWS_CRT_CPP_API HttpClientConnectionManager final
66 : public std::enable_shared_from_this<HttpClientConnectionManager>
67 {
68 public:
69 ~HttpClientConnectionManager();
70
81 bool AcquireConnection(const OnClientConnectionAvailable &onClientConnectionAvailable) noexcept;
82
90 std::future<void> InitiateShutdown() noexcept;
91
99 static std::shared_ptr<HttpClientConnectionManager> NewClientConnectionManager(
100 const HttpClientConnectionManagerOptions &connectionManagerOptions,
101 Allocator *allocator = g_allocator) noexcept;
102
103 private:
104 HttpClientConnectionManager(
105 const HttpClientConnectionManagerOptions &options,
106 Allocator *allocator = g_allocator) noexcept;
107
108 Allocator *m_allocator;
109
110 aws_http_connection_manager *m_connectionManager;
111
112 HttpClientConnectionManagerOptions m_options;
113 std::promise<void> m_shutdownPromise;
114 std::atomic<bool> m_releaseInvoked;
115
116 static void s_onConnectionSetup(
117 aws_http_connection *connection,
118 int errorCode,
119 void *userData) noexcept;
120
121 static void s_shutdownCompleted(void *userData) noexcept;
122
123 friend class ManagedConnection;
124 };
125 } // namespace Http
126 } // namespace Crt
127} // namespace Aws
HttpConnection.h
Aws::Crt::Http::HttpClientConnectionManager
Definition: HttpConnectionManager.h:67
Aws::Crt::Http::HttpClientConnectionManagerOptions
Definition: HttpConnectionManager.h:33
Aws::Crt::Http::HttpClientConnectionManagerOptions::operator=
HttpClientConnectionManagerOptions & operator=(const HttpClientConnectionManagerOptions &rhs)=default
Aws::Crt::Http::HttpClientConnectionManagerOptions::ConnectionOptions
HttpClientConnectionOptions ConnectionOptions
Definition: HttpConnectionManager.h:45
Aws::Crt::Http::HttpClientConnectionManagerOptions::MaxConnections
size_t MaxConnections
Definition: HttpConnectionManager.h:50
Aws::Crt::Http::HttpClientConnectionManagerOptions::operator=
HttpClientConnectionManagerOptions & operator=(HttpClientConnectionManagerOptions &&rhs)=default
Aws::Crt::Http::HttpClientConnectionManagerOptions::HttpClientConnectionManagerOptions
HttpClientConnectionManagerOptions(HttpClientConnectionManagerOptions &&rhs)=default
Aws::Crt::Http::HttpClientConnectionManagerOptions::EnableBlockingShutdown
bool EnableBlockingShutdown
Definition: HttpConnectionManager.h:59
Aws::Crt::Http::HttpClientConnectionManagerOptions::HttpClientConnectionManagerOptions
HttpClientConnectionManagerOptions(const HttpClientConnectionManagerOptions &rhs)=default
Aws::Crt::Http::HttpClientConnectionOptions
Definition: HttpConnection.h:347
Aws::Crt::Http::ManagedConnection
Definition: HttpConnectionManager.cpp:166
AWS_CRT_CPP_API
#define AWS_CRT_CPP_API
Definition: Exports.h:37
Aws::Crt::Http::OnClientConnectionAvailable
std::function< void(std::shared_ptr< HttpClientConnection >, int errorCode)> OnClientConnectionAvailable
Definition: HttpConnectionManager.h:27
Aws::Crt::Allocator
aws_allocator Allocator
Definition: StlAllocator.h:17
Aws::Crt::g_allocator
AWS_CRT_CPP_API Allocator * g_allocator
Definition: Api.cpp:21
Aws
Definition: Api.h:17