MCPcopy Create free account
hub / github.com/FEX-Emu/FEX / async_read_some

Method async_read_some

Source/Common/AsyncNet.h:38–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36 template<typename OnComplete>
37 requires std::is_invocable_r_v<void, OnComplete, error, size_t, std::optional<int>>
38 void async_read_some(mutable_buffer Buffers, OnComplete UserCallback) {
39 auto Callback = [Buffers, Socket = FD, UserCallback = std::move(UserCallback)](error ec) mutable {
40 if (ec != error::success) {
41 UserCallback(ec, 0, std::nullopt);
42 return post_callback::drop;
43 }
44
45 auto BytesRead = read_some_from_fd(Buffers, ec, Socket);
46 if (ec != error::success) {
47 UserCallback(ec, BytesRead, std::nullopt);
48 } else {
49 UserCallback(ec, BytesRead, Buffers.FD ? std::optional {**Buffers.FD} : std::nullopt);
50 }
51 return post_callback::drop;
52 };
53
54 Reactor->bind_handler(
55 pollfd {
56 .fd = FD,
57 .events = POLLIN | POLLPRI | POLLRDHUP,
58 .revents = 0,
59 },
60 std::move(Callback));
61 }
62
63 /**
64 * Blocks until at least one byte of data was received

Callers 1

operator()Method · 0.80

Calls 1

bind_handlerMethod · 0.80

Tested by

no test coverage detected