AWS IoT Device SDK C++ v2 1.45.1
AWS IoT Device SDK C++ v2
Loading...
Searching...
No Matches
EventLoopGroup.h
Go to the documentation of this file.
1#pragma once
6#include <aws/crt/Types.h>
7
8#include <aws/io/event_loop.h>
9
10#include <chrono>
11#include <functional>
12#include <memory>
13
14namespace Aws
15{
16 namespace Crt
17 {
18 namespace Io
19 {
24 enum class TaskStatus
25 {
28 };
29
35 {
36 public:
37 ScheduledTask() noexcept = default;
38
39 void Cancel() noexcept;
40
41 private:
42 class Impl;
43
44 explicit ScheduledTask(std::shared_ptr<Impl> impl) noexcept;
45
46 std::shared_ptr<Impl> m_impl;
47
48 friend class EventLoop;
49 };
50
56 class AWS_CRT_CPP_API EventLoop final
57 {
58 public:
62 explicit operator bool() const noexcept { return m_loop != nullptr; }
63
69 ScheduledTask Schedule(
70 std::function<void(TaskStatus)> &&task,
71 std::chrono::nanoseconds run_in) noexcept;
72
73 private:
74 explicit EventLoop(aws_event_loop *loop) noexcept;
75
76 aws_event_loop *m_loop;
77
78 friend class ClientBootstrap;
79 };
80
98 {
99 public:
105 EventLoopGroup(uint16_t threadCount = 0, Allocator *allocator = ApiAllocator()) noexcept;
112 EventLoopGroup(uint16_t cpuGroup, uint16_t threadCount, Allocator *allocator = ApiAllocator()) noexcept;
115 EventLoopGroup(EventLoopGroup &&) noexcept;
116 EventLoopGroup &operator=(const EventLoopGroup &) = delete;
117 EventLoopGroup &operator=(EventLoopGroup &&) noexcept;
118
122 operator bool() const;
123
127 int LastError() const;
128
130 aws_event_loop_group *GetUnderlyingHandle() noexcept;
131
132 private:
133 aws_event_loop_group *m_eventLoopGroup;
134 int m_lastError;
135 };
136 } // namespace Io
137
138 } // namespace Crt
139} // namespace Aws
int LastError() const
Definition EventLoopGroup.cpp:61
EventLoopGroup(uint16_t threadCount=0, Allocator *allocator=ApiAllocator()) noexcept
Definition EventLoopGroup.cpp:18
EventLoopGroup(const EventLoopGroup &)=delete
Definition EventLoopGroup.h:57
friend class ClientBootstrap
Definition EventLoopGroup.h:78
Definition EventLoopGroup.cpp:82
Definition EventLoopGroup.h:35
void Cancel() noexcept
Definition EventLoopGroup.cpp:148
ScheduledTask() noexcept=default
friend class EventLoop
Definition EventLoopGroup.h:48
#define AWS_CRT_CPP_API
Definition Exports.h:36
Definition Credentials.h:23
TaskStatus
Definition EventLoopGroup.h:25
@ Canceled
Definition EventLoopGroup.h:27
@ RunReady
Definition EventLoopGroup.h:26
Definition Allocator.h:13
AWS_CRT_CPP_API Allocator * ApiAllocator() noexcept
Definition Allocator.cpp:24
aws_allocator Allocator
Definition Allocator.h:14
Definition Allocator.h:11
Definition StringView.h:862