AWS IoT Device SDK C++ v2
1.45.2
AWS IoT Device SDK C++ v2
Toggle main menu visibility
Loading...
Searching...
No Matches
crt
aws-crt-cpp
include
aws
crt
io
ChannelHandler.h
Go to the documentation of this file.
1
#pragma once
6
7
#include <
aws/crt/Exports.h
>
8
#include <
aws/crt/Types.h
>
9
#include <
aws/crt/io/EventLoopGroup.h
>
10
#include <aws/io/channel.h>
11
12
#include <chrono>
13
#include <cstddef>
14
15
struct
aws_array_list;
16
struct
aws_io_message;
17
18
namespace
Aws
19
{
20
namespace
Crt
21
{
22
namespace
Io
23
{
24
enum class
ChannelDirection
25
{
26
Read
,
27
Write
,
28
};
29
30
enum class
MessageType
31
{
32
ApplicationData
,
33
};
34
41
class
AWS_CRT_CPP_API
ChannelHandler
42
{
43
public
:
44
virtual
~ChannelHandler
() =
default
;
45
46
ChannelHandler
(
const
ChannelHandler
&) =
delete
;
47
ChannelHandler
&
operator=
(
const
ChannelHandler
&) =
delete
;
48
49
protected
:
63
virtual
int
ProcessReadMessage
(
struct
aws_io_message *message) = 0;
64
74
virtual
int
ProcessWriteMessage
(
struct
aws_io_message *message) = 0;
75
84
virtual
int
IncrementReadWindow
(
size_t
size) = 0;
85
98
virtual
void
ProcessShutdown
(
99
ChannelDirection
dir,
100
int
errorCode,
101
bool
freeScarceResourcesImmediately) = 0;
102
106
virtual
size_t
InitialWindowSize
() = 0;
107
112
virtual
size_t
MessageOverhead
() = 0;
113
117
virtual
void
ResetStatistics
() {};
118
123
virtual
void
GatherStatistics
(
struct
aws_array_list *) {}
124
125
public
:
127
struct
aws_channel_handler *SeatForCInterop(
const
std::shared_ptr<ChannelHandler> &selfRef);
128
132
bool
ChannelsThreadIsCallersThread()
const
;
133
139
void
ShutDownChannel(
int
errorCode);
140
145
void
ScheduleTask(std::function<
void
(
TaskStatus
)> &&task);
146
152
void
ScheduleTask(std::function<
void
(
TaskStatus
)> &&task, std::chrono::nanoseconds run_in);
153
154
protected
:
155
ChannelHandler
(
Allocator
*allocator =
ApiAllocator
());
156
160
struct
aws_io_message *AcquireMessageFromPool(
MessageType
messageType,
size_t
sizeHint);
161
167
struct
aws_io_message *AcquireMaxSizeMessageForWrite();
168
174
bool
SendMessage(
struct
aws_io_message *message,
ChannelDirection
direction);
175
180
bool
IncrementUpstreamReadWindow(
size_t
windowUpdateSize);
181
186
void
OnShutdownComplete(
ChannelDirection
direction,
int
errorCode,
bool
freeScarceResourcesImmediately);
187
193
size_t
DownstreamReadWindow()
const
;
194
199
size_t
UpstreamMessageOverhead()
const
;
200
201
struct
aws_channel_slot *GetSlot()
const
;
202
203
struct
aws_channel_handler
m_handler
;
204
Allocator
*
m_allocator
;
205
206
private
:
207
std::shared_ptr<ChannelHandler> m_selfReference;
208
static
struct
aws_channel_handler_vtable s_vtable;
209
210
static
void
s_Destroy(
struct
aws_channel_handler *handler);
211
static
int
s_ProcessReadMessage(
212
struct
aws_channel_handler *,
213
struct
aws_channel_slot *,
214
struct
aws_io_message *);
215
static
int
s_ProcessWriteMessage(
216
struct
aws_channel_handler *,
217
struct
aws_channel_slot *,
218
struct
aws_io_message *);
219
static
int
s_IncrementReadWindow(
struct
aws_channel_handler *,
struct
aws_channel_slot *,
size_t
size);
220
static
int
s_ProcessShutdown(
221
struct
aws_channel_handler *,
222
struct
aws_channel_slot *,
223
enum
aws_channel_direction,
224
int
errorCode,
225
bool
freeScarceResourcesImmediately);
226
static
size_t
s_InitialWindowSize(
struct
aws_channel_handler *);
227
static
size_t
s_MessageOverhead(
struct
aws_channel_handler *);
228
static
void
s_ResetStatistics(
struct
aws_channel_handler *);
229
static
void
s_GatherStatistics(
struct
aws_channel_handler *,
struct
aws_array_list *statsList);
230
};
231
}
// namespace Io
232
}
// namespace Crt
233
}
// namespace Aws
EventLoopGroup.h
Types.h
Aws::Crt::Io::ChannelHandler
Definition
ChannelHandler.h:42
Aws::Crt::Io::ChannelHandler::m_handler
struct aws_channel_handler m_handler
Definition
ChannelHandler.h:203
Aws::Crt::Io::ChannelHandler::ProcessShutdown
virtual void ProcessShutdown(ChannelDirection dir, int errorCode, bool freeScarceResourcesImmediately)=0
Aws::Crt::Io::ChannelHandler::ProcessWriteMessage
virtual int ProcessWriteMessage(struct aws_io_message *message)=0
Aws::Crt::Io::ChannelHandler::MessageOverhead
virtual size_t MessageOverhead()=0
Aws::Crt::Io::ChannelHandler::GatherStatistics
virtual void GatherStatistics(struct aws_array_list *)
Definition
ChannelHandler.h:123
Aws::Crt::Io::ChannelHandler::ChannelHandler
ChannelHandler(const ChannelHandler &)=delete
Aws::Crt::Io::ChannelHandler::ProcessReadMessage
virtual int ProcessReadMessage(struct aws_io_message *message)=0
Aws::Crt::Io::ChannelHandler::ResetStatistics
virtual void ResetStatistics()
Definition
ChannelHandler.h:117
Aws::Crt::Io::ChannelHandler::m_allocator
Allocator * m_allocator
Definition
ChannelHandler.h:204
Aws::Crt::Io::ChannelHandler::IncrementReadWindow
virtual int IncrementReadWindow(size_t size)=0
Aws::Crt::Io::ChannelHandler::~ChannelHandler
virtual ~ChannelHandler()=default
Aws::Crt::Io::ChannelHandler::operator=
ChannelHandler & operator=(const ChannelHandler &)=delete
Aws::Crt::Io::ChannelHandler::InitialWindowSize
virtual size_t InitialWindowSize()=0
Exports.h
AWS_CRT_CPP_API
#define AWS_CRT_CPP_API
Definition
Exports.h:36
Aws::Crt::Io
Definition
Credentials.h:23
Aws::Crt::Io::ChannelDirection
ChannelDirection
Definition
ChannelHandler.h:25
Aws::Crt::Io::ChannelDirection::Write
@ Write
Definition
ChannelHandler.h:27
Aws::Crt::Io::ChannelDirection::Read
@ Read
Definition
ChannelHandler.h:26
Aws::Crt::Io::MessageType
MessageType
Definition
ChannelHandler.h:31
Aws::Crt::Io::MessageType::ApplicationData
@ ApplicationData
Definition
ChannelHandler.h:32
Aws::Crt::Io::TaskStatus
TaskStatus
Definition
EventLoopGroup.h:25
Aws::Crt
Definition
Allocator.h:13
Aws::Crt::ApiAllocator
AWS_CRT_CPP_API Allocator * ApiAllocator() noexcept
Definition
Allocator.cpp:24
Aws::Crt::Allocator
aws_allocator Allocator
Definition
Allocator.h:14
Aws
Definition
Allocator.h:11
Generated by
1.17.0