Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 36be19a

Browse files
committed
Refactor file_read/write_operation classes for Win32.
- Move common logic for Win32 OVERLAPPED-based operations out into new win32_overlapped_operation[_cancellable] base-classes. The concrete I/O operation classes are now greatly simplified due to the reduction of boilerplate. - Added overloads for read() and write() functions that don't take a cancellation_token that return a simpler awaitable type that generates much simpler assembly.
1 parent 0988627 commit 36be19a

11 files changed

+633
-545
lines changed

include/cppcoro/detail/win32.hpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include <utility>
1515
#include <cstdint>
1616

17+
struct _OVERLAPPED;
18+
1719
namespace cppcoro
1820
{
1921
namespace detail
@@ -68,6 +70,29 @@ namespace cppcoro
6870
win32::dword_t numberOfBytesTransferred,
6971
win32::ulongptr_t completionKey);
7072

73+
io_state(callback_type* callback = nullptr) noexcept
74+
: io_state(std::uint64_t(0), callback)
75+
{}
76+
77+
io_state(void* pointer, callback_type* callback) noexcept
78+
: m_callback(callback)
79+
{
80+
this->Internal = 0;
81+
this->InternalHigh = 0;
82+
this->Pointer = pointer;
83+
this->hEvent = nullptr;
84+
}
85+
86+
io_state(std::uint64_t offset, callback_type* callback) noexcept
87+
: m_callback(callback)
88+
{
89+
this->Internal = 0;
90+
this->InternalHigh = 0;
91+
this->Offset = static_cast<dword_t>(offset);
92+
this->OffsetHigh = static_cast<dword_t>(offset >> 32);
93+
this->hEvent = nullptr;
94+
}
95+
7196
callback_type* m_callback;
7297
};
7398

0 commit comments

Comments
 (0)