Skip to content

Commit ae603fa

Browse files
committed
refactor: directly construct Resource instance
1 parent 08032c4 commit ae603fa

2 files changed

Lines changed: 4 additions & 8 deletions

File tree

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,16 +195,14 @@ namespace {
195195
// For the top-level task, complex subtasks will branch out and form a tree.
196196
asyncio::task::Task<void> tracing(const auto &task) {
197197
#ifdef _WIN32
198-
const auto handle = CreateEventA(nullptr, false, false, "Global\\AsyncIOBacktraceEvent");
198+
const zero::os::Resource event{CreateEventA(nullptr, false, false, "Global\\AsyncIOBacktraceEvent")};
199199

200-
if (!handle)
200+
if (!event)
201201
throw co_await asyncio::error::StacktraceError<std::system_error>::make(
202202
static_cast<int>(GetLastError()),
203203
std::system_category()
204204
);
205205

206-
const zero::os::Resource event{handle};
207-
208206
while (true) {
209207
bool cancelled{false};
210208

src/process.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,11 @@ std::optional<asyncio::Pipe> &asyncio::process::ChildProcess::stdError() {
2828
// ReSharper disable once CppMemberFunctionMayBeConst
2929
asyncio::task::Task<asyncio::process::ExitStatus, std::error_code> asyncio::process::ChildProcess::wait() {
3030
#ifdef _WIN32
31-
const auto handle = CreateEventA(nullptr, false, false, nullptr);
31+
const zero::os::Resource event{CreateEventA(nullptr, false, false, nullptr)};
3232

33-
if (!handle)
33+
if (!event)
3434
co_return std::unexpected{std::error_code{static_cast<int>(GetLastError()), std::system_category()}};
3535

36-
const zero::os::Resource event{handle};
37-
3836
co_return co_await toThread(
3937
[&]() -> std::expected<ExitStatus, std::error_code> {
4038
const auto &impl = this->impl();

0 commit comments

Comments
 (0)