MCPcopy Create free account
hub / github.com/amule-project/amule / DispatchBackgroundRead

Method DispatchBackgroundRead

src/LibSocketAsio.cpp:562–579  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

560 }
561
562 void DispatchBackgroundRead()
563 {
564 AddDebugLogLineF(logAsio, CFormat("DispatchBackgroundRead %s") % m_IP);
565 // Why async_read_some and not async_wait(wait_read): on Windows
566 // boost.asio implements async_wait via its select_reactor (a single
567 // select() loop in a dedicated thread) because IOCP has no native
568 // "ready notification" without a buffer. async_read_some maps to
569 // WSARecv on Windows (IOCP-native) and to epoll/kqueue on POSIX, so
570 // it is the fast path on every platform.
571 if (m_readBufferSize < READ_CHUNK) {
572 delete[] m_readBuffer;
573 m_readBuffer = new char[READ_CHUNK];
574 m_readBufferSize = READ_CHUNK;
575 }
576 auto self = shared_from_this();
577 m_socket->async_read_some(buffer(m_readBuffer, m_readBufferSize),
578 bind_executor(m_strand, [self](const error_code& ec, std::size_t n) { self->HandleRead(ec, n); }));
579 }
580
581 // The buffer pointer is passed explicitly so each HandleSend knows
582 // which buffer it owns and must delete. m_sendBuffer only tracks the

Callers 1

StartBackgroundReadMethod · 0.95

Calls 2

HandleReadMethod · 0.95
CFormatClass · 0.85

Tested by

no test coverage detected